Skip to content

Commit

Permalink
Merge pull request #53 from TeamHY2/Fix/#50-Login
Browse files Browse the repository at this point in the history
[Fix] 회원가입 -> 메인화면 진입시 크래쉬오류 수정
  • Loading branch information
Seokki-Kwon authored Oct 29, 2024
2 parents 8b411ac + 7c1a6e0 commit 0df5f6d
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions HongikYeolgong2/Presentation/Auth/OnboardingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct OnboardingView: View {
content
.onReceive(routingUpdate) { self.routingState = $0 }
}
.navigationViewStyle(.stack)
}

// MARK: - Main Contents
Expand Down
7 changes: 6 additions & 1 deletion HongikYeolgong2/Presentation/Auth/SignUpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)} )
Expand Down
8 changes: 5 additions & 3 deletions HongikYeolgong2/Presentation/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}
Expand Down
29 changes: 13 additions & 16 deletions HongikYeolgong2/Presentation/Root/InitialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
83 changes: 34 additions & 49 deletions HongikYeolgong2/Presentation/Root/MainTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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()
Expand All @@ -122,3 +106,4 @@ struct TabBarView: View {
#Preview {
MainTabView()
}

2 changes: 1 addition & 1 deletion HongikYeolgong2/Util/Extensions/URLRequest+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit 0df5f6d

Please sign in to comment.