Skip to content

Commit cdcd0e1

Browse files
committed
format
1 parent 2b38d73 commit cdcd0e1

File tree

5 files changed

+104
-99
lines changed

5 files changed

+104
-99
lines changed

Examples/Sources/ControlFocusabilityTest/ControlsFocusabilityApp.swift

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@ struct ControlsFocusabilityApp: App {
4242
.focusable(false)
4343
}
4444
.padding(.bottom, 20)
45-
46-
#if !canImport(UIKitBackend)
47-
HStack {
48-
VStack {
49-
Text("Toggle button")
50-
Toggle("Toggle me!", active: $exampleButtonState)
51-
.toggleStyle(.button)
52-
.focusable(isToggleButtonFocusable)
53-
Text("Currently enabled: \(exampleButtonState)")
45+
46+
#if !canImport(UIKitBackend)
47+
HStack {
48+
VStack {
49+
Text("Toggle button")
50+
Toggle("Toggle me!", active: $exampleButtonState)
51+
.toggleStyle(.button)
52+
.focusable(isToggleButtonFocusable)
53+
Text("Currently enabled: \(exampleButtonState)")
54+
}
55+
Toggle("focusable", active: $isToggleButtonFocusable)
56+
.focusable(false)
5457
}
55-
Toggle("focusable", active: $isToggleButtonFocusable)
56-
.focusable(false)
57-
}
58-
.padding(.bottom, 20)
59-
#endif
60-
58+
.padding(.bottom, 20)
59+
#endif
60+
6161
HStack {
6262
VStack {
6363
Text("Toggle switch")
@@ -69,32 +69,32 @@ struct ControlsFocusabilityApp: App {
6969
Toggle("focusable", active: $isToggleSwitchFocusable)
7070
.focusable(false)
7171
}
72-
73-
#if !canImport(UIKitBackend)
74-
HStack {
75-
VStack {
76-
Text("Checkbox")
77-
Toggle("Toggle me:", active: $exampleCheckboxState)
78-
.toggleStyle(.checkbox)
79-
.focusable(isCheckboxFocusable)
80-
Text("Currently enabled: \(exampleCheckboxState)")
72+
73+
#if !canImport(UIKitBackend)
74+
HStack {
75+
VStack {
76+
Text("Checkbox")
77+
Toggle("Toggle me:", active: $exampleCheckboxState)
78+
.toggleStyle(.checkbox)
79+
.focusable(isCheckboxFocusable)
80+
Text("Currently enabled: \(exampleCheckboxState)")
81+
}
82+
Toggle("focusable", active: $isCheckboxFocusable)
83+
.focusable(false)
8184
}
82-
Toggle("focusable", active: $isCheckboxFocusable)
83-
.focusable(false)
84-
}
85-
#endif
85+
#endif
8686
#if !os(tvOS)
87-
HStack {
88-
VStack {
89-
Text("Slider")
90-
Slider($sliderValue, minimum: 0, maximum: 10)
91-
.frame(maxWidth: 200)
92-
.focusable(isSliderFocusable)
93-
Text("Value: \(String(format: "%.02f", sliderValue))")
87+
HStack {
88+
VStack {
89+
Text("Slider")
90+
Slider($sliderValue, minimum: 0, maximum: 10)
91+
.frame(maxWidth: 200)
92+
.focusable(isSliderFocusable)
93+
Text("Value: \(String(format: "%.02f", sliderValue))")
94+
}
95+
Toggle("focusable", active: $isSliderFocusable)
96+
.focusable(false)
9497
}
95-
Toggle("focusable", active: $isSliderFocusable)
96-
.focusable(false)
97-
}
9898
#endif
9999
HStack {
100100
VStack {
@@ -106,24 +106,27 @@ struct ControlsFocusabilityApp: App {
106106
Toggle("focusable", active: $isTextFieldFocusable)
107107
.focusable(false)
108108
}
109-
109+
110110
HStack {
111111
VStack {
112112
Text("Drop down")
113113
HStack {
114114
Text("Flavor: ")
115-
Picker(of: ["Vanilla", "Chocolate", "Strawberry"], selection: $flavor)
116-
.focusable(isPickerFocusable)
115+
Picker(
116+
of: ["Vanilla", "Chocolate", "Strawberry"],
117+
selection: $flavor
118+
)
119+
.focusable(isPickerFocusable)
117120
}
118121
Text("You chose: \(flavor ?? "Nothing yet!")")
119122
}
120123
Toggle("focusable", active: $isPickerFocusable)
121124
.focusable(false)
122125
}
123126
}
124-
.padding()
125-
.disabled(!enabled)
126-
127+
.padding()
128+
.disabled(!enabled)
129+
127130
Toggle(enabled ? "Disable all" : "Enable all", active: $enabled)
128131
.padding()
129132
.focusable(false)

Examples/Sources/ControlsExample/ControlsApp.swift

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,66 +31,68 @@ struct ControlsApp: App {
3131
Text("Count: \(count)")
3232
}
3333
.padding(.bottom, 20)
34-
35-
#if !canImport(UIKitBackend)
36-
VStack {
37-
Text("Toggle button")
38-
Toggle("Toggle me!", active: $exampleButtonState)
39-
.toggleStyle(.button)
40-
Text("Currently enabled: \(exampleButtonState)")
41-
}
42-
.padding(.bottom, 20)
43-
#endif
44-
34+
35+
#if !canImport(UIKitBackend)
36+
VStack {
37+
Text("Toggle button")
38+
Toggle("Toggle me!", active: $exampleButtonState)
39+
.toggleStyle(.button)
40+
Text("Currently enabled: \(exampleButtonState)")
41+
}
42+
.padding(.bottom, 20)
43+
#endif
44+
4545
VStack {
4646
Text("Toggle switch")
4747
Toggle("Toggle me:", active: $exampleSwitchState)
4848
.toggleStyle(.switch)
4949
Text("Currently enabled: \(exampleSwitchState)")
5050
}
51-
52-
#if !canImport(UIKitBackend)
53-
VStack {
54-
Text("Checkbox")
55-
Toggle("Toggle me:", active: $exampleCheckboxState)
56-
.toggleStyle(.checkbox)
57-
Text("Currently enabled: \(exampleCheckboxState)")
58-
}
59-
#endif
60-
#if !os(tvOS)
61-
VStack {
62-
Text("Slider")
63-
Slider($sliderValue, minimum: 0, maximum: 10)
64-
.frame(maxWidth: 200)
65-
Text("Value: \(String(format: "%.02f", sliderValue))")
66-
}
67-
#endif
68-
51+
52+
#if !canImport(UIKitBackend)
53+
VStack {
54+
Text("Checkbox")
55+
Toggle("Toggle me:", active: $exampleCheckboxState)
56+
.toggleStyle(.checkbox)
57+
Text("Currently enabled: \(exampleCheckboxState)")
58+
}
59+
#endif
60+
#if !os(tvOS)
61+
VStack {
62+
Text("Slider")
63+
Slider($sliderValue, minimum: 0, maximum: 10)
64+
.frame(maxWidth: 200)
65+
Text("Value: \(String(format: "%.02f", sliderValue))")
66+
}
67+
#endif
68+
6969
VStack {
7070
Text("Text field")
7171
TextField("Text field", text: $text)
7272
Text("Value: \(text)")
7373
}
74-
74+
7575
VStack {
7676
Text("Drop down")
7777
HStack {
7878
Text("Flavor: ")
79-
Picker(of: ["Vanilla", "Chocolate", "Strawberry"], selection: $flavor)
79+
Picker(
80+
of: ["Vanilla", "Chocolate", "Strawberry"], selection: $flavor)
8081
}
8182
Text("You chose: \(flavor ?? "Nothing yet!")")
8283
}
8384
}
84-
.padding()
85-
.disabled(!enabled)
86-
.focusable(isFocusable)
87-
85+
.padding()
86+
.disabled(!enabled)
87+
.focusable(isFocusable)
88+
8889
Toggle(enabled ? "Disable all" : "Enable all", active: $enabled)
8990
.padding()
9091
.focusable(isFocusable)
91-
92+
9293
Toggle(
93-
isFocusable ? "Disable focusability for all" : "Enable focusability for all",
94+
isFocusable
95+
? "Disable focusability for all" : "Enable focusability for all",
9496
active: $isFocusable
9597
)
9698
.padding()

Sources/Gtk/Widgets/Widget.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ open class Widget: GObject {
131131

132132
/// Set to -1 for no min height request
133133
@GObjectProperty(named: "height-request") public var minHeight: Int
134-
134+
135135
/// Wether a Widget is focusable
136136
public var focusable: Bool {
137137
get {

Sources/GtkBackend/GtkBackend.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ public final class GtkBackend: AppBackend {
879879
onSubmit()
880880
}
881881
textField.focusable = environment.isFocusable
882-
882+
883883
textField.css.clear()
884884
textField.css.set(properties: Self.cssProperties(for: environment, isControl: true))
885885
}

Sources/UIKitBackend/UIKitBackend+Control.swift

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import UIKit
33

44
final class ButtonWidget: WrapperWidget<UIButton> {
55
private let event: UIControl.Event
6-
6+
77
var canBeFocused: Bool = true
8-
8+
99
override var canBecomeFocused: Bool {
1010
canBeFocused
1111
}
12-
12+
1313
var onTap: (() -> Void)? {
1414
didSet {
1515
if oldValue == nil {
@@ -39,9 +39,9 @@ final class ButtonWidget: WrapperWidget<UIButton> {
3939
final class TextFieldWidget: WrapperWidget<UITextField>, UITextFieldDelegate {
4040
var onChange: ((String) -> Void)?
4141
var onSubmit: (() -> Void)?
42-
42+
4343
var canBeFocused: Bool = true
44-
44+
4545
override var canBecomeFocused: Bool {
4646
canBeFocused
4747
}
@@ -71,9 +71,9 @@ final class TextFieldWidget: WrapperWidget<UITextField>, UITextFieldDelegate {
7171

7272
final class TextEditorWidget: WrapperWidget<UITextView>, UITextViewDelegate {
7373
var onChange: ((String) -> Void)?
74-
74+
7575
var canBeFocused: Bool = true
76-
76+
7777
override var canBecomeFocused: Bool {
7878
canBeFocused
7979
}
@@ -91,9 +91,9 @@ final class TextEditorWidget: WrapperWidget<UITextView>, UITextViewDelegate {
9191
#if os(tvOS)
9292
final class SwitchWidget: WrapperWidget<UISegmentedControl> {
9393
var onChange: ((Bool) -> Void)?
94-
94+
9595
var canBeFocused: Bool = true
96-
96+
9797
override var canBecomeFocused: Bool {
9898
canBeFocused
9999
}
@@ -121,13 +121,13 @@ final class TextEditorWidget: WrapperWidget<UITextView>, UITextViewDelegate {
121121
#else
122122
final class SwitchWidget: WrapperWidget<UISwitch> {
123123
var onChange: ((Bool) -> Void)?
124-
124+
125125
var canBeFocused: Bool = true
126-
126+
127127
override var canBecomeFocused: Bool {
128128
canBeFocused
129129
}
130-
130+
131131
@objc
132132
func switchFlipped() {
133133
onChange?(child.isOn)
@@ -232,9 +232,9 @@ final class HoverableWidget: ContainerWidget {
232232
@available(tvOS, unavailable)
233233
final class SliderWidget: WrapperWidget<UISlider> {
234234
var onChange: ((Double) -> Void)?
235-
235+
236236
var canBeFocused: Bool = true
237-
237+
238238
override var canBecomeFocused: Bool {
239239
canBeFocused
240240
}
@@ -300,9 +300,9 @@ extension UIKitBackend {
300300
action: @escaping () -> Void
301301
) {
302302
let buttonWidget = button as! ButtonWidget
303-
303+
304304
setButtonTitle(buttonWidget, label, environment: environment)
305-
305+
306306
buttonWidget.onTap = action
307307
buttonWidget.child.isEnabled = environment.isEnabled
308308
buttonWidget.canBeFocused = environment.isFocusable

0 commit comments

Comments
 (0)