Skip to content

Commit

Permalink
#26 [Feat] MyPageMainFeature 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
soletree committed May 16, 2024
1 parent 3f31640 commit 30d0319
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions Score/Score/Reducer/MyPage/MyPageMainFeature.swift
Original file line number Diff line number Diff line change
@@ -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<Tab>.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<Destination.Action>)
case lineTabBar(SCLineTabBarFeature<Tab>.Action)
case calendar(CalendarFeature.Action)
case feed(FeedMainFeature.Action)
}

var body: some ReducerOf<Self> {
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<Self> {
Scope(state: \.setting,
action: \.setting) {
SettingMainFeature()
}

Scope(state: \.profileEdit,
action: \.profileEdit) {
ProfileEditFeature()
}

}
}
}

0 comments on commit 30d0319

Please sign in to comment.