Skip to content

Commit

Permalink
feat: date time 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
mooyoung2309 committed Sep 27, 2023
1 parent 8e4ceaf commit cab2130
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public struct CalendarStore: Reducer {
Reduce { state, action in
switch action {
case .onAppear:
if let id = state.selectedCalendarItemID {
return .send(.refreshTradeItem(state.calendarItem[id: id]?.trades ?? []))
}
return .none

case .newButtonTapped:
Expand All @@ -116,7 +119,7 @@ public struct CalendarStore: Reducer {
return .init(
trade: trade,
dateStyle: .short,
timeStyle: .none
timeStyle: .short
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,28 @@ public struct TradeItemCellView: View {

private func tradeView(viewStore: ViewStoreOf<TradeItemCellStore>) -> some View {
HStack(spacing: 10) {
Text(
viewStore.trade.date.localizedString(
dateStyle: viewStore.state.dateStyle,
timeStyle: viewStore.state.timeStyle
)
)
.font(.headline)
.fontWeight(.semibold)
VStack(alignment: .trailing) {
if viewStore.state.dateStyle != .none {
Text(
viewStore.trade.date.localizedString(
dateStyle: viewStore.state.dateStyle,
timeStyle: .none
)
)
.font(.headline)
.fontWeight(.semibold)
}

if viewStore.state.timeStyle != .none {
Text(
viewStore.trade.date.localizedString(
dateStyle: .none,
timeStyle: viewStore.state.timeStyle
)
)
.font(.caption2)
}
}

viewStore.state.trade.ticker?.type?.image
.font(.title3)
Expand All @@ -54,6 +68,14 @@ public struct TradeItemCellView: View {
.fontWeight(.semibold)

Spacer()

VStack(alignment: .trailing, spacing: 1) {
Text("\(Int(viewStore.state.trade.price ?? 0)) \(viewStore.state.trade.ticker?.currency?.rawValue ?? "")")
.font(.caption)

Text("\(Int(viewStore.state.trade.volume ?? 0)) vol")
.font(.caption)
}
}
.frame(height: 35)
.padding(10)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public struct TradeDetailStore: Reducer {
case .onAppear:
state.tradeItem = .init(
uniqueElements: state.trade.ticker?.trades?.compactMap { trade in
return .init(trade: trade, dateStyle: .short, timeStyle: .none)
return .init(trade: trade, dateStyle: .short, timeStyle: .short)
} ?? []
)
return .none
Expand Down

0 comments on commit cab2130

Please sign in to comment.