From 47d827540de8198bb7c8528a60cbbd9579f6e657 Mon Sep 17 00:00:00 2001 From: Alexandr Romanov Date: Wed, 12 Oct 2022 23:22:08 +0300 Subject: [PATCH] Add other units --- .../WeightPicker/WeightPicker.swift | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Sources/OversizeHealthComponents/WeightPicker/WeightPicker.swift b/Sources/OversizeHealthComponents/WeightPicker/WeightPicker.swift index bf24842..540a3aa 100644 --- a/Sources/OversizeHealthComponents/WeightPicker/WeightPicker.swift +++ b/Sources/OversizeHealthComponents/WeightPicker/WeightPicker.swift @@ -24,12 +24,15 @@ public struct WeightPicker: View { @Namespace private var animation @State private var image = UIImage() + + private let unit: String - public init(startWeight: Double, action: ((Double, UIImage) -> Void)? = nil, premiumAction: (() -> Void)? = nil) { + public init(startWeight: Double, unit: String, action: ((Double, UIImage) -> Void)? = nil, premiumAction: (() -> Void)? = nil) { self.startWeight = startWeight _value = State(initialValue: startWeight) self.action = action self.premiumAction = premiumAction + self.unit = unit } var weightChange: Double? { @@ -104,7 +107,7 @@ public struct WeightPicker: View { .padding(.bottom, .large) SlidingRuler(value: $value, - in: 10 ... 150, + in: 1 ... 350, step: 1, snap: .fraction, tick: .fraction, @@ -243,7 +246,7 @@ public struct WeightPicker: View { .font(.system(size: 40, design: .rounded).weight(.bold)) .monospacedDigit() - Text("kg") + Text(unit) .font(.system(.title2, design: .rounded).weight(.semibold)) .foregroundColor(.onBackgroundDisabled) } @@ -258,6 +261,6 @@ public struct WeightPicker: View { struct WeightPicker_Previews: PreviewProvider { static var previews: some View { - WeightPicker(startWeight: 80) + WeightPicker(startWeight: 80, unit: "kg") } }