Fix view switcher not updating selection
This commit is contained in:
parent
4913c0a382
commit
8c50494c74
@ -65,7 +65,9 @@ public struct ViewSwitcher<Element>: AdwaitaWidget where Element: ViewSwitcherOp
|
||||
updateProperties: Bool,
|
||||
type: Data.Type
|
||||
) where Data: ViewRenderData {
|
||||
updateSwitcher(switcher: storage)
|
||||
if updateProperties {
|
||||
updateSwitcher(switcher: storage)
|
||||
}
|
||||
}
|
||||
|
||||
/// Update a view switcher's style and selection.
|
||||
@ -84,10 +86,8 @@ public struct ViewSwitcher<Element>: AdwaitaWidget where Element: ViewSwitcherOp
|
||||
wide ? ADW_VIEW_SWITCHER_POLICY_WIDE : ADW_VIEW_SWITCHER_POLICY_NARROW
|
||||
)
|
||||
}
|
||||
if (switcher.previousState as? Self)?.selectedElement.title != selectedElement.title {
|
||||
let stack = adw_view_switcher_get_stack(switcher.opaquePointer)
|
||||
adw_view_stack_set_visible_child_name(stack, selectedElement.title)
|
||||
}
|
||||
let adwStack = adw_view_switcher_get_stack(switcher.opaquePointer)
|
||||
adw_view_stack_set_visible_child_name(adwStack, selectedElement.title)
|
||||
switcher.previousState = self
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,8 @@ struct ViewSwitcherDemo: View {
|
||||
VStack {
|
||||
Text(selection.title)
|
||||
.padding()
|
||||
HStack {
|
||||
Button(bottom ? "Show Top Bar" : "Show Bottom Bar") {
|
||||
bottom.toggle()
|
||||
}
|
||||
Button(bottom ? "Show Top Bar" : "Show Bottom Bar") {
|
||||
bottom.toggle()
|
||||
}
|
||||
.halign(.center)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user