Documentation
¶
Overview ¶
Package mobile is the reusable phone shell: one widget that gives a scene the platform navigation, a large title or app bar, a bottom bar or rail, a FAB, a snackbar and safe-area layout.
It is deliberately a widget, not a layout helper, so QML and Go callers get the same thing:
Window {
MobileShell {
id: shell
title: "Portfolio"
style: "auto"
MobilePage { title: "Portfolio"; label: "Home"; icon: "grid"
ScrollView { ... }
}
}
}
The shell lays the active page out between the header and the navigation bar, applies the platform's safe-area insets, and switches pages when a destination is chosen. The application supplies pages and behaviour; it never positions the shell.
Index ¶
- func Preset(style Style, dark bool) string
- type Action
- type Options
- type Page
- type Shell
- func (s *Shell) AddChild(child meui.Widget)
- func (s *Shell) Back() bool
- func (s *Shell) Bind(w platform.Window, root *meui.Window)
- func (s *Shell) CompactWidth() float32
- func (s *Shell) ContentRect() graphics.Rect
- func (s *Shell) Current() int
- func (s *Shell) FABVisible() bool
- func (s *Shell) Insets() platform.Insets
- func (s *Shell) KeyboardAvoidance() bool
- func (s *Shell) KeyboardInset() float32
- func (s *Shell) PageCount() int
- func (s *Shell) Pages() []*Page
- func (s *Shell) Paint(canvas *graphics.Canvas, rect graphics.Rect)
- func (s *Shell) PanelAt(x, y float32) meui.Widget
- func (s *Shell) Relayout()
- func (s *Shell) RevealFocused() bool
- func (s *Shell) SafeArea() bool
- func (s *Shell) SetActions(actions []Action) *Shell
- func (s *Shell) SetAvatar(text string, onClick func()) *Shell
- func (s *Shell) SetBoundProperty(name string, value interface{})
- func (s *Shell) SetCompactWidth(width float32) *Shell
- func (s *Shell) SetFABLabel(label string) *Shell
- func (s *Shell) SetFABVisible(on bool) *Shell
- func (s *Shell) SetInsets(in platform.Insets) *Shell
- func (s *Shell) SetKeyboardAvoidance(on bool) *Shell
- func (s *Shell) SetRoot(root *meui.Window)
- func (s *Shell) SetSafeArea(on bool) *Shell
- func (s *Shell) SetStyle(style Style) *Shell
- func (s *Shell) SetSubtitle(subtitle string) *Shell
- func (s *Shell) SetTitle(title string) *Shell
- func (s *Shell) ShowActionSheet(header, message string, items []widgets.ActionSheetItem, onChoose func(string)) *widgets.ActionSheet
- func (s *Shell) ShowAlert(title, message string, actions []widgets.DialogAction, onAction func(string)) *widgets.AlertDialog
- func (s *Shell) ShowPage(i int)
- func (s *Shell) ShowSearch(placeholder string, results []widgets.SearchViewResult, onChoose func(string)) *widgets.SearchView
- func (s *Shell) ShowSheet(title, body string) *widgets.BottomSheet
- func (s *Shell) Snackbar() *widgets.Snackbar
- func (s *Shell) Style() Style
- func (s *Shell) Toast(text string)
- func (s *Shell) ValidateLayout()
- type Style
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
Action is one app-bar or large-title action. The large title shows at most three; the Android app bar can show all of them.
type Options ¶
type Options struct {
Style Style
Title string
Subtitle string
Actions []Action
FAB bool
Avatar string
}
New builds a shell with common options filled in.
type Page ¶
type Page struct {
meui.BaseContainer
Title string
Subtitle string
Label string
Icon string
OnShow func()
}
Page is one destination. Its content is the QML/Go child.
func NewPage ¶
NewPage builds an empty page. Label falls back to Title and Icon to "grid" when the destination list is built.
func (*Page) SetBoundProperty ¶
SetBoundProperty implements the QML binding hook.
func (*Page) SetVisible ¶
SetVisible propagates visibility to the content: QML often declares the scroll view with visible:false, and the shell owns page visibility.
func (*Page) ValidateLayout ¶
func (p *Page) ValidateLayout()
ValidateLayout makes the content fill the page.
type Shell ¶
type Shell struct {
meui.BaseContainer
// OnAction fires for an app-bar/large-title action.
OnAction func(string)
// OnAvatar fires when the large-title avatar is tapped.
OnAvatar func()
// OnPageChanged fires after a destination changes.
OnPageChanged func(int)
// OnLayout is called after every reflow, with the page viewport in page-local
// coordinates. Put inner card frames here.
OnLayout func(graphics.Rect)
// OnFAB fires when the floating button is tapped.
OnFAB func()
// OnBack runs before the shell's own back behaviour. Return true when the
// app handled the gesture; returning false lets the shell pop a page and,
// at the first page, lets the platform close the window.
OnBack func() bool
// contains filtered or unexported fields
}
Shell is the mobile scaffold. See the package comment for the QML shape.
func NewShell ¶
func NewShell() *Shell
NewShell builds an empty shell. QML calls this; Go callers normally use New.
func (*Shell) AddChild ¶
AddChild adds a MobilePage (or any other widget). Non-page children are tracked but not made destinations.
func (*Shell) Back ¶
Back moves to the previous destination and reports whether it did. Bind wires the window's back gesture to it when the root supports SetOnBack.
func (*Shell) Bind ¶
Bind attaches the shell to its platform window and its root. The root is the content window used for modals; the platform window supplies resize, insets and size. Call it after App.AddWindow.
func (*Shell) CompactWidth ¶ added in v0.2.1
CompactWidth reports the threshold.
func (*Shell) ContentRect ¶
ContentRect returns the page viewport in page-local coordinates.
func (*Shell) FABVisible ¶
FABVisible reports whether the floating button is shown.
func (*Shell) KeyboardAvoidance ¶
KeyboardAvoidance reports the setting.
func (*Shell) KeyboardInset ¶
KeyboardInset reports the keyboard height used by the last layout.
func (*Shell) RevealFocused ¶
RevealFocused scrolls the nearest ScrollPane ancestor of the focused widget so the widget is inside the visible height above the keyboard. It returns true when the scroll moved.
func (*Shell) SetActions ¶
SetActions replaces the header actions.
func (*Shell) SetBoundProperty ¶
SetBoundProperty implements the QML binding hook.
func (*Shell) SetCompactWidth ¶ added in v0.2.1
SetCompactWidth changes the width below which the bottom bar is used instead of the rail. The default is 700. Mobile hosts whose window units are physical pixels can raise it; a 1080px phone with density 2.75 is 393dp.
func (*Shell) SetFABLabel ¶
SetFABLabel sets the floating button's glyph.
func (*Shell) SetFABVisible ¶
SetFABVisible shows or hides the floating action button.
func (*Shell) SetKeyboardAvoidance ¶
SetKeyboardAvoidance controls whether the shell reserves the IME height. It is on by default: the navigation bar is lifted above the keyboard and the page viewport ends above it. Turn it off when the page intentionally paints behind the keyboard.
func (*Shell) SetRoot ¶
SetRoot attaches the modal root without a platform window. Shot harnesses use it before showing an overlay; Bind also sets it.
func (*Shell) SetSafeArea ¶ added in v0.2.1
SetSafeArea controls whether the shell subtracts the platform's top/right/ bottom/left insets. It is on by default for headless layouts. Bind turns it off automatically when the content root is already the safe-area rectangle, which is what the Android adapter paints; applying the insets twice is what made a 1080px phone look like a double-inset tablet.
func (*Shell) SetStyle ¶
SetStyle sets the shell idiom. Normally called by QML before the first layout.
func (*Shell) SetSubtitle ¶
SetSubtitle sets the fallback subtitle.
func (*Shell) ShowActionSheet ¶
func (s *Shell) ShowActionSheet(header, message string, items []widgets.ActionSheetItem, onChoose func(string)) *widgets.ActionSheet
ShowActionSheet opens an action sheet and reports choices through onChoose.
func (*Shell) ShowAlert ¶
func (s *Shell) ShowAlert(title, message string, actions []widgets.DialogAction, onAction func(string)) *widgets.AlertDialog
ShowAlert opens the adaptive alert dialog.
func (*Shell) ShowSearch ¶
func (s *Shell) ShowSearch(placeholder string, results []widgets.SearchViewResult, onChoose func(string)) *widgets.SearchView
ShowSearch opens a full-screen search view.
func (*Shell) ShowSheet ¶
func (s *Shell) ShowSheet(title, body string) *widgets.BottomSheet
ShowSheet opens a bottom sheet with a wrapped body. It returns the widget so a caller can set OnDismissed.
func (*Shell) ValidateLayout ¶
func (s *Shell) ValidateLayout()
ValidateLayout places the chrome, the pages and the overlays. It is called by the window after every resize and by Relayout.