Files
Morgan Pretty 173025697b Fixed a few issues, updated for latest libSession changes
• Updated to latest libSession
• Updated code to use urls and strings from libSession
• Split the profile and message pro feature bitsets
• Fixed a bunch of warnings
• Fixed a bug where the Toggle ListItemAccessory could swallow touches and make it appear as though something changed when it didn't
• Fixed a bug where not all profile data was getting encoded/decoded
2025-11-27 15:38:02 +11:00

42 lines
1.2 KiB
Swift

// Copyright © 2025 Rangeproof Pty Ltd. All rights reserved.
import SwiftUI
public struct AnimatedToggle: View {
let value: Bool
let oldValue: Bool?
let allowHitTesting: Bool
let accessibility: Accessibility
@State private var uiValue: Bool
public init(
value: Bool,
oldValue: Bool?,
allowHitTesting: Bool,
accessibility: Accessibility
) {
self.value = value
self.oldValue = oldValue
self.allowHitTesting = allowHitTesting
self.accessibility = accessibility
_uiValue = State(initialValue: oldValue ?? value)
}
public var body: some View {
Toggle("", isOn: $uiValue)
.allowsHitTesting(allowHitTesting)
.labelsHidden()
.accessibility(accessibility)
.tint(themeColor: .primary)
.task {
guard (oldValue ?? value) != value else { return }
try? await Task.sleep(nanoseconds: 10_000_000) // ~10ms
withAnimation { uiValue = value }
}
.onChange(of: value) { new in
withAnimation { uiValue = new }
}
}
}