Skip to content

Commit

Permalink
Merge pull request #18 from folio-world/feat/#17-logic
Browse files Browse the repository at this point in the history
[Feat/#17] 저장 및 리프레시 로직 구현
  • Loading branch information
mooyoung2309 authored Sep 16, 2023
2 parents 894933a + 09ae8ef commit c044bce
Show file tree
Hide file tree
Showing 68 changed files with 2,357 additions and 856 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public extension [TargetDependency] {
case .Toolinder:
return [
.external(name: "ComposableArchitecture"),
.external(name: "RealmSwift")
]
case .Folio:
return [
Expand Down
16 changes: 16 additions & 0 deletions Projects/Mulling/App/MullingIOS.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.toolinder</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudKit</string>
</array>
</dict>
</plist>
3 changes: 2 additions & 1 deletion Projects/Toolinder/App/Sources/RootApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct RootApp: App {

init() {
do {
modelContainer = try ModelContainer(for: Trade.self)
modelContainer = try ModelContainer(for: Ticker.self, Trade.self)
} catch {
fatalError("Could not initialize ModelContainer \(error)")
}
Expand All @@ -32,6 +32,7 @@ struct RootApp: App {
._printChanges()
}
)
.onAppear(perform: UIApplication.shared.hideKeyboard)
}
.modelContainer(modelContainer)
}
Expand Down
36 changes: 20 additions & 16 deletions Projects/Toolinder/App/Support/ToolinderAppIOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,32 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>REWARDED_ID</key>
<string>$(REWARDED_ID)</string>
<key>OPENAI_API_KEY</key>
<string>$(OPENAI_API_KEY)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>Primary App Icon Set Name</key>
<string>AppIcon</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Toolinder</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>UILaunchStoryboardName</key>
<string>Launch</string>
<key>CFBundleDisplayName</key>
<string>Toolinder</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-2392187154020666~7018659983</string>
<key>GADIsAdManagerApp</key>
<true/>
<key>OPENAI_API_KEY</key>
<string>$(OPENAI_API_KEY)</string>
<key>Primary App Icon Set Name</key>
<string>AppIcon</string>
<key>REWARDED_ID</key>
<string>$(REWARDED_ID)</string>
<key>SKAdNetworkItems</key>
<array>
<dict>
Expand Down Expand Up @@ -229,5 +227,11 @@
<string>3qcr597p9d.skadnetwork</string>
</dict>
</array>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>Launch</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// TradeDTO.swift
// ToolinderDomainTrade
//
// Created by 송영모 on 2023/09/16.
//

import Foundation
import SwiftData

public struct TradeDTO {
public var side: TradeSide?
public var price: Double?
public var volume: Double?
public var images: [Data] = []
public var note: String?
public var date: Date = Date()

public var ticker: Ticker?

public init(
side: TradeSide? = nil,
price: Double? = 0.0,
volume: Double? = 0.0,
images: [Data] = [],
note: String? = "",
date: Date = Date(),
ticker: Ticker? = nil
) {
self.side = side
self.images = images
self.price = price
self.volume = volume
self.note = note
self.date = date
self.ticker = ticker
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Tradecurrency.swift
// ToolinderDomainTradeInterface
//
// Created by 송영모 on 2023/09/04.
//

import Foundation

public enum Currency: String, Codable, CaseIterable, Equatable {
case dollar = "USD"
case yen = "JPY"
case sterling = "GBP"
case franc = "CHF"
case florin = "AWG"
case turkishlira = "TRY"
case ruble = "RUB"
case euro = "EUR"
case dong = "VND"
case indianrupee = "INR"
case tenge = "KZT"
case peseta = "ESP"
case peso = "MXN"
case kip = "LAK"
case won = "KRW"
case austral = "AUD"
case hryvnia = "UAH"
case naira = "NGN"
case guarani = "PYG"
case coloncurrency = "CRC"
case cedi = "GHS"
case tugrik = "MNT"
case shekel = "ILS"
case manat = "AZN"
case baht = "THB"
case lari = "GEL"
case bitcoin = "BTC"
case brazilianreal = "BRL"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Ticker.swift
// ToolinderDomainTradeInterface
//
// Created by 송영모 on 2023/09/08.
//

import Foundation
import SwiftData

@Model
public class Ticker {
public var type: TickerType? = TickerType.stock
public var currency: Currency? = Currency.dollar
public var name: String? = ""

@Relationship(inverse: \Trade.ticker) public var trades: [Trade]? = []

public init(
type: TickerType,
currency: Currency,
name: String
) {
self.type = type
self.currency = currency
self.name = name
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import Foundation

public enum TradeType: Codable {
case stock
public enum TickerType: String, Codable, CaseIterable, Equatable {
case stock = "Stock"
case crypto = "Crypto"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,30 @@ import SwiftData

@Model
public class Trade {
public var name: String?
public var type: TradeType?
public var currency: Tradecurrency?
public var side: TradeSide?
public var images: [Data] = []
public var price: Double?
public var volume: Double?
public var images: [Data] = []
public var note: String?
public var date: Date = Date()


@Relationship public var ticker: Ticker?

public init(
name: String? = "",
type: TradeType? = .stock,
currency: Tradecurrency? = .krw,
side: TradeSide? = .buy,
images: [Data] = [],
side: TradeSide? = nil,
price: Double? = 0.0,
volume: Double? = 0.0,
images: [Data] = [],
note: String? = "",
date: Date = Date()
date: Date = Date(),
ticker: Ticker? = nil
) {
self.name = name
self.type = type
self.currency = currency
self.side = side
self.images = images
self.price = price
self.volume = volume
self.note = note
self.date = date
self.ticker = ticker
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

public enum TradeSide: Codable {
public enum TradeSide: String, Codable, CaseIterable {
case buy
case sell
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// PhotoClient.swift
// ToolinderDomainTrade
//
// Created by 송영모 on 2023/09/16.
//

import Foundation
import SwiftUI
import SwiftData
import PhotosUI

import ComposableArchitecture

public enum PhotoError: Error {
case unknown
}

public struct PhotoClient {
public static let photoRepository: PhotoRepositoryInterface = PhotoRepository.shared

public var toDataList: @Sendable ([PhotosPickerItem]) async -> Result<[Data], PhotoError>

public init(
toDataList: @Sendable @escaping ([PhotosPickerItem]) async -> Result<[Data], PhotoError>
) {
self.toDataList = toDataList
}
}

extension PhotoClient: TestDependencyKey {
public static var previewValue: PhotoClient = Self(
toDataList: { _ in return .failure(.unknown) }
)

public static var testValue = Self(
toDataList: unimplemented("\(Self.self).toDataList")
)
}

public extension DependencyValues {
var photoClient: PhotoClient {
get { self[PhotoClient.self] }
set { self[PhotoClient.self] = newValue }
}
}

extension PhotoClient: DependencyKey {
public static var liveValue = PhotoClient(
toDataList: { photosPickerItems in
var result: [Data] = []
for item in photosPickerItems {
let data = await photoRepository.toData(from: item)
result.append(data)
}

return .success(result)
}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// PhotoRepository.swift
// ToolinderDomainTrade
//
// Created by 송영모 on 2023/09/16.
//

import SwiftUI
import PhotosUI

public protocol PhotoRepositoryInterface {
func toData(from photosPickerItem: PhotosPickerItem) async -> Data
}

public class PhotoRepository: PhotoRepositoryInterface {
public static var shared: PhotoRepositoryInterface = PhotoRepository()

public func toData(from photosPickerItem: PhotosPickerItem) async -> Data {
return await withCheckedContinuation { continuation in
photosPickerItem.loadTransferable(type: Data.self) { result in
switch result {
case .success(let imageData):
if let imageData = imageData {
continuation.resume(returning: imageData)
}
case .failure(let error):
print(error)
}
}
}
}
}
Loading

0 comments on commit c044bce

Please sign in to comment.