Add credits section to icon selector

This commit is contained in:
Thomas Ricouard 2023-01-28 08:58:36 +01:00
parent 0fb9e60c3f
commit edb43040a3

View file

@ -20,6 +20,16 @@ struct IconSelectorView: View {
case alt9, alt10, alt11, alt12, alt13, alt14 case alt9, alt10, alt11, alt12, alt13, alt14
case alt15, alt16, alt17, alt18, alt19, alt20, alt21 case alt15, alt16, alt17, alt18, alt19, alt20, alt21
case alt22, alt23, alt24 case alt22, alt23, alt24
static var officialIcons: [Icon] {
[.alt1, .alt2, .alt3, .alt4, .alt5, .alt6, .alt7, .alt8,
.alt9, .alt10, .alt11, .alt12, .alt13, .alt14,
.alt15, .alt16, .alt17, .alt18, .alt19]
}
static var albertKinngIcons: [Icon] {
[.alt20, .alt21, .alt22, .alt23, .alt24]
}
var appIconName: String { var appIconName: String {
switch self { switch self {
@ -43,31 +53,18 @@ struct IconSelectorView: View {
var body: some View { var body: some View {
ScrollView { ScrollView {
VStack(alignment: .leading) { VStack(alignment: .leading) {
LazyVGrid(columns: columns, spacing: 6) { Section {
ForEach(Icon.allCases) { icon in makeIconGridView(icons: Icon.officialIcons)
Button { } header: {
currentIcon = icon.appIconName Text("Official icons")
if icon.rawValue == Icon.primary.rawValue { .font(.scaledHeadline)
UIApplication.shared.setAlternateIconName(nil) }
} else {
UIApplication.shared.setAlternateIconName(icon.appIconName) Section {
} makeIconGridView(icons: Icon.albertKinngIcons)
} label: { } header: {
ZStack(alignment: .bottomTrailing) { Text("Icons by Alert Kinng")
Image(uiImage: .init(named: icon.iconName) ?? .init()) .font(.scaledHeadline)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(minHeight: 125, maxHeight: 1024)
.cornerRadius(6)
.shadow(radius: 3)
if icon.appIconName == currentIcon {
Image(systemName: "checkmark.seal.fill")
.padding(4)
.tint(.green)
}
}
}
}
} }
} }
.padding(6) .padding(6)
@ -75,4 +72,33 @@ struct IconSelectorView: View {
} }
.background(theme.primaryBackgroundColor) .background(theme.primaryBackgroundColor)
} }
private func makeIconGridView(icons: [Icon]) -> some View {
LazyVGrid(columns: columns, spacing: 6) {
ForEach(icons) { icon in
Button {
currentIcon = icon.appIconName
if icon.rawValue == Icon.primary.rawValue {
UIApplication.shared.setAlternateIconName(nil)
} else {
UIApplication.shared.setAlternateIconName(icon.appIconName)
}
} label: {
ZStack(alignment: .bottomTrailing) {
Image(uiImage: .init(named: icon.iconName) ?? .init())
.resizable()
.aspectRatio(contentMode: .fit)
.frame(minHeight: 125, maxHeight: 1024)
.cornerRadius(6)
.shadow(radius: 3)
if icon.appIconName == currentIcon {
Image(systemName: "checkmark.seal.fill")
.padding(4)
.tint(.green)
}
}
}
}
}
}
} }