Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import PlaygroundSupport
- import SwiftUI
- struct Toggles: View {
- @State private var vibrateOnRing = false
- var body: some View {
- VStack(spacing: 16) {
- Toggle("Vibrate on Ring", isOn: $vibrateOnRing)
- Toggle(
- "Vibrate on Ring",
- systemImage: "dot.radiowaves.left.and.right",
- isOn: $vibrateOnRing
- )
- Toggle("Vibrate on Ring", isOn: $vibrateOnRing)
- .toggleStyle(.button)
- Toggle(isOn: $vibrateOnRing) {
- Text("Vibrate on Ring")
- Text("Enable vibration when the phone rings")
- }
- .toggleStyle(.switch)
- Toggle(isOn: $vibrateOnRing) {
- Text("Vibrate on Ring")
- Text("Enable vibration when the phone rings")
- }
- .toggleStyle(ChecklistToggleStyle())
- }
- .padding()
- }
- }
- struct ChecklistToggleStyle: ToggleStyle {
- func makeBody(configuration: Configuration) -> some View {
- Button {
- configuration.isOn.toggle()
- } label: {
- HStack {
- Image(systemName: configuration.isOn
- ? "checkmark.circle.fill"
- : "circle")
- .tint(.green)
- configuration.label
- }
- }
- .tint(.primary)
- .buttonStyle(.borderless)
- }
- }
- let view = Toggles()
- PlaygroundPage.current.setLiveView(view)
Advertisement
Add Comment
Please, Sign In to add comment