Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
devMinseok committed Aug 15, 2024
1 parent 91caf33 commit c5a06e3
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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() }
)
)
}
2 changes: 1 addition & 1 deletion Projects/Feature/HomeFeature/Sources/Home/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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#>
Expand All @@ -30,7 +36,32 @@ public struct TimeSelectCore {
private func core(state: inout State, action: Action) -> EffectOf<Self> {
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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
}

0 comments on commit c5a06e3

Please sign in to comment.