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

[PI-43] 1차 배포 준비: 약속관리화면 연결, Bundle Id 변경 #57

Open
wants to merge 7 commits into
base: main
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
5 changes: 3 additions & 2 deletions AppPackage/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let package = Package(
"TimeTableFeature",
"Share",
"MakePromise",
"PromiseManagement",
"ManagePromiseFeature",
"LoginFeature",
"SwiftUIHelper",
"Entity"
Expand Down Expand Up @@ -122,7 +122,7 @@ let package = Package(
]
),
.target(
name: "PromiseManagement",
name: "ManagePromiseFeature",
dependencies: [
"DesignSystem",
"CommonView",
Expand All @@ -145,6 +145,7 @@ let package = Package(
name: "HomeContainerFeature",
dependencies: [
"DesignSystem",
"ManagePromiseFeature",
"MakePromise",
"HomeFeature",
"CalendarFeature",
Expand Down
1 change: 0 additions & 1 deletion AppPackage/Sources/CommonView/EmptyDataView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public struct EmptyDataView: View {
)

Button("약속잡기") {
// TODO: - 약속잡기 화면 이동
viewStore.send(.makePromiseButtonTapped)
}
.buttonStyle(RoundCornerButtonStyle())
Expand Down
30 changes: 30 additions & 0 deletions AppPackage/Sources/HomeContainerFeature/HomeContainerCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ComposableArchitecture
import Foundation
import HomeFeature
import MakePromise
import ManagePromiseFeature
import SharedModel

public enum Tab: CaseIterable, Equatable {
Expand All @@ -19,22 +20,27 @@ public struct HomeContainerCore: ReducerProtocol {
public struct State: Equatable {
var selectedTab: Tab
var homeState: HomeCore.State
var managePromiseState: ManagePromiseCore.State

@PresentationState var destinationState: DestinationState?

public init(
selectedTab: Tab = .home,
homeState: HomeCore.State = .init(),
managePromiseState: ManagePromiseCore.State = .init(),
destinationState: DestinationState? = nil
) {
self.selectedTab = selectedTab
self.homeState = homeState
self.managePromiseState = managePromiseState
self.destinationState = destinationState
}
}

public enum Action: Equatable {
case selectedTabChanged(tab: Tab)
case home(action: HomeCore.Action)
case manage(action: ManagePromiseCore.Action)
case destination(PresentationAction<DestinationAction>)
}

Expand All @@ -57,6 +63,12 @@ public struct HomeContainerCore: ReducerProtocol {
child: HomeCore.init
)

Scope(
state: \.managePromiseState,
action: /HomeContainerCore.Action.manage,
child: ManagePromiseCore.init
)

Reduce<State, Action> { state, action in
switch action {
case let .selectedTabChanged(tab: tab):
Expand Down Expand Up @@ -129,6 +141,24 @@ public struct HomeContainerCore: ReducerProtocol {

case .destination, .home:
return .none

case let .manage(.delegate(action)):
switch action {
case .makePromise:
state.destinationState = .makePromise(.init())
return .none

case let .standbyDetail(state):
// TODO: 상세화면 띄우기
return .none

case let .confirmedDetail(state):
// TODO: 상세화면 띄우기
return .none
}

case .manage:
return .none
}
}
.ifLet(\.$destinationState, action: /Action.destination) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import DesignSystem
import Entity
import HomeFeature
import MakePromise
import ManagePromiseFeature
import SharedModel
import SwiftUI
import SwiftUIHelper
Expand Down Expand Up @@ -101,7 +102,12 @@ public struct HomeContainerView: View {
Color.clear

case .promiseManagement:
Text("Promise")
ManagePromiseView(
store: store.scope(
state: \.managePromiseState,
action: HomeContainerCore.Action.manage
)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public struct ConfirmedListFeature: ReducerProtocol {

public enum Delegate: Equatable {
case showDetailView(ConfirmedCell.State)
case showMakePromise
}
}

Expand All @@ -42,10 +43,10 @@ public struct ConfirmedListFeature: ReducerProtocol {
}
return .send(.delegate(.showDetailView(selectedData)))

case .delegate:
return .none

case .emptyData(.delegate(.makePromise)):
return .send(.delegate(.showMakePromise))

case .delegate:
return .none

default:
Expand All @@ -67,10 +68,11 @@ struct ConfirmedListView: View {
WithViewStore(store, observe: { $0 }) { viewStore in

if viewStore.rows.isEmpty {
EmptyDataView(store: self.store.scope(
state: \.emptyData,
action: ConfirmedListFeature.Action.emptyData
)
EmptyDataView(
store: self.store.scope(
state: \.emptyData,
action: ConfirmedListFeature.Action.emptyData
)
)

} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
//
// ManagementView.swift
// Planz
// ManagePromiseCore.swift
//
// Created by Sujin Jin on 2023/02/25.
// Copyright © 2023 Team-Planz. All rights reserved.
//
// Created by Sujin Jin on 2023/04/16.
//

import APIClient
import APIClientLive
import CommonView
import ComposableArchitecture
import DesignSystem
import Entity
import Foundation
import SharedModel
import SwiftUI

public struct PromiseManagement: ReducerProtocol {
public struct ManagePromiseCore: ReducerProtocol {
public init() {}

@Dependency(\.apiClient) var apiClient
Expand All @@ -24,16 +21,13 @@ public struct PromiseManagement: ReducerProtocol {
@BindingState var visibleTab: Tab = .standby
var confirmedTab = ConfirmedListFeature.State()
var standbyTab = StandbyListFeature.State()
@BindingState var detailItem: PromiseDetailViewState?

public init(
standbyRows: IdentifiedArrayOf<StandbyCell.State> = [],
confirmedRows: IdentifiedArrayOf<ConfirmedCell.State> = [],
detailItem: PromiseDetailViewState? = nil
confirmedRows: IdentifiedArrayOf<ConfirmedCell.State> = []
) {
standbyTab = StandbyListFeature.State(rows: standbyRows)
confirmedTab = ConfirmedListFeature.State(rows: confirmedRows)
self.detailItem = detailItem
}
}

Expand All @@ -42,16 +36,29 @@ public struct PromiseManagement: ReducerProtocol {
case onAppear
case standbyTab(StandbyListFeature.Action)
case confirmedTab(ConfirmedListFeature.Action)
case closeDetailButtonTapped
case standbyFetchAllResponse([StandbyCell.State])
case confirmedFetchAllResponse([ConfirmedCell.State])
case makePromiseButtonTapped
case delegate(Delegate)

public enum Delegate: Equatable {
case makePromise
case confirmedDetail(PromiseDetailViewState)
case standbyDetail(PromiseDetailViewState)
}
}

public var body: some ReducerProtocol<State, Action> {
BindingReducer()

Reduce { state, action in
switch action {
case .delegate:
return .none

case .makePromiseButtonTapped:
return .send(.delegate(.makePromise))

case let .standbyFetchAllResponse(result):
let rows = IdentifiedArrayOf(uniqueElements: result)
state.standbyTab = StandbyListFeature.State(rows: rows)
Expand All @@ -70,35 +77,36 @@ public struct PromiseManagement: ReducerProtocol {
case let .confirmedTab(.delegate(action)):
switch action {
case let .showDetailView(item):
state.detailItem = PromiseDetailViewState(

let detailState = PromiseDetailViewState(
id: UUID(uuidString: String(item.id)) ?? UUID(),
title: item.title,
theme: item.theme,

// MARK: - TODO must fix it

date: .now,
place: item.place,
participants: item.participants
)
return .none
return .send(.delegate(.confirmedDetail(detailState)))

case .showMakePromise:
return .send(.delegate(.makePromise))
}
case .closeDetailButtonTapped:
state.detailItem = nil
return .none

case let .standbyTab(.delegate(action)):
switch action {
case let .showDetailView(item):
state.detailItem = PromiseDetailViewState(
let detailState = PromiseDetailViewState(
id: UUID(uuidString: String(item.id)) ?? UUID(),
title: item.title,
theme: "테마",
date: .now,
place: "강남역",
participants: item.members
)
return .none
return .send(.delegate(.standbyDetail(detailState)))

case .showMakePromise:
return .send(.delegate(.makePromise))
}

default:
Expand Down Expand Up @@ -164,99 +172,3 @@ public struct PromiseManagement: ReducerProtocol {
} catch {}
}
}

public struct ManagementView: View {
private let store: StoreOf<PromiseManagement>

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

public var body: some View {
WithViewStore(self.store) { viewStore in
NavigationView {
GeometryReader { geo in
VStack {
HeaderTabView(
activeTab:
viewStore.binding(\.$visibleTab),
tabs: Tab.allCases,
fullWidth: geo.size.width - 40
)

TabView(selection:
viewStore.binding(\.$visibleTab)
) {
StandbyListView(store: self.store.scope(
state: \.standbyTab,
action: PromiseManagement.Action.standbyTab
)
)
.tag(Tab.standby)

ConfirmedListView(store: store.scope(
state: \.confirmedTab,
action: PromiseManagement.Action.confirmedTab
))
.tag(Tab.confirmed)
}
.animation(.default, value: viewStore.visibleTab.rawValue)
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height - 200)
.tabViewStyle(.page(indexDisplayMode: .never))
}
.navigationTitle("약속 관리")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
Button {
print("Add Item")
} label: {
PDS.Icon.plus.image
}
}
}
.onAppear { viewStore.send(.onAppear) }
.fullScreenCover(
unwrapping: viewStore.binding(\.$detailItem)
) { state in
NavigationStack {
PromiseDetailView(state: state.wrappedValue)
.toolbar {
ToolbarItem {
Button {
viewStore.send(.closeDetailButtonTapped)
} label: {
PDS.Icon.close.image
}
}
}
.navigationTitle("약속 상세보기")
.navigationBarTitleDisplayMode(.inline)
}
}
}
}
}
}
}

struct ManagementView_Previews: PreviewProvider {
static var previews: some View {
ManagementView(store: StoreOf<PromiseManagement>(
initialState: PromiseManagement.State(
standbyRows: .mock,
confirmedRows: .mock,
detailItem:
PromiseDetailViewState(
id: UUID(),
title: "약속명",
theme: "여행",
date: .now,
place: "강남",
participants: ["정인혜", "이은영"]
)
),
reducer: PromiseManagement()._printChanges()
))
}
}
Loading