Mercurial > public > simoleon
comparison Simoleon/Conversion.swift @ 27:d95582268b44
Fix bug CoreData and minor UI changes
author | Dennis Concepción Martín <dennisconcepcionmartin@gmail.com> |
---|---|
date | Wed, 21 Jul 2021 12:36:10 +0100 |
parents | 933d9ab04374 |
children | 4f862c618b44 |
comparison
equal
deleted
inserted
replaced
26:337816652bfe | 27:d95582268b44 |
---|---|
16 @State private var showingConversion = false | 16 @State private var showingConversion = false |
17 @State private var showingCurrencySelector = false | 17 @State private var showingCurrencySelector = false |
18 @State private var isEditing = false | 18 @State private var isEditing = false |
19 | 19 |
20 @Environment(\.managedObjectContext) private var viewContext | 20 @Environment(\.managedObjectContext) private var viewContext |
21 @FetchRequest(sortDescriptors: []) private var userSettings: FetchedResults<UserSettings> | 21 @FetchRequest(sortDescriptors: []) private var defaultCurrency: FetchedResults<DefaultCurrency> |
22 let currencyMetadata: [String: CurrencyMetadataModel] = parseJson("CurrencyMetadata.json") | 22 let currencyMetadata: [String: CurrencyMetadataModel] = parseJson("CurrencyMetadata.json") |
23 | 23 |
24 var body: some View { | 24 var body: some View { |
25 ScrollView(showsIndicators: false) { | 25 ScrollView(showsIndicators: false) { |
26 VStack(alignment: .leading) { | 26 VStack(alignment: .leading) { |
27 HStack { | 27 HStack { |
28 Button(action: { showingCurrencySelector = true }) { | 28 Button(action: { showingCurrencySelector = true }) { |
29 RoundedRectangle(cornerRadius: 25) | 29 RoundedRectangle(cornerRadius: 15) |
30 .foregroundColor(Color(.secondarySystemBackground)) | 30 .foregroundColor(Color(.secondarySystemBackground)) |
31 .frame(height: 65) | 31 .frame(height: 60) |
32 .overlay(CurrencyRow(currencyPair: currencyPair).padding(.horizontal)) | 32 .overlay(CurrencyRow(currencyPair: currencyPair).padding(.horizontal)) |
33 } | 33 } |
34 | 34 |
35 FavouriteButton(currencyPair: currencyPair) | 35 FavouriteButton(currencyPair: currencyPair) |
36 } | 36 } |
94 /* | 94 /* |
95 1) Fetch default currency from User Settings | 95 1) Fetch default currency from User Settings |
96 2) Change State var currencyPair | 96 2) Change State var currencyPair |
97 */ | 97 */ |
98 private func fetchingUserSettings() { | 98 private func fetchingUserSettings() { |
99 if let userSettings = userSettings.first { | 99 if let defaultCurrency = defaultCurrency.first { |
100 self.currencyPair = userSettings.defaultCurrency ?? "USD/GBP" | 100 self.currencyPair = defaultCurrency.pair ?? "USD/GBP" |
101 } | 101 } |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 | 105 |