2022/2/16 —— 2022/4/10
CryptoApp: A Swift Learning Demo
This app was make by following a @SwiftfulThinking course on YouTube. It use MVVM Architecture, Combine, and CoreData! The cryptocurrency data that is used this app comes from a free API from CoinGecko.
This app was developed by Nick Sarno. It uses SwiftUI and is written 100% in Swift The project benefits from multi-threading, publishers/subscibers, and data psersistance.
Tutorial url: https://www.youtube.com/watch?v=TTYKL6CfbSs&list=PLwvDm4Vfkdphbc3bgy_LpLRQ9DDfFGcFu
-
allCoinList数据的获取
-
按照价格、id对coin进行排序
-
数据刷新
-
搜索框及其逻辑处理
func filterCoins(text:String, coins:[CoinModel])->[CoinModel]{ guard !text.isEmpty else { return coins } let lowercasedText = text.lowercased() return coins.filter { coin in return coin.symbol.lowercased().contains(lowercasedText) || coin.id.lowercased().contains(lowercasedText) || coin.name.lowercased().contains(lowercasedText) } }
-
portfolioCoin的增删改查
-
allCoinList到portfolioCoin的切换
- 折线图表
使用Combine构建一个通用的网络请求函数
static func download(url:URL)->AnyPublisher<Data, Error>{
URLSession.shared.dataTaskPublisher(for: url)
.subscribe(on: DispatchQueue.global(qos: .background))
.tryMap({ try handleResponse(output: $0, url: url) })
.receive(on: DispatchQueue.main)
.eraseToAnyPublisher()
}
使用FileManager实现对图片资源持久化存储,以及增删改查
UINotificationFeedbackGenerator()
震动反馈
统一全局的颜色,方便修改和扩展。
extension Color{
static let theme = ColorTheme()
}
struct ColorTheme{
let secondaryText = Color("SecondaryTextColor")
let red = Color("RedColor")
let accent = Color("AccentColor")
let green = Color("GreenColor")
let background = Color("BackgroundColor")
}
方便为canvas的预览提供数据
enum SortOption{
case coin,coinReverse,price,priceReverse,holding,holdingReverse
}
- overlay
- .animation 和 with animation的使用区别
- .transition