File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -22,19 +22,23 @@ class FontPickerDelegate {
22
22
}
23
23
24
24
public struct FontPicker : View {
25
- let labelString : String
25
+ let label : LocalizedStringKey ?
26
26
27
27
@Binding var font : NSFont
28
- @State var fontPickerDelegate : FontPickerDelegate ? = nil
28
+ @State var fontPickerDelegate : FontPickerDelegate ?
29
29
30
- public init ( _ label : String , selection: Binding < NSFont > ) {
31
- self . labelString = label
30
+ public init ( _ titlekey : LocalizedStringKey ? = nil , selection: Binding < NSFont > ) {
31
+ self . label = titlekey
32
32
self . _font = selection
33
33
}
34
34
35
35
public var body : some View {
36
36
HStack {
37
- Text ( labelString)
37
+ if let label {
38
+ Text ( label)
39
+ } else {
40
+ EmptyView ( )
41
+ }
38
42
39
43
Button {
40
44
if NSFontPanel . shared. isVisible {
@@ -65,6 +69,9 @@ public struct FontPicker: View {
65
69
66
70
struct FontPicker_Previews : PreviewProvider {
67
71
static var previews : some View {
68
- FontPicker ( " font " , selection: . constant( NSFont . systemFont ( ofSize: 24 ) ) )
72
+ Group {
73
+ FontPicker ( " font " , selection: . constant( NSFont . systemFont ( ofSize: 24 ) ) )
74
+ FontPicker ( selection: . constant( NSFont . systemFont ( ofSize: 24 ) ) )
75
+ }
69
76
}
70
77
}
You can’t perform that action at this time.
0 commit comments