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

[Feat/#91] View의 인터페이스 분리 #95

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
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 @@ -7,7 +7,6 @@

import SwiftUI

import Foundation
import ComposableArchitecture

import SharedDesignSystem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
//

import Foundation

import ComposableArchitecture

import SharedDesignSystem

public struct WorkoutEndStore: ReducerProtocol {
private let reducer: Reduce<State, Action>

Expand All @@ -16,6 +19,13 @@ public struct WorkoutEndStore: ReducerProtocol {
}

public struct State: Equatable {
public var workoutTime: Int = 10000
public var workoutCalorie: Int = 300
public var workoutToolCells: IdentifiedArrayOf<PumpingTextCellStore.State> = [
.init(id: .init(), title: "어깨"),
.init(id: .init(), title: "등")
]

public init() {

}
Expand All @@ -24,9 +34,14 @@ public struct WorkoutEndStore: ReducerProtocol {
public enum Action: BindableAction, Equatable {
case binding(BindingAction<State>)

case editButtonTapped
case completeButtonTapped

case pumpingTextCell(id: PumpingTextCellStore.State.ID, action: PumpingTextCellStore.Action)

//MARK: Navigation
case backToRoot
case goToWorkoutRecord
}

public var body: some ReducerProtocol<State, Action> {
Expand Down
121 changes: 0 additions & 121 deletions Projects/Feature/Workout/Interface/Sources/End/WorkoutEndView.swift

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// WorkoutEndViewInterface.swift
// FeatureWorkoutInterface
//
// Created by 송영모 on 2023/06/21.
//

import SwiftUI

import ComposableArchitecture

import SharedDesignSystem
import SharedUtil

public struct WorkoutEndView<Content: View>: View {
private let store: StoreOf<WorkoutEndStore>
public var content: () -> Content

public init(store: StoreOf<WorkoutEndStore>, @ViewBuilder content: @escaping () -> Content) {
self.store = store
self.content = content
}

public var body: some View {
content()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// WorkoutRecordStoreInterface.swift
// FeatureWorkoutInterface
//
// Created by 송영모 on 2023/06/18.
//

import SwiftUI

import ComposableArchitecture

import SharedDesignSystem
import DomainAuth

public struct WorkoutRecordStore: ReducerProtocol {
private let reducer: Reduce<State, Action>

public init(reducer: Reduce<State, Action>) {
self.reducer = reducer
}

public struct State: Equatable {
public init() {

}
}

public enum Action: BindableAction, Equatable {
case binding(BindingAction<State>)

case onAppear

case completeButtonTapped
}

public var body: some ReducerProtocol<State, Action> {
BindingReducer()
reducer
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//
// WorkoutRecordView.swift
// FeatureWorkoutInterface
//
// Created by 송영모 on 2023/06/18.
//

import SwiftUI

import ComposableArchitecture

import SharedDesignSystem

public struct WorkoutRecordView: View {
public let store: StoreOf<WorkoutRecordStore>

public init(store: StoreOf<WorkoutRecordStore>) {
self.store = store
}

public var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
VStack {
titleView()
.padding(.horizontal)

Spacer()

PumpingSubmitButton(title: "완료", completion: {
viewStore.send(.completeButtonTapped)
})
}
.navigationBarBackButtonHidden(true)
.onAppear {
viewStore.send(.onAppear)
}
}
}

@ViewBuilder
private func titleView() -> some View {
VStack(alignment: .leading, spacing: 12) {
Text("오늘 수행한 세트를 알려주세요.")
.font(.pretendard(size: 24, type: .bold))
.foregroundColor(PumpingColors.colorGrey900.swiftUIColor)

Text("운동 기구와 중량도 작성할 수 있어요.")
.font(.pretendard(size: 15, type: .medium))
.foregroundColor(.colorGrey600)

HStack {
Spacer()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import ComposableArchitecture

public enum WorkoutScene: Hashable {
case root
case selectWorkoutCategoryType
case workoutStart
case workoutTimer
case workoutEnd
case home
case start
case timer
case end
case record
}

public struct WorkoutRootStore: ReducerProtocol {
Expand All @@ -22,20 +23,23 @@ public struct WorkoutRootStore: ReducerProtocol {
private let workoutStartStore: WorkoutStartStore
private let workoutTimerStore: WorkoutTimerStore
private let workoutEndStore: WorkoutEndStore
private let workoutRecordStore: WorkoutRecordStore

public init(
reducer: Reduce<State, Action>,
workoutHomeStore: WorkoutHomeStore,
workoutStartStore: WorkoutStartStore,
workoutTimerStore: WorkoutTimerStore,
workoutEndStore: WorkoutEndStore
workoutEndStore: WorkoutEndStore,
workoutRecordStore: WorkoutRecordStore
) {
self.reducer = reducer

self.workoutHomeStore = workoutHomeStore
self.workoutStartStore = workoutStartStore
self.workoutTimerStore = workoutTimerStore
self.workoutEndStore = workoutEndStore
self.workoutRecordStore = workoutRecordStore
}

public struct State: Equatable {
Expand All @@ -45,6 +49,7 @@ public struct WorkoutRootStore: ReducerProtocol {
public var workoutStart: WorkoutStartStore.State?
public var workoutTimer: WorkoutTimerStore.State?
public var workoutEnd: WorkoutEndStore.State?
public var workoutRecord: WorkoutRecordStore.State?

public init() {

Expand All @@ -60,6 +65,7 @@ public struct WorkoutRootStore: ReducerProtocol {
case workoutStart(WorkoutStartStore.Action)
case workoutTimer(WorkoutTimerStore.Action)
case workoutEnd(WorkoutEndStore.Action)
case workoutRecord(WorkoutRecordStore.Action)
}

public var body: some ReducerProtocol<State, Action> {
Expand All @@ -77,5 +83,8 @@ public struct WorkoutRootStore: ReducerProtocol {
.ifLet(\.workoutEnd, action: /Action.workoutEnd) {
workoutEndStore
}
.ifLet(\.workoutRecord, action: /Action.workoutRecord) {
workoutRecordStore
}
}
}
Loading