-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToggleFunc.swift
More file actions
34 lines (28 loc) · 966 Bytes
/
ToggleFunc.swift
File metadata and controls
34 lines (28 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// ToggleFunc.swift
// inna
//
// Created by Sebin Park on 2023/06/08.
//
import Foundation
import SwiftUI
struct CheckmarkToggleStyle: ToggleStyle {
func makeBody(configuration: Configuration) -> some View {
HStack {
configuration.label
Spacer()
ZStack {
Rectangle()
.foregroundColor(configuration.isOn ? .Green3 : .greyishGreen5)
.frame(width: 46, height: 22, alignment: .center)
.cornerRadius(20)
Circle()
.foregroundColor(configuration.isOn ? .Green2 : .greyishGreen2 )
.onTapGesture { configuration.isOn.toggle() }
.frame(width: 34, height: 34)
.offset(x: configuration.isOn ? 11 : -11, y: 0)
.animation(Animation.linear(duration: 0.1))
}
}
}
}