Documentation ¶
Index ¶
- Constants
- func DisableLog()
- func UseLogger(logger slog.Logger)
- type Closable
- type GenericPageModal
- type MasterPage
- func (masterPage *MasterPage) ClearStackAndDisplay(newPage Page)
- func (masterPage *MasterPage) CloseAllPages()
- func (masterPage *MasterPage) CloseCurrentPage()
- func (masterPage *MasterPage) ClosePagesAfter(keepPageID string)
- func (masterPage *MasterPage) CurrentPage() Page
- func (masterPage *MasterPage) CurrentPageID() string
- func (masterPage *MasterPage) Display(newPage Page)
- type Modal
- type Page
- type PageNavigator
- type PageStack
- type SimpleWindowNavigator
- func (window *SimpleWindowNavigator) ClearStackAndDisplay(newPage Page)
- func (window *SimpleWindowNavigator) CloseAllPages()
- func (window *SimpleWindowNavigator) CloseCurrentPage()
- func (window *SimpleWindowNavigator) ClosePagesAfter(keepPageID string)
- func (window *SimpleWindowNavigator) CurrentPage() Page
- func (window *SimpleWindowNavigator) CurrentPageID() string
- func (window *SimpleWindowNavigator) DismissModal(modalID string)
- func (window *SimpleWindowNavigator) Display(newPage Page)
- func (window *SimpleWindowNavigator) Reload()
- func (window *SimpleWindowNavigator) ShowModal(modal Modal)
- func (window *SimpleWindowNavigator) TopModal() Modal
- type WidgetDisplayPage
- type WindowNavigator
Constants ¶
const WidgetDisplayPageID = "widgetdisplaypage"
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
Types ¶
type Closable ¶
type Closable interface { // OnClosed is called to indicate that a specific instance of a page or // modal has been dismissed and will no longer be displayed. OnClosed() }
Closable should be implemented by pages and modals that want to know when they are closed in order to perform some cleanup actions.
type GenericPageModal ¶
type GenericPageModal struct {
// contains filtered or unexported fields
}
GenericPageModal implements the ID() and OnAttachedToNavigator() methods required by most pages and modals. It also defines ParentNavigator() and ParentWindow() helper methods, to enable pages access the Navigator that displayed the page and the root WindowNavigator. Actual pages and modals may embed this struct and implement other methods as necessary.
func NewGenericPageModal ¶
func NewGenericPageModal(id string) *GenericPageModal
NewGenericPageModal returns an instance of a GenericPageModal.
func (*GenericPageModal) ID ¶
func (pageModal *GenericPageModal) ID() string
ID is a unique string that identifies this page or modal and may be used to differentiate this page or modal from other pages or modals. Part of the Page and Modal interfaces.
func (*GenericPageModal) OnAttachedToNavigator ¶
func (pageModal *GenericPageModal) OnAttachedToNavigator(parentNav PageNavigator)
OnAttachedToNavigator is called when navigation occurs; i.e. when this page or modal is pushed into the window's display. The navigator parameter is the PageNavigator or WindowNavigator object that is used to display this page or modal. OnAttachedToNavigator is called just before OnResume (for modals) and OnNavigatedTo (for pages). Part of the Page and Modal interfaces.
func (*GenericPageModal) ParentNavigator ¶
func (pageModal *GenericPageModal) ParentNavigator() PageNavigator
ParentNavigator is a helper method that returns the Navigator that pushed this content into display, which may be the WindowNavigator or any other page that implements the PageNavigator interface (e.g. a MasterPage). For modals, this is always the WindowNavigator.
func (*GenericPageModal) ParentWindow ¶
func (pageModal *GenericPageModal) ParentWindow() WindowNavigator
ParentWindow is a helper method that returns the Navigator that displayed this page or modal if it is a WindowNavigator, otherwise it recursively checks the parent navigators to find and return a WindowNavigator.
type MasterPage ¶
type MasterPage struct { *GenericPageModal // contains filtered or unexported fields }
MasterPage is a page that can display subpages. It is an extension of the GenericPageModal which provides access to the Window or PageNavigator that was used to display the MasterPage. The ParentNavigator of a MasterPage is typically set when the MasterPage is pushed into the display window by a WindowNavigator or a PageNavigator. MasterPage must be embedded by pages that want to display subpages. Those pages must satisfy the other methods of the Page interface that are not already satisfied by MasterPage.
func NewMasterPage ¶
func NewMasterPage(id string) *MasterPage
NewMasterPage returns an instance of MasterPage.
func (*MasterPage) ClearStackAndDisplay ¶
func (masterPage *MasterPage) ClearStackAndDisplay(newPage Page)
ClearStackAndDisplay dismisses all pages in the stack and displays the specified page. Part of the PageNavigator interface.
func (*MasterPage) CloseAllPages ¶
func (masterPage *MasterPage) CloseAllPages()
CloseAllPages dismisses all pages in the stack. Part of the PageNavigator interface.
func (*MasterPage) CloseCurrentPage ¶
func (masterPage *MasterPage) CloseCurrentPage()
CloseCurrentPage dismisses the page at the top of the stack and gets the next page ready for display. Part of the PageNavigator interface.
func (*MasterPage) ClosePagesAfter ¶
func (masterPage *MasterPage) ClosePagesAfter(keepPageID string)
ClosePagesAfter dismisses all pages from the top of the stack until (and excluding) the page with the specified ID. If no page is found with the provided ID, no page will be popped. The page with the specified ID will be displayed after the other pages are popped. Part of the PageNavigator interface.
func (*MasterPage) CurrentPage ¶
func (masterPage *MasterPage) CurrentPage() Page
CurrentPage returns the page that is at the top of the stack. Returns nil if the stack is empty. Part of the PageNavigator interface.
func (*MasterPage) CurrentPageID ¶
func (masterPage *MasterPage) CurrentPageID() string
CurrentPageID returns the ID of the current page or an empty string if no page is displayed. Part of the PageNavigator interface.
func (*MasterPage) Display ¶
func (masterPage *MasterPage) Display(newPage Page)
Display causes the specified page to be displayed on the parent window or page. All other instances of this same page will be closed and removed from the backstack. Part of the PageNavigator interface.
type Modal ¶
type Modal interface { // ID is a unique string that identifies the modal and may be used // to differentiate this modal from other modals. ID() string // or modal is pushed into the window's display. The navigator parameter is // the PageNavigator or WindowNavigator object that is used to display the // content. This is called just before OnResume() is called. OnAttachedToNavigator(navigator PageNavigator) // OnResume is called to initialize data and get UI elements ready to be // displayed. This is called just before Handle() and Layout() are called (in // that order). OnResume() // Handle is called just before Layout() to determine if any user // interaction recently occurred on the modal and may be used to update the // page's UI components shortly before they are displayed. Handle() // Layout draws the modal's UI components into the provided layout context // to be eventually drawn on screen. Layout(gtx layout.Context) layout.Dimensions // OnDismiss is called after the modal is dismissed. // NOTE: The modal may be re-displayed on the app's window, in which case // OnResume() will be called again. This method should not destroy UI // components unless they'll be recreated in the OnResume() method. OnDismiss() }
Modal defines methods that control the appearance and functionality of a modal displayed on a window.
type Page ¶
type Page interface { // ID is a unique string that identifies the page and may be used // to differentiate this page from other pages. ID() string // or modal is pushed into the window's display. The navigator parameter is // the PageNavigator or WindowNavigator object that is used to display the // content. This is called just before OnNavigatedTo() is called. OnAttachedToNavigator(navigator PageNavigator) // used to initialize page features that are only relevant when the page is // displayed. This is called just before HandleUserInteractions() and // Layout() are called (in that order). OnNavigatedTo() // HandleUserInteractions is called just before Layout() to determine // if any user interaction recently occurred on the page and may be // used to update the page's UI components shortly before they are // displayed. HandleUserInteractions() // Layout draws the page UI components into the provided layout context // to be eventually drawn on screen. Layout(layout.Context) layout.Dimensions // the displayed window. This method should ideally be used to disable // features that are irrelevant when the page is NOT displayed. // NOTE: The page may be re-displayed on the app's window, in which case // OnNavigatedTo() will be called again. This method should not destroy UI // components unless they'll be recreated in the OnNavigatedTo() method. OnNavigatedFrom() }
Page defines methods that control the appearance and functionality of UI components displayed on a window.
type PageNavigator ¶
type PageNavigator interface { // if the stack is empty. CurrentPage() Page // page is displayed. CurrentPageID() string // page. All other instances of this same page will be closed and removed // from the backstack. Display(page Page) // next page ready for display. CloseCurrentPage() // excluding) the page with the specified ID. If no page is found with the // provided ID, no page will be popped. The page with the specified ID will // be displayed after the other pages are popped. ClosePagesAfter(keepPageID string) // specified page. ClearStackAndDisplay(page Page) CloseAllPages() }
PageNavigator defines methods for navigating between pages in a window or a MasterPage.
type PageStack ¶
type PageStack struct {
// contains filtered or unexported fields
}
PageStack is a stack of pages that handles page data initialization and destruction when pages are added to/removed from the top of the stack. NOTE: This stack does not maintain duplicate instances of the same page.
func NewPageStack ¶
NewPageStack creates a new PageStack object.
func (*PageStack) Pop ¶
Pop removes the page at the top of the stack and gets the next page ready for display. The OnNavigatedFrom() and if supported, the OnClosed() methods of the page to be removed are called to signal that the page is removed from display and will never be re-displayed. An about-to-display signal is sent to the page that will be displayed next via the page.OnNavigatedTo() method.
func (*PageStack) PopAfter ¶
PopAfter removes all pages from the top of the stack until (and excluding) a specific page. The matcher parameter should return true for the page that should be excluded. If the matcher never matches a page to exclude, no page will be popped. If any page is popped, the page's OnNavigatedFrom() and if supported, the OnClosed() methods will be called to signal that the page has been removed from the display and will never be re-displayed. The page to be displayed will receive an about-to-display signal via the OnNavigatedTo() method.
func (*PageStack) PushAndNavigate ¶ added in v1.1.0
func (pageStack *PageStack) PushAndNavigate(newPage Page, navigator PageNavigator) bool
PushAndNavigate pushes the specified page to the top of the stack, removing all other instances of the same page from the stack and executes the OnNavigatedTo() method on the newPage while page.OnNavigatedFrom() is called on the current page to signal that the current page is no longer the displayed page.
func (*PageStack) Reset ¶
Reset pops all pages in the stack and creates a new stack with the specified pages as root. Each popped page's OnNavigatedFrom() and if supported, the OnClosed() methods will be called to signal that the page has been removed from the display and will never be re-displayed. If there are new pages to display, the top page is readied for display via the its OnNavigatedTo() method.
type SimpleWindowNavigator ¶
type SimpleWindowNavigator struct {
// contains filtered or unexported fields
}
SimpleWindowNavigator implements WindowNavigator using a PageStack for keeping track of displayed pages. If an instance of this WindowNavigator is used to display a Page or Modal, that Page or Modal will have this navigator as its Parent.
func NewSimpleWindowNavigator ¶
func NewSimpleWindowNavigator(reloadDisplayFn func()) *SimpleWindowNavigator
NewSimpleWindowNavigator creates an instance of a SimpleWindowNavigator.
func (*SimpleWindowNavigator) ClearStackAndDisplay ¶
func (window *SimpleWindowNavigator) ClearStackAndDisplay(newPage Page)
ClearStackAndDisplay dismisses all pages in the stack and displays the specified page. Part of the PageNavigator interface.
func (*SimpleWindowNavigator) CloseAllPages ¶
func (window *SimpleWindowNavigator) CloseAllPages()
CloseAllPages dismisses all pages in the stack. Part of the PageNavigator interface.
func (*SimpleWindowNavigator) CloseCurrentPage ¶
func (window *SimpleWindowNavigator) CloseCurrentPage()
CloseCurrentPage dismisses the page at the top of the stack and gets the next page ready for display. Part of the PageNavigator interface.
func (*SimpleWindowNavigator) ClosePagesAfter ¶
func (window *SimpleWindowNavigator) ClosePagesAfter(keepPageID string)
ClosePagesAfter dismisses all pages from the top of the stack until (and excluding) the page with the specified ID. If no page is found with the provided ID, no page will be popped. The page with the specified ID will be displayed after the other pages are popped. Part of the PageNavigator interface.
func (*SimpleWindowNavigator) CurrentPage ¶
func (window *SimpleWindowNavigator) CurrentPage() Page
CurrentPage returns the page that is at the top of the stack. Returns nil if the stack is empty. Part of the PageNavigator interface.
func (*SimpleWindowNavigator) CurrentPageID ¶
func (window *SimpleWindowNavigator) CurrentPageID() string
CurrentPageID returns the ID of the current page or an empty string if no page is displayed. Part of the PageNavigator interface.
func (*SimpleWindowNavigator) DismissModal ¶
func (window *SimpleWindowNavigator) DismissModal(modalID string)
DismissModal dismisses the modal with the specified ID, if it was previously displayed by this WindowNavigator. If there are more than 1 modal with the specified ID, only the top-most instance is dismissed. Part of the WindowNavigator interface.
func (*SimpleWindowNavigator) Display ¶
func (window *SimpleWindowNavigator) Display(newPage Page)
Display causes the specified page to be displayed on this window. All other instances of this same page will be closed and removed from the backstack. Part of the PageNavigator interface.
func (*SimpleWindowNavigator) Reload ¶
func (window *SimpleWindowNavigator) Reload()
Reload causes the entire window display to be reloaded. If a page is currently displayed, this will call the page's HandleUserInteractions() method. If a modal is displayed, the modal's Handle() method will also be called. Finally, the current page and modal's Layout() methods are called to render the entire window's display. Part of the WindowNavigator interface.
func (*SimpleWindowNavigator) ShowModal ¶
func (window *SimpleWindowNavigator) ShowModal(modal Modal)
ShowModal displays a modal over the current page. Any previously displayed modal will be hidden by this new modal. NOTE: Allows displaying multiple instances of the same modal. Part of the WindowNavigator interface.
func (*SimpleWindowNavigator) TopModal ¶
func (window *SimpleWindowNavigator) TopModal() Modal
TopModal returns the top-most modal in display or nil if there is no modal in display. Part of the WindowNavigator interface.
type WidgetDisplayPage ¶ added in v1.1.0
type WidgetDisplayPage struct { *GenericPageModal // contains filtered or unexported fields }
WidgetDisplayPage is a page that takes a widget to layout and does nothing more than displaying the widget.
func NewWidgetDisplayPage ¶ added in v1.1.0
func NewWidgetDisplayPage(widget layout.Widget) *WidgetDisplayPage
func (*WidgetDisplayPage) HandleUserInteractions ¶ added in v1.1.0
func (*WidgetDisplayPage) HandleUserInteractions()
HandleUserInteractions implements Page.
func (*WidgetDisplayPage) Layout ¶ added in v1.1.0
func (pg *WidgetDisplayPage) Layout(gtx layout.Context) layout.Dimensions
Layout implements Page.
func (*WidgetDisplayPage) OnNavigatedFrom ¶ added in v1.1.0
func (*WidgetDisplayPage) OnNavigatedFrom()
OnNavigatedFrom implements Page.
func (*WidgetDisplayPage) OnNavigatedTo ¶ added in v1.1.0
func (*WidgetDisplayPage) OnNavigatedTo()
OnNavigatedTo implements Page.
type WindowNavigator ¶
type WindowNavigator interface { PageNavigator // displayed modal will be hidden by this new modal. ShowModal(Modal) // previously displayed by this WindowNavigator. If there are more than 1 // modal with the specified ID, only the top-most instance is dismissed. DismissModal(modalID string) // modal in display. TopModal() Modal // currently displayed, this should call the page's HandleUserInteractions() // method. If a modal is displayed, the modal's Handle() method should also // be called. Finally, the current page and modal's Layout methods should be // called to render the entire window's display. Reload() }
WindowNavigator defines methods for page navigation, displaying modals and reloading the entire window display.