diff --git a/Score/Score/Reducer/MyPage/MyPageMainFeature.swift b/Score/Score/Reducer/MyPage/MyPageMainFeature.swift new file mode 100644 index 0000000..1061b17 --- /dev/null +++ b/Score/Score/Reducer/MyPage/MyPageMainFeature.swift @@ -0,0 +1,135 @@ +// +// MyPageMainFeature.swift +// Score +// +// Created by sole on 4/24/24. +// + +import ComposableArchitecture + +//MARK: - MyPageMainFeature + +@Reducer +struct MyPageMainFeature { + @Dependency(\.dismiss) var dismiss + typealias Tab = MyPageLineTab + + //MARK: - MyPageLineTab + + enum MyPageLineTab: SCLineTabProtocol { + case feed + case calendar + } + + //MARK: - State + + struct State: Equatable { + @PresentationState var destination: Destination.State? + + var lineTabBar: SCLineTabBarFeature.State = .init( + tabItems: [.init(title: "피드", tab: .feed), + .init(title: "캘린더", tab: .calendar)], + selectedTab: .feed) + + var calendar: CalendarFeature.State = .init() + var feed: FeedMainFeature.State = .init() + } + + //MARK: - State + + enum Action { + case viewApearing + case tasking + + case dismissButtonTapped + case settingButtonTapped + case profileEditButtonTapped + case myFriendButtonTapped + + case destination(PresentationAction) + case lineTabBar(SCLineTabBarFeature.Action) + case calendar(CalendarFeature.Action) + case feed(FeedMainFeature.Action) + } + + var body: some ReducerOf { + Reduce { state, action in + switch action { + case .viewApearing: + return .none + + case .tasking: + return .none + + case .dismissButtonTapped: + return .run { send in + await self.dismiss() + } + + case .settingButtonTapped: + state.destination = .setting(.init()) + return .none + + case .profileEditButtonTapped: + state.destination = .profileEdit(.init()) + return .none + + case .myFriendButtonTapped: + return .none + + case .destination, + .lineTabBar, + .calendar, + .feed: + return .none + } + } + .ifLet(\.$destination, + action: \.destination) { + Destination() + } + + Scope(state: \.lineTabBar, + action: \.lineTabBar) { + SCLineTabBarFeature() + } + + Scope(state: \.calendar, + action: \.calendar) { + CalendarFeature() + } + + Scope(state: \.feed, + action: \.feed) { + FeedMainFeature() + } + } + + //MARK: - Destination + + @Reducer + struct Destination { + enum State: Equatable { + case setting(SettingMainFeature.State) + case profileEdit(ProfileEditFeature.State) + } + + enum Action { + case setting(SettingMainFeature.Action) + case profileEdit(ProfileEditFeature.Action) + } + + var body: some ReducerOf { + Scope(state: \.setting, + action: \.setting) { + SettingMainFeature() + } + + Scope(state: \.profileEdit, + action: \.profileEdit) { + ProfileEditFeature() + } + + } + } +}