Add persistence of selected currencies to disk via SQLite

This commit is contained in:
2024-11-20 20:13:54 +02:00
parent 303cad1076
commit da21b78588
6 changed files with 224 additions and 10 deletions

View File

@@ -31,7 +31,7 @@ struct CurrencyPickerView: View {
ForEach(satsViewModel.selectedCurrencies.filter { $0 != currentCurrency }.sorted { $0.identifier < $1.identifier }, id: \.identifier) { currency in
Button(
action: {
satsViewModel.selectedCurrencies.remove(currency)
satsViewModel.removeSelectedCurrency(currency)
},
label: {
HStack {
@@ -57,7 +57,7 @@ struct CurrencyPickerView: View {
ForEach(satsViewModel.currencies.filter { $0 != currentCurrency && !satsViewModel.selectedCurrencies.contains($0) }, id: \.identifier) { currency in
Button(
action: {
satsViewModel.selectedCurrencies.insert(currency)
satsViewModel.addSelectedCurrency(currency)
},
label: {
if let localizedCurrency = Locale.current.localizedString(forCurrencyCode: currency.identifier) {
@@ -80,5 +80,6 @@ struct CurrencyPickerView: View {
}
#Preview {
CurrencyPickerView(satsViewModel: SatsViewModel())
let satsPriceModel = try! SatsPriceModel(url: nil)
CurrencyPickerView(satsViewModel: SatsViewModel(model: satsPriceModel))
}