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 committed 2025-06-29 17:52:37 +01:00
1 parent 80ddde3a62
commit a4a71968fe
1 file changed
+8 -3
+8 -3
View File
@@ -19,12 +19,15 @@ struct ThemeManagerView: View {
@State var rename: String = "" @State var rename: String = ""
let grid: GridItem = GridItem( let grid: GridItem = GridItem(
.flexible(minimum: 100, maximum: 200), .flexible(minimum: 150, maximum: 250),
spacing: 8, spacing: 8,
alignment: .center alignment: .center
) )
var body: some View { var body: some View {
GeometryReader { geo in
let columns: Int = Int(geo.size.width)/200
let layout = Array(repeating: grid, count: columns)
ScrollView { ScrollView {
if hostsManager.themes.isEmpty { if hostsManager.themes.isEmpty {
VStack(alignment: .leading) { 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.") Text("Once you find one that you like, copy it's link and enter it here using the link button.")
} }
} else { } else {
LazyVGrid(columns: [grid, grid], alignment: .center, spacing: 8) { LazyVGrid(columns: layout, alignment: .center, spacing: 8) {
ForEach(hostsManager.themes) { theme in ForEach(hostsManager.themes) { theme in
ThemePreview(hostsManager: hostsManager, theme: theme, canModify: true) ThemePreview(hostsManager: hostsManager, theme: theme, canModify: true)
} }
@@ -56,7 +59,7 @@ struct ThemeManagerView: View {
.font(.headline) .font(.headline)
Spacer() Spacer()
} }
LazyVGrid(columns: [grid, grid], alignment: .center, spacing: 8) { LazyVGrid(columns: layout, alignment: .center, spacing: 8) {
ForEach(Theme.builtinThemes) { theme in ForEach(Theme.builtinThemes) { theme in
ThemePreview(hostsManager: hostsManager, theme: theme, canModify: false) ThemePreview(hostsManager: hostsManager, theme: theme, canModify: false)
} }
@@ -90,6 +93,8 @@ struct ThemeManagerView: View {
} label: { } label: {
Label("From URL", systemImage: "link") Label("From URL", systemImage: "link")
} }
}
} }
} }
} }
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.