From 3560b12c240ccf9fe73a3f810abd3e6142e11eed Mon Sep 17 00:00:00 2001 From: Terry Yiu <963907+tyiu@users.noreply.github.com> Date: Sat, 7 Sep 2024 06:05:20 +0300 Subject: [PATCH] Add warning when BTC and sats exceed the maximum --- Skip.env | 2 +- Sources/SatsPrice/ContentView.swift | 8 ++++++++ Sources/SatsPrice/Resources/Localizable.xcstrings | 6 ++++++ Sources/SatsPrice/SatsViewModel.swift | 7 +++++++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Skip.env b/Skip.env index 1a2980d..4f2665e 100644 --- a/Skip.env +++ b/Skip.env @@ -14,7 +14,7 @@ PRODUCT_BUNDLE_IDENTIFIER = xyz.tyiu.SatsPrice MARKETING_VERSION = 0.2.0 // The build number specifying the internal app version -CURRENT_PROJECT_VERSION = 2 +CURRENT_PROJECT_VERSION = 3 // The package name for the Android entry point, referenced by the AndroidManifest.xml ANDROID_PACKAGE_NAME = sats.price diff --git a/Sources/SatsPrice/ContentView.swift b/Sources/SatsPrice/ContentView.swift index 755feae..9f4a798 100644 --- a/Sources/SatsPrice/ContentView.swift +++ b/Sources/SatsPrice/ContentView.swift @@ -88,6 +88,10 @@ public struct ContentView: View { #endif } header: { Text("Sats") + } footer: { + if satsViewModel.exceedsMaximum { + Text("2100000000000000 sats is the maximum.") + } } Section { @@ -97,6 +101,10 @@ public struct ContentView: View { #endif } header: { Text("BTC") + } footer: { + if satsViewModel.exceedsMaximum { + Text("21000000 BTC is the maximum.") + } } Section { diff --git a/Sources/SatsPrice/Resources/Localizable.xcstrings b/Sources/SatsPrice/Resources/Localizable.xcstrings index 54f5947..3e62340 100644 --- a/Sources/SatsPrice/Resources/Localizable.xcstrings +++ b/Sources/SatsPrice/Resources/Localizable.xcstrings @@ -16,6 +16,12 @@ }, "1 BTC to %@" : { + }, + "21000000 BTC is the maximum." : { + + }, + "2100000000000000 sats is the maximum." : { + }, "BTC" : { diff --git a/Sources/SatsPrice/SatsViewModel.swift b/Sources/SatsPrice/SatsViewModel.swift index 1be80a8..e3b10fa 100644 --- a/Sources/SatsPrice/SatsViewModel.swift +++ b/Sources/SatsPrice/SatsViewModel.swift @@ -190,6 +190,13 @@ class SatsViewModel: ObservableObject { } #endif } + + var exceedsMaximum: Bool { + if let btc, btc > Decimal(21000000) { + return true + } + return false + } } extension Decimal {