Files
Reflect/Shared/views/CustomizeView/SubViews/IconPickerView.swift
Trey t 682f62fa4a separate all customize views into their own files
make corner radius a constant
create the views in the main app file and pass through so they dont get re-drawn when changing UI things
2022-04-02 10:53:04 -05:00

71 lines
2.6 KiB
Swift

//
// IconPickerView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 4/2/22.
//
import SwiftUI
struct IconPickerView: View {
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
let iconSets: [(String,String)] = [
("AppIconGoodImage", "AppIconGood"),
("AppIconAverageImage", "AppIconAverage"),
("AppIconBadImage", "AppIconBad"),
("AppIconBlueGreenImage", "AppIconBlueGreen"),
("AppIconNeonGreenImage", "AppIconNeonGreen"),
("AppIconPinkImage", "AppIconPink"),
("AppIconPurpleImage", "AppIconPurple")
]
var body: some View {
ZStack {
theme.currentTheme.secondaryBGColor
VStack {
ScrollView(.horizontal) {
HStack {
Button(action: {
UIApplication.shared.setAlternateIconName(nil)
EventLogger.log(event: "change_icon_title", withData: ["title": "default"])
}, label: {
Image("AppIconImage", bundle: .main)
.resizable()
.frame(width: 50, height:50)
.cornerRadius(10)
})
ForEach(iconSets, id: \.self.0){ iconSet in
Button(action: {
UIApplication.shared.setAlternateIconName(iconSet.1) { (error) in
// FIXME: Handle error
}
EventLogger.log(event: "change_icon_title", withData: ["title": iconSet.1])
}, label: {
Image(iconSet.0, bundle: .main)
.resizable()
.frame(width: 50, height:50)
.cornerRadius(10)
})
}
}
.padding()
}
.background(RoundedRectangle(cornerRadius: 10).fill().foregroundColor(theme.currentTheme.bgColor))
.padding()
.cornerRadius(10)
}
}
.fixedSize(horizontal: false, vertical: true)
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
}
}
struct IconPickerView_Previews: PreviewProvider {
static var previews: some View {
IconPickerView()
}
}