Skip to content
thisisthewa2 edited this page Jun 22, 2023 · 3 revisions

😲 Learned

  • AppStorage의 μ‚¬μš© 방법에 λŒ€ν•΄ 읡힘
  • MVC -> MVVM으둜 λ³€κ²½ν•˜λ©° MVVM의 κ°œλ…μ— λŒ€ν•΄ 배울 수 μžˆμ—ˆμŒ
  • 첫 iOSμ•± μ•±μŠ€ν† μ–΄ 배포 성곡!

✏️ Todo

  • νŒŒμ΄μ–΄λ² μ΄μŠ€λ₯Ό μ‚¬μš©ν•œ 둜그인 κΈ°λŠ₯ κ΅¬ν˜„ (진행쀑)
  • μΊ˜λ¦°λ”μ— μš΄λ™ν•œ λ‚  ν‘œμ‹œ

πŸ’» Code

  • μ‚¬μš©μžμ˜ μš΄λ™ μ„€μ • 사항을 μ €μž₯ν•˜κΈ° μœ„ν•œ 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()
        
    }
}
Clone this wiki locally