diff --git a/Projects/Feature/HomeFeature/Example/Sources/TimeWheelPickerDetailView.swift b/Projects/Feature/HomeFeature/Example/Sources/TimeWheelPickerDetailView.swift new file mode 100644 index 0000000..a799663 --- /dev/null +++ b/Projects/Feature/HomeFeature/Example/Sources/TimeWheelPickerDetailView.swift @@ -0,0 +1,20 @@ +// +// TimeWheelPickerDetailView.swift +// DesignSystemExample +// +// Created by devMinseok on 8/13/24. +// Copyright © 2024 PomoNyang. All rights reserved. +// + +import SwiftUI + +import HomeFeature + +#Preview { + TimeSelectView( + store: .init( + initialState: .init(), + reducer: { TimeSelectCore() } + ) + ) +} diff --git a/Projects/Feature/HomeFeature/Sources/Home/HomeView.swift b/Projects/Feature/HomeFeature/Sources/Home/HomeView.swift index f22d91d..af01c94 100644 --- a/Projects/Feature/HomeFeature/Sources/Home/HomeView.swift +++ b/Projects/Feature/HomeFeature/Sources/Home/HomeView.swift @@ -101,8 +101,8 @@ public struct HomeView: View { .buttonStyle(.round(level: .primary)) } } + .background(Global.Color.gray50) } - .background(Global.Color.gray50) .tooltipDestination(tooltip: $store.homeCatTooltip.sending(\.setHomeCatTooltip)) .tooltipDestination(tooltip: $store.homeCategoryGuideTooltip.sending(\.setHomeCategoryGuideTooltip)) .tooltipDestination(tooltip: $store.homeTimeGuideTooltip.sending(\.setHomeTimeGuideTooltip)) diff --git a/Projects/Feature/HomeFeature/Sources/TimeSelect/TimeSelectCore.swift b/Projects/Feature/HomeFeature/Sources/TimeSelect/TimeSelectCore.swift index 370b7c3..7e0e8d7 100644 --- a/Projects/Feature/HomeFeature/Sources/TimeSelect/TimeSelectCore.swift +++ b/Projects/Feature/HomeFeature/Sources/TimeSelect/TimeSelectCore.swift @@ -6,17 +6,23 @@ // Copyright © 2024 PomoNyang. All rights reserved. // +import Foundation + import ComposableArchitecture @Reducer public struct TimeSelectCore { @ObservableState public struct State: Equatable { + var timeList: [TimeItem] = [] + var selectedTime: TimeItem? + public init() {} } public enum Action { case onAppear + case pickerSelection(TimeItem?) } // <#@Dependency() var#> @@ -30,7 +36,32 @@ public struct TimeSelectCore { private func core(state: inout State, action: Action) -> EffectOf { switch action { case .onAppear: + state.timeList = generateFocusTimeByMinute().map { .init(title: "\($0):00", data: $0) } + state.selectedTime = state.timeList.last + return .none + + case let .pickerSelection(selection): + state.selectedTime = selection + print(selection?.title) return .none } } + + /// 집중시간 리스트 생성 (분) + private func generateFocusTimeByMinute() -> [Int] { + var result: [Int] = [] + for i in stride(from: 10, through: 60, by: 5) { + result.append(i) + } + return result.reversed() + } + + /// 휴식시간 리스트 생성 (분) + private func generateRelaxTimeByMinute() -> [Int] { + var result: [Int] = [] + for i in stride(from: 5, through: 30, by: 5) { + result.append(i) + } + return result.reversed() + } } diff --git a/Projects/Feature/HomeFeature/Sources/TimeSelect/TimeSelectView.swift b/Projects/Feature/HomeFeature/Sources/TimeSelect/TimeSelectView.swift index 287c982..553db5d 100644 --- a/Projects/Feature/HomeFeature/Sources/TimeSelect/TimeSelectView.swift +++ b/Projects/Feature/HomeFeature/Sources/TimeSelect/TimeSelectView.swift @@ -31,7 +31,11 @@ public struct TimeSelectView: View { ) .buttonStyle(.text(level: .primary, size: .medium)) - Spacer() + WheelPicker( + image: DesignSystemAsset.Image._24Focus.swiftUIImage, + sources: store.timeList, + selection: $store.selectedTime.sending(\.pickerSelection) + ) Button( icon: DesignSystemAsset.Image._32PlayPrimary.swiftUIImage, @@ -43,5 +47,24 @@ public struct TimeSelectView: View { .padding(.vertical, 40) } } + .background(Global.Color.gray50) + .onAppear { + store.send(.onAppear) + } + } +} + + +public struct TimeItem: WheelPickerData { + public let id: UUID = .init() + let title: String + let data: Int + + init( + title: String, + data: Int + ) { + self.title = title + self.data = data } }