Mercurial > public > lazybear
changeset 212:e7fc442ccdc8
Update IconPicker
author | Dennis Concepción Martín <66180929+denniscm190@users.noreply.github.com> |
---|---|
date | Sat, 27 Feb 2021 12:45:03 +0000 |
parents | 43a05e129bad |
children | 94f80732226a |
files | LazyBear/UI/IconPicker.swift |
diffstat | 1 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/LazyBear/UI/IconPicker.swift Sat Feb 27 12:44:55 2021 +0000 +++ b/LazyBear/UI/IconPicker.swift Sat Feb 27 12:45:03 2021 +0000 @@ -10,10 +10,34 @@ struct IconPicker: View { var body: some View { List(icons, id:\.name) { icon in - IconRow(icon: icon) + Button(action: { changeIcon(key: icon.file) }) { + HStack { + Image(icon.file) + .resizable() + .cornerRadius(20) + .frame(width: 70, height: 70) + + Text(icon.name) + } + } + .buttonStyle(PlainButtonStyle()) } .listStyle(GroupedListStyle()) } + + private func changeIcon(key: String) { + if key != "defaultIcon" { + UIApplication.shared.setAlternateIconName(key) { error in + if let error = error { + print(error.localizedDescription) + } else { + print("Success!") + } + } + } else { + UIApplication.shared.setAlternateIconName(nil) + } + } } struct IconPicker_Previews: PreviewProvider {