From 4e1ac7040c0b6d3b542bb9fb638e99e1d32097e8 Mon Sep 17 00:00:00 2001 From: Terry Yiu <963907+tyiu@users.noreply.github.com> Date: Wed, 21 Feb 2024 08:25:14 -0500 Subject: [PATCH] Restructure OS-specific compilation --- SatsPrice/ContentView.swift | 61 +++++++++++++++---------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/SatsPrice/ContentView.swift b/SatsPrice/ContentView.swift index 6985c4c..a045722 100644 --- a/SatsPrice/ContentView.swift +++ b/SatsPrice/ContentView.swift @@ -7,6 +7,7 @@ import SwiftUI import BigDecimal +import Combine struct ContentView: View { @ObservedObject private var satsViewModel = SatsViewModel() @@ -69,46 +70,32 @@ struct ContentView: View { Text("Last updated: \(dateFormatter.string(from: satsViewModel.lastUpdated))") } + Section { + TextField("", text: $satsViewModel.satsString) #if os(iOS) - Section { - TextField("", text: $satsViewModel.satsString) .keyboardType(.numberPad) - } header: { - Text("Sats") - } - - Section { - TextField("", text: $satsViewModel.btcString) - .keyboardType(.decimalPad) - } header: { - Text("BTC") - } - - Section { - TextField("", text: $satsViewModel.usdString) - .keyboardType(.decimalPad) - } header: { - Text("USD") - } -#else - Section { - TextField("", text: $satsViewModel.satsString) - } header: { - Text("Sats") - } - - Section { - TextField("", text: $satsViewModel.btcString) - } header: { - Text("BTC") - } - - Section { - TextField("", text: $satsViewModel.usdString) - } header: { - Text("USD") - } #endif + } header: { + Text("Sats") + } + + Section { + TextField("", text: $satsViewModel.btcString) +#if os(iOS) + .keyboardType(.decimalPad) +#endif + } header: { + Text("BTC") + } + + Section { + TextField("", text: $satsViewModel.usdString) +#if os(iOS) + .keyboardType(.decimalPad) +#endif + } header: { + Text("USD") + } } .task { await updatePrice()