Files
2022-07-26 22:03:18 -04:00

40 lines
1.0 KiB
Swift
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The MIT License (MIT)
//
// Copyright (c) 20202022 Alexander Grebenyuk (github.com/kean).
import SwiftUI
#if os(iOS) || os(macOS)
struct Checkbox: View {
@Binding var isEnabled: Bool
var body: some View {
Button(action: { isEnabled.toggle() }) {
Image(systemName: isEnabled ? "checkmark.circle.fill" : "circle")
.font(.system(size: 18))
.foregroundColor(.accentColor)
}.buttonStyle(.plain)
}
}
struct CheckboxView_Previews: PreviewProvider {
static var previews: some View {
VStack(spacing: 32) {
HStack(spacing: 16) {
Checkbox(isEnabled: .constant(true))
.disabled(false)
Checkbox(isEnabled: .constant(false))
.disabled(false)
}
HStack(spacing: 16) {
Checkbox(isEnabled: .constant(true))
.disabled(true)
Checkbox(isEnabled: .constant(false))
.disabled(true)
}
}
}
}
#endif