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

[SCRUM-110] 2차 MVP 버그 수정 #68

Merged
merged 4 commits into from
Dec 31, 2024
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
49 changes: 23 additions & 26 deletions Projects/Feature/Feature/Sources/AppView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,36 @@ import ComposableArchitecture

public struct AppView: View {
@Bindable var store: StoreOf<AppCore>

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

public var body: some View {
Group {
if let splashStore = store.scope(state: \.splash, action: \.splash) {
SplashView(store: splashStore)
.zIndex(0)
} else if let onboardingStore = store.scope(state: \.onboarding, action: \.onboarding) {
NavigationStack {
OnboardingView(store: onboardingStore)
.zIndex(1)
}
} else if let homeStore = store.scope(state: \.home, action: \.home) {
NavigationStack {
HomeView(store: homeStore)
.zIndex(2)
ZStack {
Group {
if let splashStore = store.scope(state: \.splash, action: \.splash) {
SplashView(store: splashStore)
.zIndex(0)
} else if let onboardingStore = store.scope(state: \.onboarding, action: \.onboarding) {
NavigationStack {
OnboardingView(store: onboardingStore)
.zIndex(1)
}
} else if let homeStore = store.scope(state: \.home, action: \.home) {
NavigationStack {
HomeView(store: homeStore)
.transition(.opacity.animation(.easeInOut))
.zIndex(2)
}
} else {
Global.Color.black // MARK: - DB정보 없고 오프라인일때 Dialog 띄우기
.zIndex(3)
devMinseok marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
Global.Color.black // MARK: - DB정보 없고 오프라인일때 Dialog 띄우기
.zIndex(3)
}
}
.transition(.opacity)
.animation(.easeInOut, value: store.home == nil)
.fullScreenCover(isPresented: $store.isLoading) {
LoadingView()
if store.isLoading {
LoadingView()
}
}
.fullScreenCover(
item: $store.scope(
Expand All @@ -64,10 +65,6 @@ public struct AppView: View {
) { store in
NetworkErrorView(store: store)
}
.transaction(value: store.isLoading) { transaction in
// TODO: 11.25 로딩 이외 다른 fullScreen들도 disabled됨
transaction.disablesAnimations = true
}
.onLoad {
store.send(.onLoad)
}
Expand Down
53 changes: 24 additions & 29 deletions Projects/Feature/HomeFeature/Sources/Home/HomeCore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ public struct HomeCore {

var selectedCategory: PomodoroCategory?
var selectedCat: SomeCat?

var isNetworkConnected: Bool = false

var isNetworkConnected: Bool = true
var toast: DefaultToast?
var dialog: DefaultDialog?

var catRiv: RiveViewModel = Rive.catHomeRiv(stateMachineName: "State Machine_Home")

@Presents var categorySelect: CategorySelectCore.State?
@Presents var timeSelect: TimeSelectCore.State?
@Presents var focusPomodoro: FocusPomodoroCore.State?
@Presents var myPage: MyPageCore.State?

@Presents var pomodoro: PomodoroCore.State?

public init() {}
}

Expand All @@ -68,8 +68,8 @@ public struct HomeCore {
case syncCategory
case categorySelect(PresentationAction<CategorySelectCore.Action>)
case timeSelect(PresentationAction<TimeSelectCore.Action>)
case focusPomodoro(PresentationAction<FocusPomodoroCore.Action>)
case myPage(PresentationAction<MyPageCore.Action>)
case pomodoro(PresentationAction<PomodoroCore.Action>)
}

@Dependency(UserDefaultsClient.self) var userDefaultsClient
Expand All @@ -91,26 +91,26 @@ public struct HomeCore {
.ifLet(\.$timeSelect, action: \.timeSelect) {
TimeSelectCore()
}
.ifLet(\.$focusPomodoro, action: \.focusPomodoro) {
FocusPomodoroCore()
}
.ifLet(\.$myPage, action: \.myPage) {
MyPageCore()
}
.ifLet(\.$pomodoro, action: \.pomodoro) {
PomodoroCore()
}
}

private func core(_ state: inout State, _ action: Action) -> EffectOf<Self> {
switch action {
case .binding:
return .none

case .task:
return .run { send in
for await isConnected in networkTracking.updateNetworkConnected() {
await send(._fetchNetworkConnection(isConnected))
}
}

case .onLoad:
return .run { send in
if self.userDefaultsClient.boolForKey(isHomeGuideCompletedKey) == false {
Expand Down Expand Up @@ -162,7 +162,7 @@ public struct HomeCore {
return .none

case .playButtonTapped:
state.focusPomodoro = .init()
state.pomodoro = .init()
return .none

case .catTapped:
Expand All @@ -177,11 +177,11 @@ public struct HomeCore {
state.catRiv.reset()
state.catRiv.setInput(selectedCat.rivInputName, value: true)
return .none

case let ._fetchNetworkConnection(isConnected):
state.isNetworkConnected = isConnected
return .none

case .syncCategory:
return .run { send in
try await self.pomodoroService.syncCategoryList(
Expand Down Expand Up @@ -221,7 +221,9 @@ public struct HomeCore {
return .none

case .timeSelect(.presented(.bottomCheckButtonTapped)):
guard let mode = state.timeSelect?.mode else { return .none }
guard let mode = state.timeSelect?.mode,
state.timeSelect?.isTimeChanged == true
else { return .none }
var message: String
switch mode {
case .focus:
Expand All @@ -246,9 +248,9 @@ public struct HomeCore {
case .myPage:
return .none

case let .focusPomodoro(.presented(.saveHistory(focusTimeBySeconds, restTimeBySeconds))), // FocusPomodoro
let .focusPomodoro(.presented(.restWaiting(.presented(.saveHistory(focusTimeBySeconds, restTimeBySeconds))))), // RestWaiting
let .focusPomodoro(.presented(.restWaiting(.presented(.restPomodoro(.presented(.saveHistory(focusTimeBySeconds, restTimeBySeconds))))))): // RestPomodoro
case let .pomodoro(.presented(.focusPomodoro(.saveHistory(focusTimeBySeconds, restTimeBySeconds)))), // FocusPomodoro
let .pomodoro(.presented(.restWaiting(.saveHistory(focusTimeBySeconds, restTimeBySeconds)))), // RestWaiting
let .pomodoro(.presented(.restPomodoro(.saveHistory(focusTimeBySeconds, restTimeBySeconds)))): // RestPomodoro
guard let selectedCategoryID = state.selectedCategory?.id else { return .none }
if focusTimeBySeconds >= 60 {
return .run { _ in
Expand All @@ -266,18 +268,11 @@ public struct HomeCore {
return .none
}

case .focusPomodoro(.presented(.restWaiting(.presented(.goToHomeByOver60Minute)))):
state.focusPomodoro = nil
case .pomodoro(.presented(.restWaiting(.goToHomeByOver60Minute))):
state.dialog = focusEndDialog()
return .none

case .focusPomodoro(.presented(.goToHome)),
.focusPomodoro(.presented(.restWaiting(.presented(.goToHome)))),
.focusPomodoro(.presented(.restWaiting(.presented(.restPomodoro(.presented(.goToHome)))))):
state.focusPomodoro = nil
return .none

case .focusPomodoro:
case .pomodoro:
return .none
}
}
Expand Down
6 changes: 3 additions & 3 deletions Projects/Feature/HomeFeature/Sources/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ public struct HomeView: View {
}
.navigationDestination(
item: $store.scope(
state: \.focusPomodoro,
action: \.focusPomodoro
state: \.pomodoro,
action: \.pomodoro
)
) { store in
FocusPomodoroView(store: store)
PomodoroView(store: store)
}
.navigationDestination(
item: $store.scope(
Expand Down
29 changes: 29 additions & 0 deletions Projects/Feature/HomeFeature/Sources/TimeSelect/TimeItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// TimeItem.swift
// HomeFeature
//
// Created by devMinseok on 12/30/24.
// Copyright © 2024 PomoNyang. All rights reserved.
//

import Foundation

public struct TimeItem: WheelPickerData {
let minute: Int

init(minute: Int) {
self.minute = minute
}

public var id: Int {
return minute
}

var title: String {
return String(format: "%02d:00", minute)
}

var data: Int {
return minute
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ public struct TimeSelectCore {
public init(mode: Mode) {
self.mode = mode
}

var isTimeChanged: Bool {
switch mode {
case .focus:
return selectedCategory?.focusTimeMinutes != selectedTime?.minute
case .rest:
return selectedCategory?.restTimeMinutes != selectedTime?.minute
}
}
}

public enum Action {
Expand Down Expand Up @@ -93,12 +102,13 @@ public struct TimeSelectCore {
return .none

case .bottomCheckButtonTapped:
return .run { [
mode = state.mode,
selectedTime = state.selectedTime,
selectedCategory = state.selectedCategory
] send in
if let selectedCategoryID = selectedCategory?.id,
let mode = state.mode
let selectedCategory = state.selectedCategory
let selectedTime = state.selectedTime
let isTimeChanged = state.isTimeChanged
return .run { send in
if isTimeChanged,
let selectedCategoryID = selectedCategory?.id,
let selectedTime = selectedTime?.minute {
let selectedTimeDuration = DateComponents(minute: selectedTime).to8601DurationString()
var request: EditCategoryRequest
Expand All @@ -110,7 +120,8 @@ public struct TimeSelectCore {
request = EditCategoryRequest(focusTime: nil, restTime: selectedTimeDuration)
}

try await self.pomodoroService.changeCategoryTime(
// TODO: - 오프라인 대응 필요
try? await self.pomodoroService.changeCategoryTime(
devMinseok marked this conversation as resolved.
Show resolved Hide resolved
apiClient: self.apiClient,
categoryID: selectedCategoryID,
request: request
Expand Down Expand Up @@ -140,23 +151,3 @@ public struct TimeSelectCore {
return result.reversed()
}
}

public struct TimeItem: WheelPickerData {
let minute: Int

init(minute: Int) {
self.minute = minute
}

public var id: Int {
return minute
}

var title: String {
return String(format: "%02d:00", minute)
}

var data: Int {
return minute
}
}
Loading
Loading