Skip to content

Commit ac37db0

Browse files
committed
Made it work for non identifiables
StressTestExample is broken
1 parent 390d2b5 commit ac37db0

File tree

6 files changed

+207
-98
lines changed

6 files changed

+207
-98
lines changed

Examples/Sources/ControlsExample/ControlsApp.swift

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -81,47 +81,54 @@ struct ControlsApp: App {
8181
Text("Value: \(text)")
8282
}
8383

84-
VStack {
85-
Text("Drop down")
86-
HStack {
87-
Text("Flavor: ")
88-
Picker(of: ["Vanilla", "Chocolate", "Strawberry"], selection: $flavor)
89-
Toggle("Enable ProgressView resizability", active: $isProgressViewResizable)
90-
Slider($progressViewSize, minimum: 10, maximum: 100)
91-
Button("Randomize progress view size") {
92-
progressViewSize = Int.random(in: 10...100)
93-
}
94-
ProgressView()
95-
.resizable(isProgressViewResizable)
96-
.frame(width: progressViewSize, height: progressViewSize)
97-
9884
VStack {
9985
Text("Drop down")
10086
HStack {
10187
Text("Flavor: ")
10288
Picker(
10389
of: ["Vanilla", "Chocolate", "Strawberry"], selection: $flavor)
90+
Toggle(
91+
"Enable ProgressView resizability",
92+
active: $isProgressViewResizable)
93+
Slider($progressViewSize, minimum: 10, maximum: 100)
94+
Button("Randomize progress view size") {
95+
progressViewSize = Int.random(in: 10...100)
96+
}
97+
ProgressView()
98+
.resizable(isProgressViewResizable)
99+
.frame(width: progressViewSize, height: progressViewSize)
100+
101+
VStack {
102+
Text("Drop down")
103+
HStack {
104+
Text("Flavor: ")
105+
Picker(
106+
of: ["Vanilla", "Chocolate", "Strawberry"],
107+
selection: $flavor)
108+
}
109+
Text("You chose: \(flavor ?? "Nothing yet!")")
110+
}
104111
}
105-
Text("You chose: \(flavor ?? "Nothing yet!")")
106-
}
107-
}
108-
.padding()
109-
.disabled(!enabled)
110-
.focusable(isFocusable)
112+
.padding()
113+
.disabled(!enabled)
114+
.focusable(isFocusable)
111115

112-
Toggle(enabled ? "Disable all" : "Enable all", active: $enabled)
113-
.padding()
114-
.focusable(isFocusable)
116+
Toggle(enabled ? "Disable all" : "Enable all", active: $enabled)
117+
.padding()
118+
.focusable(isFocusable)
115119

116-
Toggle(
117-
isFocusable
118-
? "Disable focusability for all" : "Enable focusability for all",
119-
active: $isFocusable
120-
)
121-
.padding()
122-
.focusable(isFocusable)
120+
Toggle(
121+
isFocusable
122+
? "Disable focusability for all"
123+
: "Enable focusability for all",
124+
active: $isFocusable
125+
)
126+
.padding()
127+
.focusable(isFocusable)
128+
}
129+
.frame(minHeight: 600)
130+
}
123131
}
124-
.frame(minHeight: 600)
125132
}
126133
}.defaultSize(width: 400, height: 600)
127134
}

Sources/SwiftCrossUI/Builders/MenuItemsBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public struct MenuItemsBuilder {
1818
}
1919

2020
public static func buildPartialBlock<Items: Collection>(
21-
first: ForEach<Items, [MenuItem]>
21+
first: ForEach<Items, MenuItem, [MenuItem]>
2222
) -> [MenuItem] {
2323
first.elements.map(first.child).flatMap { $0 }
2424
}
@@ -53,7 +53,7 @@ public struct MenuItemsBuilder {
5353

5454
public static func buildPartialBlock<Items: Collection>(
5555
accumulated: [MenuItem],
56-
next: ForEach<Items, [MenuItem]>
56+
next: ForEach<Items, MenuItem, [MenuItem]>
5757
) -> [MenuItem] {
5858
accumulated + buildPartialBlock(first: next)
5959
}

Sources/SwiftCrossUI/Views/Button.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Foundation
2+
13
/// A control that initiates an action.
24
public struct Button: Sendable {
35
/// The label to show on the button.

0 commit comments

Comments
 (0)