mirror of
https://github.com/ivanvorobei/SwiftUI.git
synced 2026-04-10 03:03:47 +02:00
Remove deprecation warnings for Xcode beta4
This commit is contained in:
@@ -39,14 +39,14 @@ struct ConverterView : View {
|
||||
return ZStack(alignment: Alignment.bottomTrailing) {
|
||||
NavigationView {
|
||||
VStack(alignment: .leading){
|
||||
Text("From:").bold().color(.gray)
|
||||
Text("From:").bold().foregroundColor(.gray)
|
||||
HStack{
|
||||
// Flag
|
||||
Text("\(userData.baseCurrency.flag)").padding(5)
|
||||
// Code and name
|
||||
VStack(alignment: .leading){
|
||||
Text(userData.baseCurrency.code).color(.white)
|
||||
Text(userData.baseCurrency.name).color(.white)
|
||||
Text(userData.baseCurrency.code).foregroundColor(.white)
|
||||
Text(userData.baseCurrency.name).foregroundColor(.white)
|
||||
}
|
||||
Spacer()
|
||||
// Amount and conversion
|
||||
@@ -60,7 +60,7 @@ struct ConverterView : View {
|
||||
.padding(inset)
|
||||
)
|
||||
}.background(Color.blue).cornerRadius(5)
|
||||
Text("To:").bold().color(.gray)
|
||||
Text("To:").bold().foregroundColor(.gray)
|
||||
List {
|
||||
// TODO: should filter out BaseCurrency from list
|
||||
ForEach(userData.userCurrency) { currency in
|
||||
@@ -79,7 +79,8 @@ struct ConverterView : View {
|
||||
}
|
||||
})
|
||||
HStack {
|
||||
Text("Last updated: \(self.lastUpdated)").color(.gray).bold()
|
||||
Text("Last updated: \(self.lastUpdated)")
|
||||
.foregroundColor(.gray).bold()
|
||||
Spacer()
|
||||
|
||||
NavigationLink(destination: AddCurrencyView().environmentObject(self.userData)) {
|
||||
|
||||
@@ -49,7 +49,7 @@ struct CurrencyItemView: View {
|
||||
Text(currency.flag).font(.title)
|
||||
VStack(alignment: .leading){
|
||||
Text(currency.code)
|
||||
Text(currency.name).color(.gray)
|
||||
Text(currency.name).foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,14 +61,15 @@ struct CurrencyItemView: View {
|
||||
// Code and name
|
||||
VStack(alignment: .leading){
|
||||
Text(currency.code).font(.headline)
|
||||
Text(currency.name).font(.footnote).color(.gray)
|
||||
Text(currency.name).font(.footnote).foregroundColor(.gray)
|
||||
}
|
||||
Spacer()
|
||||
// Amount and conversion
|
||||
VStack(alignment: .trailing){
|
||||
Text("\(totalAmount)")
|
||||
// Would be 1 this currency = xxx base currency
|
||||
Text("1 \(currency.code) = \(converstionRate) \(userData.baseCurrency.code)").color(.gray)
|
||||
Text("1 \(currency.code) = \(converstionRate) \(userData.baseCurrency.code)")
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ private let defaultCurrencies: [Currency] = [
|
||||
Currency(name: "Canadian dollar", rate: 1.0, symbol: "CA", code: "CAD")
|
||||
]
|
||||
|
||||
@propertyDelegate
|
||||
@propertyWrapper
|
||||
struct UserDefaultValue<Value: Codable> {
|
||||
|
||||
let key: String
|
||||
let defaultValue: Value
|
||||
|
||||
var value: Value {
|
||||
var wrappedValue: Value {
|
||||
get {
|
||||
let data = UserDefaults.standard.data(forKey: key)
|
||||
let value = data.flatMap { try? JSONDecoder().decode(Value.self, from: $0) }
|
||||
|
||||
Reference in New Issue
Block a user