File tree Expand file tree Collapse file tree 3 files changed +29
-41
lines changed
Sources/ComponentsKit/Components/Checkbox Expand file tree Collapse file tree 3 files changed +29
-41
lines changed Original file line number Diff line number Diff line change @@ -60,19 +60,19 @@ extension CheckboxVM {
6060 case . small:
6161 return 1.5
6262 case . medium:
63- return 2.0
63+ return 1.75
6464 case . large:
65- return 2.5
65+ return 2.0
6666 }
6767 }
6868 var checkboxSide : CGFloat {
6969 switch self . size {
7070 case . small:
71- return 16.0
72- case . medium:
7371 return 20.0
74- case . large :
72+ case . medium :
7573 return 24.0
74+ case . large:
75+ return 28.0
7676 }
7777 }
7878 var checkboxCornerRadius : CGFloat {
@@ -105,6 +105,22 @@ extension CheckboxVM {
105105 return . lgBody
106106 }
107107 }
108+ var checkmarkPath : CGPath {
109+ let path = UIBezierPath ( )
110+ path. move ( to: . init(
111+ x: 7 / 24 * self . checkboxSide,
112+ y: 12 / 24 * self . checkboxSide
113+ ) )
114+ path. addLine ( to: . init(
115+ x: 11 / 24 * self . checkboxSide,
116+ y: 16 / 24 * self . checkboxSide
117+ ) )
118+ path. addLine ( to: . init(
119+ x: 17 / 24 * self . checkboxSide,
120+ y: 8 / 24 * self . checkboxSide
121+ ) )
122+ return path. cgPath
123+ }
108124}
109125
110126// 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