Allow non-consecutive state variables (#191)
* Fix error when state variables are non-consecutive * Update one of the demos to cause it to fail without the fix
This commit is contained in:
parent
ffa686c7dc
commit
314a6f3a5a
|
@ -112,9 +112,11 @@ public final class StackReconciler<R: Renderer> {
|
|||
|
||||
let needsSubscriptions = compositeView.subscriptions.isEmpty
|
||||
|
||||
for (id, property) in info.properties.enumerated() {
|
||||
var stateIdx = 0
|
||||
for property in info.properties {
|
||||
if property.type is ValueStorage.Type {
|
||||
setupState(id: id, for: property, of: compositeView)
|
||||
setupState(id: stateIdx, for: property, of: compositeView)
|
||||
stateIdx += 1
|
||||
} else if needsSubscriptions && property.type is ObservedProperty.Type {
|
||||
setupSubscription(for: property, of: compositeView)
|
||||
}
|
||||
|
|
|
@ -40,12 +40,6 @@ public struct ColorDemo: View {
|
|||
case rgb, hsb
|
||||
}
|
||||
|
||||
@State private var colorForm: ColorForm = .hsb
|
||||
|
||||
@State private var v0: String = "0.9"
|
||||
@State private var v1: String = "1"
|
||||
@State private var v2: String = "0.5"
|
||||
|
||||
let colors: [Color] = [
|
||||
.clear,
|
||||
.black,
|
||||
|
@ -62,6 +56,12 @@ public struct ColorDemo: View {
|
|||
.secondary,
|
||||
]
|
||||
|
||||
@State private var colorForm: ColorForm = .hsb
|
||||
|
||||
@State private var v0: String = "0.9"
|
||||
@State private var v1: String = "1"
|
||||
@State private var v2: String = "0.5"
|
||||
|
||||
public var body: some View {
|
||||
VStack {
|
||||
Button("Input \(colorForm.rawValue.uppercased())") {
|
||||
|
|
Loading…
Reference in New Issue