Skip to content

Commit 4f6e922

Browse files
committed
initializer access fix
1 parent 1c0b3d9 commit 4f6e922

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

Sources/CheckBoxSwiftUI/CheckBox.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@ import SwiftUI
22

33
public struct CheckBox: View {
44
@Binding var isChecked:Bool
5-
@State var title:String
6-
@State var checkBoxColor: Color?
7-
@State var titleColor: Color?
5+
var title:String?
6+
var checkBoxColor: Color?
7+
var titleColor: Color?
88

9-
private var uncheckedSymbolName = "square"
10-
private var checkedSymbolName = "checkmark.square.fill"
9+
var uncheckedSymbolName = "square"
10+
var checkedSymbolName = "checkmark.square.fill"
11+
12+
public init(isChecked: Binding<Bool>, title: String? = nil, checkBoxColor: Color? = nil, titleColor: Color? = nil) {
13+
self._isChecked = isChecked
14+
self.title = title
15+
self.checkBoxColor = checkBoxColor
16+
self.titleColor = titleColor
17+
}
1118

1219
public var body: some View {
1320
HStack {
@@ -19,7 +26,7 @@ public struct CheckBox: View {
1926
.imageScale(.large)
2027
.foregroundColor(checkBoxColor ?? Color(.gray))
2128

22-
Text(title)
29+
Text(title ?? "")
2330
.foregroundColor(titleColor ?? Color(UIColor.label))
2431
}
2532
}

0 commit comments

Comments
 (0)