Clean up IconSelectorView code (#745)

* Clean up code

* Update IceCubesApp/App/Tabs/Settings/IconSelectorView.swift

Co-authored-by: Ico Davids <ico.davids@gmail.com>

---------

Co-authored-by: Ico Davids <ico.davids@gmail.com>
This commit is contained in:
Sean Goldin 2023-02-09 11:49:03 -06:00 committed by GitHub
parent ce5ee5e021
commit d5177f9b2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 55 deletions

View File

@ -24,28 +24,6 @@ struct IconSelectorView: View {
case alt29, alt30, alt31, alt32 case alt29, alt30, alt31, alt32
case alt33 case alt33
static var officialIcons: [Icon] {
[.primary, .alt1, .alt2, .alt3, .alt4, .alt5, .alt6, .alt7, .alt8,
.alt9, .alt10, .alt11, .alt12, .alt13, .alt14,
.alt15, .alt16, .alt17, .alt18, .alt19, .alt25]
}
static var albertKinngIcons: [Icon] {
[.alt20, .alt21, .alt22, .alt23, .alt24]
}
static var danIcons: [Icon] {
[.alt26, .alt27, .alt28]
}
static var tes6Icons: [Icon] {
[.alt29, .alt30, .alt31, .alt32]
}
static var agnesIcons: [Icon] {
[.alt33]
}
var appIconName: String { var appIconName: String {
switch self { switch self {
case .primary: case .primary:
@ -60,6 +38,22 @@ struct IconSelectorView: View {
} }
} }
struct IconSelector: Identifiable {
var id = UUID()
let title: String
let icons: [Icon]
static let items = [
IconSelector(title: "Official icons", icons: [.primary, .alt1, .alt2, .alt3, .alt4, .alt5, .alt6, .alt7, .alt8,
.alt9, .alt10, .alt11, .alt12, .alt13, .alt14,
.alt15, .alt16, .alt17, .alt18, .alt19, .alt25]),
IconSelector(title: "Icons by Albert Kinng", icons: [.alt20, .alt21, .alt22, .alt23, .alt24]),
IconSelector(title: "Icons by Dan van Moll", icons: [.alt26, .alt27, .alt28]),
IconSelector(title: "Icons by @te6-in (GitHub)", icons: [.alt29, .alt30, .alt31, .alt32]),
IconSelector(title: "Icon by W. Kovács Ágnes (@wildgica)", icons: [.alt33]),
]
}
@EnvironmentObject private var theme: Theme @EnvironmentObject private var theme: Theme
@State private var currentIcon = UIApplication.shared.alternateIconName ?? Icon.primary.appIconName @State private var currentIcon = UIApplication.shared.alternateIconName ?? Icon.primary.appIconName
@ -68,39 +62,13 @@ struct IconSelectorView: View {
var body: some View { var body: some View {
ScrollView { ScrollView {
VStack(alignment: .leading) { VStack(alignment: .leading) {
Section { ForEach(IconSelector.items) { item in
makeIconGridView(icons: Icon.officialIcons) Section {
} header: { makeIconGridView(icons: item.icons)
Text("Official icons") } header: {
.font(.scaledHeadline) Text(item.title)
} .font(.scaledHeadline)
}
Section {
makeIconGridView(icons: Icon.albertKinngIcons)
} header: {
Text("Icons by Albert Kinng")
.font(.scaledHeadline)
}
Section {
makeIconGridView(icons: Icon.danIcons)
} header: {
Text("Icons by Dan van Moll")
.font(.scaledHeadline)
}
Section {
makeIconGridView(icons: Icon.tes6Icons)
} header: {
Text("Icons by @te6-in (GitHub)")
.font(.scaledHeadline)
}
Section {
makeIconGridView(icons: Icon.agnesIcons)
} header: {
Text("Icon by W. Kovács Ágnes (@wildgica)")
.font(.scaledHeadline)
} }
} }
.padding(6) .padding(6)