SlidingRuler icon indicating copy to clipboard operation
SlidingRuler copied to clipboard

Accessing Environment<Bool>'s value

Open e1tester2019 opened this issue 3 years ago • 3 comments

[SwiftUI] Accessing Environment<Bool>'s value outside of being installed on a View. This will always read the default value and will not update.

Screenshot 2022-12-03 at 11 53 10
@State private var value: Double = .zero

private var formatter: NumberFormatter {
    let f = NumberFormatter()
    f.numberStyle = .decimal
    f.maximumFractionDigits = 20
    return f
}

var body: some View {
    
    SlidingRuler(value: $value,
                 in: 0...1,
                 step: 0.1,
                 snap: .fraction,
                 tick: .fraction,
                 formatter: formatter)

e1tester2019 avatar Dec 03 '22 18:12 e1tester2019

same +1

Weixuanf avatar Mar 31 '23 08:03 Weixuanf

I made a fork and fixed this: https://github.com/Weixuanf/SlidingRuler

I just deleted accessing the environment .hasmark variable, it's kinda a hack now, let me know if there's a better to fix, I can do it

Weixuanf avatar Mar 31 '23 09:03 Weixuanf

I made a fork and fixed this: https://github.com/Weixuanf/SlidingRuler

I just deleted accessing the environment .hasmark variable, it's kinda a hack now, let me know if there's a better to fix, I can do it

Thank you, solved the problem! <3

marvpaul avatar Sep 11 '24 08:09 marvpaul