Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TNT-221] 트레이너 화면 흐름 로직 작성 #67

Merged
merged 7 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ extension SNSLoginManager: ASAuthorizationControllerDelegate, ASWebAuthenticatio

guard let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential else {
self.appleLoginCompletion?(nil)
self.appleLoginCompletion = nil
return
}

Expand All @@ -92,6 +93,7 @@ extension SNSLoginManager: ASAuthorizationControllerDelegate, ASWebAuthenticatio
let authorizationCodeString = String(data: authorizationCode, encoding: .utf8)
else {
self.appleLoginCompletion?(nil)
self.appleLoginCompletion = nil
return
}

Expand All @@ -101,12 +103,14 @@ extension SNSLoginManager: ASAuthorizationControllerDelegate, ASWebAuthenticatio
authorizationCode: authorizationCodeString
)
)
self.appleLoginCompletion = nil
}

// 애플 로그인 실패 시 nil 리턴
public func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
print("Apple login failed: \(error.localizedDescription)")
self.appleLoginCompletion?(nil)
self.appleLoginCompletion = nil
}

public func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,10 @@ public struct AppFlowCoordinatorFeature {
switch action {
case .subFeature(let internalAction):
switch internalAction {
case .onboardingFlow(.switchFlow(let flow)), .traineeMainFlow(.switchFlow(let flow)):
case .onboardingFlow(.switchFlow(let flow)),
.traineeMainFlow(.switchFlow(let flow)),
.trainerMainFlow(.switchFlow(let flow)):
return self.setFlow(flow, state: &state)

case .trainerMainFlow:
return .none

default:
return .none
}
Expand Down Expand Up @@ -128,7 +126,7 @@ public struct AppFlowCoordinatorFeature {
return .send(.checkSessionInfo)
}
}
.ifLet(\.onboardingState, action: \.subFeature.onboardingFlow) { OnboardingFlowFeature()._printChanges() }
.ifLet(\.onboardingState, action: \.subFeature.onboardingFlow) { OnboardingFlowFeature() }
.ifLet(\.trainerMainState, action: \.subFeature.trainerMainFlow) { TrainerMainFlowFeature() }
.ifLet(\.traineeMainState, action: \.subFeature.traineeMainFlow) { TraineeMainFlowFeature() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public struct TrainerMainFlowFeature {
public enum Action: Sendable {
/// 현재 표시되고 있는 path 화면 내부에서 일어나는 액션을 처리합니다.
case path(StackActionOf<Path>)
/// Flow 변경을 AppCoordinator로 전달합니다
case switchFlow(AppFlow)
case onAppear
}

Expand All @@ -38,57 +40,36 @@ public struct TrainerMainFlowFeature {
/// 트레이니 탭뷰의 네비 관련 액션 처리
case .element(_, action: .mainTab(.setNavigating(let screen))):
switch screen {
/// 트레이니
case .traineeHome(let screen):
/// 트레이너
case .trainerHome(let screen):
switch screen {
/// 홈 화면 알림 버튼 탭 -> 알림 화면 이동
case .alarmPage:
state.path.append(.alarmCheck(.init(userType: .trainee)))
state.path.append(.alarmCheck(.init(userType: .trainer)))
return .none
case .sessionRecordPage:
return .none
case .recordFeedbackPage:
return .none
case .addWorkoutRecordPage:
return .none
case .addMealRecordPage:
case .addPTSessionPage:
state.path.append(.addPTSession(.init()))
return .none
}
/// 트레이니 마이페이지
case .traineeMyPage(let screen):

/// 트레이너 회원목록
case .trainerTraineeList:
return .none

/// 트레이너 마이페이지
case .trainerMyPage(let screen):
switch screen {
case .traineeInfoEdit:
return .none

/// 마이페이지 초대코드 입력하기 버튼 탭-> 초대코드 입력 화면 이동
case .traineeInvitationCodeInput:
state.path.append(.traineeInvitationCodeInput(.init()))
return .none

case .onboardingLogin:
return .none
return .send(.switchFlow(.onboardingFlow))
}
}

/// 알림 목록 특정 알림 탭 -> 해당 알림 내용 화면 이동
case .element(_, action: .alarmCheck(.setNavigating)):
// 특정 화면 append
return .none

/// 마이페이지 초대코드 입력화면 다음 버튼 탭 - > PT 정보 입력 화면 이동
case .element(_, action: .traineeInvitationCodeInput(.setNavigating)):
state.path.append(.traineeTrainingInfoInput(.init()))
return .none

/// PT 정보 입력 화면 다음 버튼 탭 -> 연결 완료 화면 이동
case .element(_, action: .traineeTrainingInfoInput(.setNavigating)):
state.path.append(.traineeConnectionComplete(.init(userType: .trainee, traineeName: "여기에", trainerName: "데이터 연결")))
return .none

default:
return .none
}

case .switchFlow:
return .none

case .onAppear:
return .none
}
Expand All @@ -103,19 +84,14 @@ extension TrainerMainFlowFeature {
public enum Path {
// MARK: MainTab
/// 트레이니 메인탭 - 홈/마이페이지
case mainTab(TraineeMainTabFeature)
case mainTab(TrainerMainTabFeature)

// MARK: Home
/// 알림 목록
case alarmCheck(AlarmCheckFeature)
/// PT 일정 추가
case addPTSession(TrainerAddPTSessionFeature)

// MARK: MyPage
/// 트레이니 초대 코드입력
case traineeInvitationCodeInput(TraineeInvitationCodeInputFeature)
/// 트레이니 수업 정보 입력
case traineeTrainingInfoInput(TraineeTrainingInfoInputFeature)
/// 트레이니-트레이너 연결 완료
/// TODO: 트레이너/트레이니 연결 완료 화면으로 통합 필요
case traineeConnectionComplete(TraineeConnectionCompleteFeature)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,15 @@ public struct TrainerMainFlowView: View {
switch store.case {
// MARK: MainTab
case .mainTab(let store):
TraineeMainTabView(store: store)
TrainerMainTabView(store: store)
case .addPTSession(let store):
TrainerAddPTSessionView(store: store)

// MARK: Home
case .alarmCheck(let store):
AlarmCheckView(store: store)

// MARK: MyPage
case .traineeInvitationCodeInput(let store):
TraineeInvitationCodeInputView(store: store)
case .traineeTrainingInfoInput(let store):
TraineeTrainingInfoInputView(store: store)
case .traineeConnectionComplete(let store):
TraineeConnectionCompleteView(store: store)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ public struct TrainerHomeFeature {
var view_recordTitleString: String {
return TDateFormatUtility.formatter(for: .M월_d일_EEEE).string(from: selectedDate)
}
/// 선택 바텀 시트 표시
var view_isBottomSheetPresented: Bool
/// 팝업 표시
// TODO: 3일 동안 보지 않기 로직 작성 때 추가
var view_isPopUpPresented: Bool

public init(
selectedDate: Date = .now,
Expand All @@ -53,17 +54,17 @@ public struct TrainerHomeFeature {
sessionInfo: WorkoutListItemEntity? = nil,
records: [RecordListItemEntity] = [],
view_currentPage: Date = .now,
view_isBottomSheetPresented: Bool = false,
tappedsessionInfo: GetDateSessionListEntity? = nil
tappedsessionInfo: GetDateSessionListEntity? = nil,
view_isPopUpPresented: Bool = false
) {
self.selectedDate = selectedDate
self.events = events
self.sessionCount = sessionCount
self.sessionInfo = sessionInfo
self.records = records
self.view_currentPage = view_currentPage
self.view_isBottomSheetPresented = view_isBottomSheetPresented
self.tappedsessionInfo = tappedsessionInfo
self.view_isPopUpPresented = view_isPopUpPresented
}
}

Expand All @@ -73,7 +74,7 @@ public struct TrainerHomeFeature {
/// 뷰에서 발생한 액션을 처리합니다.
case view(View)
/// 네비게이션 여부 설정
case setNavigating
case setNavigating(RoutingScreen)

@CasePathable
public enum View: Sendable, BindableAction {
Expand All @@ -83,8 +84,8 @@ public struct TrainerHomeFeature {
case tapAlarmPageButton
/// 수업 완료 버튼 탭
case tapSessionCompleted(id: String)
/// 식단 기록 추가 버튼 탭
case tapAddSessionRecordButton
/// 수업 추가 버튼 탭
case tapAddSessionButton
}
}

Expand All @@ -104,21 +105,26 @@ public struct TrainerHomeFeature {
case .binding:
return .none
case .tapAlarmPageButton:
// TODO: 네비게이션 연결 시 추가
print("tapAlarmPageButton")
return .none
return .send(.setNavigating(.alarmPage))
case .tapSessionCompleted(let id):
// TODO: 네비게이션 연결 시 추가
print("tapSessionCompleted otLessionID \(id)")
return .none
case .tapAddSessionRecordButton:
// TODO: 네비게이션 연결 시 추가
print("tapAddSessionRecordButton")
return .none
case .tapAddSessionButton:
return .send(.setNavigating(.addPTSessionPage))
}
case .setNavigating:
return .none
}
}
}
}

extension TrainerHomeFeature {
public enum RoutingScreen: Sendable {
/// 알림 페이지
case alarmPage
/// PT 일정 추가페이지
case addPTSessionPage
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,16 @@ public struct TrainerHomeView: View {
}
.background(Color.neutral100)
}
.background(
VStack {
Color.common0
Color.neutral100
}
)
.overlay(alignment: .bottomTrailing) {
SessionAddButton()
}
.navigationBarBackButtonHidden()
}

// MARK: - Sections
Expand Down Expand Up @@ -126,7 +133,7 @@ public struct TrainerHomeView: View {
}
}
.onTapGesture {
send(.tapAddSessionRecordButton)
send(.tapAddSessionButton)
}
.padding(.trailing, 22)
.padding(.bottom, 28)
Expand Down
10 changes: 5 additions & 5 deletions TnT/Projects/Presentation/Sources/MainTab/TabBar/TabInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ import DesignSystem

public enum TrainerTabInfo: String, CaseIterable, Equatable, Sendable {
case home = "홈"
case feedback = "피드백"
// case feedback = "피드백"
case traineeList = "회원목록"
case mypage = "내 정보"

public var filledIcn: ImageResource {
switch self {
case .home:
return .icnHomeFilled
case .feedback:
return .icnFeedbackFilled
// case .feedback:
// return .icnFeedbackFilled
case .traineeList:
return .icnListFilled
case .mypage:
Expand All @@ -32,8 +32,8 @@ public enum TrainerTabInfo: String, CaseIterable, Equatable, Sendable {
switch self {
case .home:
return .icnHomeEmpty
case .feedback:
return .icnFeedbackEmpty
// case .feedback:
// return .icnFeedbackEmpty
case .traineeList:
return .icnListEmpty
case .mypage:
Expand Down
Loading