aboutsummaryrefslogtreecommitdiff
path: root/Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift
diff options
context:
space:
mode:
authorbenedom <>2024-04-16 10:51:16 +0200
committerbenedom <>2024-04-16 11:00:59 +0200
commit5e4554272f1262120a643efb39ccdb890ae592fe (patch)
treeb41eb7a0c5517a03d6937bb7c58cbb61ddb12920 /Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift
parentbe22624ac4e3d15091aa4556f4f7bdf1ff2b65ad (diff)
Adjusted demo application to include all configuration options
Diffstat (limited to 'Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift')
-rw-r--r--Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift20
1 files changed, 20 insertions, 0 deletions
diff --git a/Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift b/Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift
new file mode 100644
index 0000000..f616413
--- /dev/null
+++ b/Demo/SwiftyCropDemo/UIElements/DecimalTextField.swift
@@ -0,0 +1,20 @@
+import SwiftUI
+
+struct DecimalTextField: View {
+ @Binding var value: CGFloat
+ private let decimalFormatter: NumberFormatter = {
+ let formatter = NumberFormatter()
+ formatter.numberStyle = .decimal
+ formatter.allowsFloats = true
+ formatter.minimumFractionDigits = 1
+ formatter.decimalSeparator = "."
+ return formatter
+ }()
+
+ var body: some View {
+ TextField("maxMagnification", value: $value, formatter: decimalFormatter)
+ .textFieldStyle(RoundedBorderTextFieldStyle())
+ .multilineTextAlignment(.trailing)
+ .keyboardType(.decimalPad)
+ }
+}