File tree Expand file tree Collapse file tree 3 files changed +28
-47
lines changed
Sources/ComponentsKit/Components/Checkbox Expand file tree Collapse file tree 3 files changed +28
-47
lines changed Original file line number Diff line number Diff line change @@ -56,23 +56,16 @@ extension CheckboxVM {
5656 return self . title. isNil ? 0.0 : 8.0
5757 }
5858 var checkmarkLineWidth : CGFloat {
59- switch self . size {
60- case . small:
61- return 1.5
62- case . medium:
63- return 2.0
64- case . large:
65- return 2.5
66- }
59+ return 1.5
6760 }
6861 var checkboxSide : CGFloat {
6962 switch self . size {
7063 case . small:
71- return 16.0
72- case . medium:
7364 return 20.0
74- case . large :
65+ case . medium :
7566 return 24.0
67+ case . large:
68+ return 28.0
7669 }
7770 }
7871 var checkboxCornerRadius : CGFloat {
@@ -105,6 +98,22 @@ extension CheckboxVM {
10598 return . lgBody
10699 }
107100 }
101+ var checkmarkPath : CGPath {
102+ let path = UIBezierPath ( )
103+ path. move ( to: . init(
104+ x: 7 / 24 * self . checkboxSide,
105+ y: 12 / 24 * self . checkboxSide
106+ ) )
107+ path. addLine ( to: . init(
108+ x: 11 / 24 * self . checkboxSide,
109+ y: 16 / 24 * self . checkboxSide
110+ ) )
111+ path. addLine ( to: . init(
112+ x: 17 / 24 * self . checkboxSide,
113+ y: 8 / 24 * self . checkboxSide
114+ ) )
115+ return path. cgPath
116+ }
108117}
109118
110119// MARK: UIKit Helpers
Original file line number Diff line number Diff line change @@ -45,27 +45,14 @@ public struct SUCheckbox: View {
4545 value: self . isSelected
4646 )
4747
48- Path { path in
49- path. move ( to: . init(
50- x: self . model. checkboxSide / 4 ,
51- y: 11 / 24 * self . model. checkboxSide
48+ Path ( self . model. checkmarkPath)
49+ . trim ( from: 0 , to: self . checkmarkStroke)
50+ . stroke ( style: StrokeStyle (
51+ lineWidth: self . model. checkmarkLineWidth,
52+ lineCap: . round,
53+ lineJoin: . round
5254 ) )
53- path. addLine ( to: . init(
54- x: 11 / 24 * self . model. checkboxSide,
55- y: 17 / 24 * self . model. checkboxSide
56- ) )
57- path. addLine ( to: . init(
58- x: 3 / 4 * self . model. checkboxSide,
59- y: 7 / 24 * self . model. checkboxSide
60- ) )
61- }
62- . trim ( from: 0 , to: self . checkmarkStroke)
63- . stroke ( style: StrokeStyle (
64- lineWidth: self . model. checkmarkLineWidth,
65- lineCap: . round,
66- lineJoin: . round
67- ) )
68- . foregroundStyle ( self . model. foregroundColor. color)
55+ . foregroundStyle ( self . model. foregroundColor. color)
6956 }
7057 . overlay {
7158 RoundedRectangle ( cornerRadius: self . model. checkboxCornerRadius)
Original file line number Diff line number Diff line change @@ -96,22 +96,7 @@ open class UKCheckbox: UIView, UKComponent {
9696 self . checkmarkLayer. lineCap = . round
9797 self . checkmarkLayer. lineJoin = . round
9898 self . checkmarkLayer. strokeEnd = self . isSelected ? 1.0 : 0.0
99-
100- let checkmarkPath = UIBezierPath ( )
101- checkmarkPath. move ( to: . init(
102- x: self . model. checkboxSide / 4 ,
103- y: 11 / 24 * self . model. checkboxSide
104- ) )
105- checkmarkPath. addLine ( to: . init(
106- x: 11 / 24 * self . model. checkboxSide,
107- y: 17 / 24 * self . model. checkboxSide
108- ) )
109- checkmarkPath. addLine ( to: . init(
110- x: 3 / 4 * self . model. checkboxSide,
111- y: 7 / 24 * self . model. checkboxSide
112- ) )
113-
114- self . checkmarkLayer. path = checkmarkPath. cgPath
99+ self . checkmarkLayer. path = self . model. checkmarkPath
115100 }
116101
117102 // MARK: Style
You can’t perform that action at this time.
0 commit comments