theme list is now adaptive - it divides the width of the view by 200 to get the columns count

each theme preview is 150-250 wide
This commit is contained in:
neon443
2025-06-29 17:52:37 +01:00
parent 80ddde3a62
commit a4a71968fe

View File

@@ -19,12 +19,15 @@ struct ThemeManagerView: View {
@State var rename: String = ""
let grid: GridItem = GridItem(
.flexible(minimum: 100, maximum: 200),
.flexible(minimum: 150, maximum: 250),
spacing: 8,
alignment: .center
)
var body: some View {
GeometryReader { geo in
let columns: Int = Int(geo.size.width)/200
let layout = Array(repeating: grid, count: columns)
ScrollView {
if hostsManager.themes.isEmpty {
VStack(alignment: .leading) {
@@ -40,7 +43,7 @@ struct ThemeManagerView: View {
Text("Once you find one that you like, copy it's link and enter it here using the link button.")
}
} else {
LazyVGrid(columns: [grid, grid], alignment: .center, spacing: 8) {
LazyVGrid(columns: layout, alignment: .center, spacing: 8) {
ForEach(hostsManager.themes) { theme in
ThemePreview(hostsManager: hostsManager, theme: theme, canModify: true)
}
@@ -56,7 +59,7 @@ struct ThemeManagerView: View {
.font(.headline)
Spacer()
}
LazyVGrid(columns: [grid, grid], alignment: .center, spacing: 8) {
LazyVGrid(columns: layout, alignment: .center, spacing: 8) {
ForEach(Theme.builtinThemes) { theme in
ThemePreview(hostsManager: hostsManager, theme: theme, canModify: false)
}
@@ -90,6 +93,8 @@ struct ThemeManagerView: View {
} label: {
Label("From URL", systemImage: "link")
}
}
}
}
}