Skip to content

Commit

Permalink
Add other units
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Oct 12, 2022
1 parent 857efd0 commit 47d8275
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Sources/OversizeHealthComponents/WeightPicker/WeightPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand All @@ -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")
}
}

0 comments on commit 47d8275

Please sign in to comment.