diff --git a/HongikYeolgong2/Domain/Interactors/UserDataInteractor.swift b/HongikYeolgong2/Domain/Interactors/UserDataInteractor.swift index e126003..7154ff3 100644 --- a/HongikYeolgong2/Domain/Interactors/UserDataInteractor.swift +++ b/HongikYeolgong2/Domain/Interactors/UserDataInteractor.swift @@ -110,7 +110,7 @@ final class UserDataInteractorImpl: UserDataInteractor { receiveCompletion: { [weak self] completion in guard let self = self else { return } switch completion { - case .finished: + case .finished: appState[\.appLaunchState] = .authenticated case let .failure(error): appState[\.appLaunchState] = .notAuthenticated diff --git a/HongikYeolgong2/Presentation/Auth/OnboardingView.swift b/HongikYeolgong2/Presentation/Auth/OnboardingView.swift index 5dabd5a..580a57a 100644 --- a/HongikYeolgong2/Presentation/Auth/OnboardingView.swift +++ b/HongikYeolgong2/Presentation/Auth/OnboardingView.swift @@ -19,6 +19,7 @@ struct OnboardingView: View { content .onReceive(routingUpdate) { self.routingState = $0 } } + .navigationViewStyle(.stack) } // MARK: - Main Contents diff --git a/HongikYeolgong2/Presentation/Auth/SignUpView.swift b/HongikYeolgong2/Presentation/Auth/SignUpView.swift index 375f442..2c4aafe 100644 --- a/HongikYeolgong2/Presentation/Auth/SignUpView.swift +++ b/HongikYeolgong2/Presentation/Auth/SignUpView.swift @@ -9,12 +9,17 @@ import SwiftUI import Combine struct SignUpView: View { + @Environment(\.injected.appState) var appState @Environment(\.injected.interactors.userDataInteractor) var userDataInetractor - + @Environment(\.presentationMode) var presentationMode @State private var signupData = SignupData() @State private var isSubmitButtonAvailable = false @State private var isCheckButtonAvailable = false + init() { + UINavigationBar.setAnimationsEnabled(false) + } + var body: some View { content .onChange(of: signupData.nickname, perform: { validateUserNickname(nickname: $0)} ) diff --git a/HongikYeolgong2/Presentation/Home/HomeView.swift b/HongikYeolgong2/Presentation/Home/HomeView.swift index 2c88ab9..1a46c7b 100644 --- a/HongikYeolgong2/Presentation/Home/HomeView.swift +++ b/HongikYeolgong2/Presentation/Home/HomeView.swift @@ -80,9 +80,11 @@ struct HomeView: View { } .padding(.horizontal, 32.adjustToScreenWidth) .modifier(GradientBackground()) - .onAppear { permissions.request(permission: .localNotifications) } - .onAppear { weeklyStudyInteractor.getWeekyStudy(studyRecords: $studyRecords) } - .onAppear { weeklyStudyInteractor.getWiseSaying(wiseSaying: $wiseSaying) } + .onAppear { + permissions.request(permission: .localNotifications) + weeklyStudyInteractor.getWeekyStudy(studyRecords: $studyRecords) + weeklyStudyInteractor.getWiseSaying(wiseSaying: $wiseSaying) + } .onReceive(studySessionUpdated) { studySession = $0 } } } diff --git a/HongikYeolgong2/Presentation/Root/InitialView.swift b/HongikYeolgong2/Presentation/Root/InitialView.swift index f4aa646..d212781 100644 --- a/HongikYeolgong2/Presentation/Root/InitialView.swift +++ b/HongikYeolgong2/Presentation/Root/InitialView.swift @@ -14,23 +14,20 @@ struct InitialView: View { @State private var appLaunchState: AppState.AppLaunchState = .checkAuthentication var body: some View { - Group { - content - .onReceive(isAppLaunchStateUpdated) { appLaunchState = $0 } - } - } - - @ViewBuilder private var content: some View { - switch appLaunchState { - case .notAuthenticated: - OnboardingView() - case .authenticated: - MainTabView() - case .checkAuthentication: - SplashView() - .ignoresSafeArea(.all) - .onAppear(perform: appLaunchCompleted) + NavigationView { + switch appLaunchState { + case .notAuthenticated: + OnboardingView() + case .authenticated: + MainTabView() + case .checkAuthentication: + SplashView() + .ignoresSafeArea(.all) + .onAppear(perform: appLaunchCompleted) + } } + .navigationViewStyle(.stack) + .onReceive(isAppLaunchStateUpdated) { appLaunchState = $0 } } } diff --git a/HongikYeolgong2/Presentation/Root/MainTabView.swift b/HongikYeolgong2/Presentation/Root/MainTabView.swift index 14189c4..3b43f62 100644 --- a/HongikYeolgong2/Presentation/Root/MainTabView.swift +++ b/HongikYeolgong2/Presentation/Root/MainTabView.swift @@ -15,75 +15,59 @@ enum Tab: CaseIterable { var title: String { switch self { - case .home: - "홈" - case .record: - "기록" - case .ranking: - "랭킹" - case .setting: - "설정" + case .home: "홈" + case .record: "기록" + case .ranking: "랭킹" + case .setting: "설정" } } var iconName: String { switch self { - case .home: - "home" - case .record: - "calendar" - case .ranking: - "ranking" - case .setting: - "setting" + case .home: "home" + case .record: "calendar" + case .ranking: "ranking" + case .setting: "setting" } } var iconNameSelected: String { switch self { - case .home: - "homeSelected" - case .record: - "calendarSelected" - case .ranking: - "rankingSelected" - case .setting: - "settingSelected" + case .home: "homeSelected" + case .record: "calendarSelected" + case .ranking: "rankingSelected" + case .setting: "settingSelected" } } } struct MainTabView: View { - @State private var selectedTab: Tab = .home - + @State private var currentTab: Tab = .home + var body: some View { - ZStack(alignment: .bottom) { - Color.dark.ignoresSafeArea(.all) + TabView(selection: $currentTab, + content: { + HomeView() + .tag(Tab.home) - VStack(spacing: 0) { - Spacer() - switch selectedTab { - case .home: - HomeView() - case .record: - RecordView() - case .ranking: - RankingView() - case .setting: - SettingView() - } - Spacer() - } - .padding(.bottom, SafeAreaHelper.getTabBarHeight()) + RecordView() + .tag(Tab.record) - TabBarView(selectedTab: $selectedTab) + RankingView() + .tag(Tab.ranking) + + SettingView() + .tag(Tab.setting) + }) + .overlay(alignment: .bottom) { + TabBarView(currentTab: $currentTab) } - .edgesIgnoringSafeArea(.bottom) + .edgesIgnoringSafeArea(.bottom) } } struct TabBarView: View { - @Binding var selectedTab: Tab + @Binding var currentTab: Tab var body: some View { VStack(spacing: 0) { @@ -92,17 +76,17 @@ struct TabBarView: View { ForEach(Tab.allCases, id: \.hashValue) { tab in VStack(spacing: 5.adjustToScreenHeight) { - Image(tab == selectedTab ? tab.iconNameSelected : tab.iconName, bundle: nil) + Image(tab == currentTab ? tab.iconNameSelected : tab.iconName, bundle: nil) Text(tab.title) .font(.pretendard(size: 12, weight: .regular)) - .foregroundStyle(tab == selectedTab ? .gray100 : .gray300) + .foregroundStyle(tab == currentTab ? .gray100 : .gray300) .frame(height: 18.adjustToScreenHeight) } .frame(maxWidth: .infinity) .contentShape(Rectangle()) .onTapGesture { - selectedTab = tab + currentTab = tab } Spacer() @@ -122,3 +106,4 @@ struct TabBarView: View { #Preview { MainTabView() } + diff --git a/HongikYeolgong2/Util/Extensions/URLRequest+.swift b/HongikYeolgong2/Util/Extensions/URLRequest+.swift index f992fb4..9d92d79 100644 --- a/HongikYeolgong2/Util/Extensions/URLRequest+.swift +++ b/HongikYeolgong2/Util/Extensions/URLRequest+.swift @@ -11,7 +11,7 @@ import Foundation extension URLRequest { init(_ url: URL) { self.init(url: url) - let accessToken = KeyChainManager.readItem(key: .accessToken) ?? "" + let accessToken = KeyChainManager.readItem(key: .accessToken) ?? "" self.addValue("Bearer \(accessToken)", forHTTPHeaderField: "Authorization") } }