mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-12 05:46:15 +00:00
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:
@@ -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