Refactor: results expose Element as a named field
Every component result type now names its element Element instead of embedding *ui.Element. The eleven element-plus-changed results (AccordionView, CarouselView, CollapsibleView, ImageViewerView, PaginationResult, StepsResult, SidebarResult, TabsResult, RatingParts, FileDropZoneParts, TransferParts) fold into ChoiceResult. Fixes four Gallery demos where .Width(...).Changed() read the element's flag instead of the component's: Accordion, MultiSelect, Cascader, TreeSelect. TestDataAccordionDemoLogsChange covers the Accordion.
This commit is contained in:
73 files changed
+163
-245
No files matched your search
+2
-11
@@ -37,17 +37,8 @@ type SidebarOptions struct {
|
||||
Width float32
|
||||
}
|
||||
|
||||
// SidebarResult is the built Sidebar.
|
||||
type SidebarResult struct {
|
||||
*ui.Element
|
||||
changed bool
|
||||
}
|
||||
|
||||
// Changed reports a new choice in this frame.
|
||||
func (r SidebarResult) Changed() bool { return r.changed }
|
||||
|
||||
// Sidebar is a source list choosing an item ID into *selected, built on MyGo's Sidebar.
|
||||
func Sidebar(c *ui.Context, selected *string, sections []SidebarSection, opts SidebarOptions) SidebarResult {
|
||||
func Sidebar(c *ui.Context, selected *string, sections []SidebarSection, opts SidebarOptions) ChoiceResult {
|
||||
k := Tokens(c)
|
||||
width := opts.Width
|
||||
if width == 0 {
|
||||
@@ -58,7 +49,7 @@ func Sidebar(c *ui.Context, selected *string, sections []SidebarSection, opts Si
|
||||
}
|
||||
wrap := ui.Column(c).Width(width).FillHeight().AlignItems(ui.Stretch).Shrink(0)
|
||||
closed := ui.Local(wrap, "closed", func() map[string]*bool { return map[string]*bool{} })
|
||||
res := SidebarResult{Element: wrap}
|
||||
res := ChoiceResult{Element: wrap}
|
||||
prev := *selected
|
||||
wrap.Children(func() {
|
||||
// MyGo draws icons in Accent: swap in readable state colors for the sidebar.
|
||||
|
||||
Reference in new issue
Block a user