-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat/#17] 저장 및 리프레시 로직 구현
- Loading branch information
Showing
68 changed files
with
2,357 additions
and
856 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Projects/Toolinder/Domain/Trade/Interface/Sources/DTO/TradeDTO.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
Projects/Toolinder/Domain/Trade/Interface/Sources/Model/Currency.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
28 changes: 28 additions & 0 deletions
28
Projects/Toolinder/Domain/Trade/Interface/Sources/Model/Ticker.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
Projects/Toolinder/Domain/Trade/Interface/Sources/Model/Tradecurrency.swift
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
Projects/Toolinder/Domain/Trade/Interface/Sources/PhotoClient.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
) | ||
} |
32 changes: 32 additions & 0 deletions
32
Projects/Toolinder/Domain/Trade/Interface/Sources/PhotoRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.