Skip to content

Commit

Permalink
Merge pull request #21 from folio-world/feat/#19-calendar-feature
Browse files Browse the repository at this point in the history
[Feat/#19] Calendar 기능 상세 구현
  • Loading branch information
mooyoung2309 authored Sep 25, 2023
2 parents c044bce + a39536b commit f09896d
Show file tree
Hide file tree
Showing 20 changed files with 685 additions and 275 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"colors" : [
{
"color" : {
"platform" : "universal",
"reference" : "labelColor"
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFE"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFE"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0xFF",
"green" : "0xFF",
"red" : "0xFE"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
14 changes: 14 additions & 0 deletions Projects/Folio/Shared/DesignSystem/Sources/Color+Extension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Color+Extension.swift
// FolioSharedDesignSystem
//
// Created by 송영모 on 2023/09/18.
//

import SwiftUI

public extension Color {
static func blackOrWhite(_ isSelected: Bool = false) -> Self {
return isSelected ? Color(uiColor: .label) : Color(uiColor: .systemBackground)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,22 @@ public struct AddTradeView: View {

public var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
ScrollView {
VStack(spacing: 20) {
headerView(viewStore: viewStore)
.padding(.top)

pickerView(viewStore: viewStore)
.padding(.bottom)

inputView(viewStore: viewStore)

Spacer()

saveButtonView(viewStore: viewStore)
GeometryReader { proxy in
ScrollView {
VStack(spacing: 20) {
headerView(viewStore: viewStore)

pickerView(viewStore: viewStore)
.padding(.bottom)

inputView(viewStore: viewStore)

Spacer()

saveButtonView(viewStore: viewStore)
}
.frame(height: proxy.size.height)
.padding()
}
}
}
Expand Down Expand Up @@ -112,6 +115,8 @@ public struct AddTradeView: View {

ScrollView(.horizontal) {
HStack {
Image(systemName: "photo")

ForEach(viewStore.state.images, id: \.self) { imageData in
ImageItem(imageData: imageData)
}
Expand All @@ -122,12 +127,6 @@ public struct AddTradeView: View {
}
}
}

VStack(alignment: .leading) {
Image(systemName: "note.text")

TextEditor(text: viewStore.binding(get: \.note, send: AddTradeStore.Action.setNote))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//
// TradeItemCellStore.swift
// ToolinderFeatureCalendarDemo
//
// Created by 송영모 on 2023/09/18.
//

import Foundation

import ComposableArchitecture

import ToolinderDomain

public struct TradeItemCellStore: Reducer {
public init() {}

public enum ViewType {
case `default`
case edit
}

public struct State: Equatable, Identifiable {
public let id: UUID
public let trade: Trade

public let viewType: ViewType
public let dateStyle: DateFormatter.Style
public let timeStyle: DateFormatter.Style

public var isSelected: Bool
public init(
id: UUID = .init(),
trade: Trade,
viewType: ViewType = .default,
dateStyle: DateFormatter.Style,
timeStyle: DateFormatter.Style,
isSelected: Bool = false
) {
self.id = id
self.trade = trade
self.viewType = viewType
self.dateStyle = dateStyle
self.timeStyle = timeStyle
self.isSelected = isSelected
}
}

public enum Action: Equatable {
case onAppear

case tapped
case editButtonTapped

case delegate(Delegate)

public enum Delegate: Equatable {
case tapped
case editButtonTapped
}
}

public var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .onAppear:
return .none

case .tapped:
return .send(.delegate(.tapped))

case .editButtonTapped:
return .send(.delegate(.editButtonTapped))

default:
return .none
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
//
// TradeItemCellView.swift
// ToolinderFeatureCalendarDemo
//
// Created by 송영모 on 2023/09/18.
//

import SwiftUI

import ComposableArchitecture

import ToolinderShared
import ToolinderDomain

public struct TradeItemCellView: View {
private let store: StoreOf<TradeItemCellStore>

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

public var body: some View {
WithViewStore(self.store, observe: { $0 }) { viewStore in
HStack {
tradeView(viewStore: viewStore)

switch viewStore.state.viewType {
case .default:
EmptyView()
case .edit:
editButtonView(viewStore: viewStore)
}
}
}
}

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)

viewStore.state.trade.ticker?.type?.image
.font(.title3)
.foregroundStyle(viewStore.state.trade.side == .buy ? .pink : .mint)

Text(viewStore.state.trade.ticker?.name ?? "")
.font(.body)
.fontWeight(.semibold)

Spacer()
}
.frame(height: 35)
.padding(10)
.background(viewStore.state.isSelected ? Color(uiColor: .systemGray5) : Color(uiColor: .systemGray6))
.clipShape(
RoundedRectangle(
cornerRadius: 8
)
)
.onTapGesture {
viewStore.send(.tapped)
}
}

private func editButtonView(viewStore: ViewStoreOf<TradeItemCellStore>) -> some View {
Button(action: {
viewStore.send(.editButtonTapped)
}, label: {
Image(systemName: "square.and.pencil")
})
.frame(height: 35)
.padding(10)
.background(viewStore.state.isSelected ? Color(uiColor: .systemGray5) : Color(uiColor: .systemGray6))
.clipShape(
RoundedRectangle(
cornerRadius: 8
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// TradePreviewItemCellStore.swift
// ToolinderFeatureCalendarDemo
//
// Created by 송영모 on 2023/09/18.
//

import Foundation

import ComposableArchitecture

import ToolinderDomain

public struct TradePreviewItemCellStore: Reducer {
public init() {}

public struct State: Equatable, Identifiable {
public let id: UUID

public let trade: Trade
public var isSelected: Bool

public init(
id: UUID = .init(),
trade: Trade,
isSelected: Bool = false
) {
self.id = id
self.trade = trade
self.isSelected = isSelected
}
}

public enum Action: Equatable {
case onAppear

case tapped

case delegate(Delegate)

public enum Delegate: Equatable {
case tapped
}
}

public var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
case .onAppear:
return .none

case .tapped:
return .send(.delegate(.tapped))

default:
return .none
}
}
}
}
Loading

0 comments on commit f09896d

Please sign in to comment.