Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Sources/CharcoalSwiftUI/Components/CharcoalToggle.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import SwiftUI

struct CharcoalToggleWrapper: UIViewRepresentable {
@Binding var isOn: Bool
@Binding var isOn: Bool {
didSet {
if uiSwitch.isOn != isOn {
uiSwitch.setOn(isOn, animated: true)
}
}
}

let uiSwitch = UISwitch()

func makeUIView(context: Context) -> UISwitch {
let uiSwitch = UISwitch()
uiSwitch.addTarget(context.coordinator, action: #selector(Coordinator.handleValueChanged(_:)), for: .valueChanged)
uiSwitch.onTintColor = CharcoalAsset.ColorPaletteGenerated.brand.color
uiSwitch.backgroundColor = CharcoalAsset.ColorPaletteGenerated.surface4.color
Expand Down
Loading