-
Notifications
You must be signed in to change notification settings - Fork 1
Mando
thisisthewa2 edited this page Jun 22, 2023
·
3 revisions
- AppStorageμ μ¬μ© λ°©λ²μ λν΄ μ΅ν
- MVC -> MVVMμΌλ‘ λ³κ²½νλ©° MVVMμ κ°λ μ λν΄ λ°°μΈ μ μμμ
- 첫 iOSμ± μ±μ€ν μ΄ λ°°ν¬ μ±κ³΅!
- νμ΄μ΄λ² μ΄μ€λ₯Ό μ¬μ©ν λ‘κ·ΈμΈ κΈ°λ₯ ꡬν (μ§νμ€)
- μΊλ¦°λμ μ΄λν λ νμ
- μ¬μ©μμ μ΄λ μ€μ μ¬νμ μ μ₯νκΈ° μν WorkoutSettingsView ꡬν
struct WorkoutSettingsView: View {
@StateObject var settings = WorkoutSettingsManager.shared
//Onboarding Screenμ λμ°κΈ° μν λ³μ
@AppStorage("firstVisit") var isFirstTimeVisited = true
//btnBackμ λλ μ λ λ©μΈνλ©΄μΌλ‘ λμκ°κΈ° μν¨.
@Environment(\.dismiss) private var dismiss
//λ©μΈ νλ©΄μΌλ‘ λμκ°λ λ²νΌ, λ€λΉκ²μ΄μ
μ΄ μλ νμ¬ νλ©΄μ μ§μμ λμκ°
@State private var buttonBackColor: Color = Color("neongreen")
var btnBack: some View{
Button(action:{dismiss()}){
HStack{
Image(systemName: "chevron.left")
.font(.system(size: 22))
.fontWeight(.bold)
.foregroundColor(.white)
}
}
}
//λ€λΉκ²μ΄μ
νμ΄νμ κ²½μ° μμ μ§μ μ μν΄ λ³λμ μ΄κΈ°νκ° νμν΄μ μμ±
init() {
// Large FontμΌ λ μ¬μ©
UINavigationBar.appearance().largeTitleTextAttributes = [.foregroundColor: UIColor.white]
// displayMode = .inlineμΌ λ μ¬μ©
UINavigationBar.appearance().titleTextAttributes = [.foregroundColor: UIColor.white]
}
var body: some View{
NavigationView{
ZStack{
Color("background")
.ignoresSafeArea()
VStack (spacing:80){
VStack(spacing: 20){
Text("νκ³ μΆμ§ μμ λμμ΄ μλμ?")
.font(.system(size: 20))
.fontWeight(.semibold)
HStack{
Button(action:{
settings.selectUpperBody.toggle()
if settings.selectUpperBody == true && settings.selectLowerBody == true {
settings.selectLowerBody.toggle()
}
}){
Text("μ체")
.foregroundColor(settings.selectUpperBody ? .black: .white)
.padding()
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(Color("buttonBackgroundStart"),lineWidth: 3)
)
}
.background(LinearGradient(gradient: settings.selectUpperBody ? Gradient(colors: [Color("buttonBackgroundStart"), Color("buttonBackgroundEnd")]) : Gradient(colors: [Color("background")]), startPoint: .leading, endPoint: .trailing))
.cornerRadius(20)
Button(action:{
settings.selectLowerBody.toggle()
if settings.selectUpperBody == true && settings.selectLowerBody == true {
settings.selectUpperBody.toggle()
}
}){
Text("ν체")
.foregroundColor(settings.selectLowerBody ? .black: .white)
.padding()
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(Color("buttonBackgroundStart"),lineWidth: 3)
)
}
.background(LinearGradient(gradient: settings.selectLowerBody ? Gradient(colors: [Color("buttonBackgroundStart"), Color("buttonBackgroundEnd")]) : Gradient(colors: [Color("background")]), startPoint: .leading, endPoint: .trailing))
.cornerRadius(20) }
}
VStack( spacing: 20){
Text("1ν μ΄λ μκ°μ μ νμΈμ.")
.font(.system(size: 20))
.fontWeight(.semibold)
HStack{
Button(action:{
settings.selectFiveMinutes.toggle()
if(settings.selectFiveMinutes == true && settings.selectSevenMinutes == true){
settings.selectSevenMinutes.toggle()
}
}){
Text("5λΆ")
.foregroundColor(settings.selectFiveMinutes ? .black: .white)
.padding()
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(Color("buttonBackgroundStart"),lineWidth: 3)
)
}
.background(LinearGradient(gradient: settings.selectFiveMinutes ? Gradient(colors: [Color("buttonBackgroundStart"), Color("buttonBackgroundEnd")]) : Gradient(colors: [Color("background")]), startPoint: .leading, endPoint: .trailing))
.cornerRadius(20)
Button(action:{
settings.selectSevenMinutes.toggle()
if(settings.selectFiveMinutes == true && settings.selectSevenMinutes == true){
settings.selectFiveMinutes.toggle()
}
}){
Text("7λΆ")
.foregroundColor(settings.selectSevenMinutes ? .black: .white)
.padding()
.overlay(
RoundedRectangle(cornerRadius: 20)
.stroke(Color("buttonBackgroundStart"),lineWidth: 3)
)
}
.background(LinearGradient(gradient: settings.selectSevenMinutes ? Gradient(colors: [Color("buttonBackgroundStart"), Color("buttonBackgroundEnd")]) : Gradient(colors: [Color("background")]), startPoint: .leading, endPoint: .trailing))
.cornerRadius(20)
}
}
}
.navigationTitle("μ΄λ μ€μ ")
.foregroundColor(Color.white)
.navigationBarItems(leading: btnBack)
}
}.navigationBarBackButtonHidden()
}
}