Skip to content

Instantly share code, notes, and snippets.

@all12jus
Created October 6, 2022 02:07
Show Gist options
  • Save all12jus/358384ebc774051709c98f92a97550c7 to your computer and use it in GitHub Desktop.
Save all12jus/358384ebc774051709c98f92a97550c7 to your computer and use it in GitHub Desktop.
SampleIconChanger
//
// ContentView.swift
// SampleIconChanger
//
// Created by Justin Allen on 10/5/22.
//
import SwiftUI
struct AppIconChanger: View {
var colors: [Color] = [.red, .purple, .blue, .yellow, .orange, .teal, .cyan]
var unlockedColor: [Color] = [.purple, .orange]
var body: some View {
VStack {
Text("App Icon").bold()
ScrollView(.horizontal) {
HStack {
ForEach(colors, id: \.self) { color in
ZStack (alignment:.top) {
Button {
} label: {
ZStack {
color.frame(width: 69, height: 69).cornerRadius(5)
if !unlockedColor.contains(color) {
Image(systemName: "lock")
}
}
}
.buttonStyle(.plain).disabled(!unlockedColor.contains(color))
VStack {
Spacer().frame(height: 69)
Button {
} label: {
Text("$0.99").font(.footnote)
}
.buttonStyle(.borderedProminent)
.padding(.top, 4)
.disabled(unlockedColor.contains(color))
} // vstack
} // ztack
} // foreach
} // hstack
.padding(.bottom, 8)
} //scroll view
Text("Unlocking app icon doesn't remove ads.").font(.caption2).foregroundColor(.secondary)
} // vstack
}
}
struct ContentView: View {
var body: some View {
// VStack {
// Image(systemName: "globe")
// .imageScale(.large)
// .foregroundColor(.accentColor)
// Text("Hello, world!")
// }
// .padding()
NavigationView {
Form {
AppIconChanger()
}
.navigationTitle("App Icon Changer Sample")
.navigationBarTitleDisplayMode(.inline)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment