Skip to main content

WebView

Struct WebView 

Source
pub struct WebView { /* private fields */ }

Implementations§

Source§

impl WebView

Source

pub fn renderer( self, renderer: WebRenderer, ) -> Result<Self, RendererUnavailable>

Select an engine for this context, failing instead of falling back silently. Rebuild the piece at its current URL to switch an existing page’s renderer.

§Errors

Returns RendererUnavailable when this build does not include renderer.

Source

pub fn profile(self, profile: WebProfile) -> Self

Share cookies, local storage, cache and engine site data with other views using this profile.

Source

pub fn url_binding(self, url: impl Binding<String>) -> Self

Bind the actual page URL, including native navigation reports, to application state. Useful for an address bar on bundled/resource views. Notify .go() to load the value.

Source

pub fn page_state(self, state: impl Binding<PageState>) -> Self

Keep state current with the page’s URL, title, load progress and history, as the engine reports them (see PageState). The view writes the binding; the app reads it to drive a title, a progress line, or Back/Forward buttons.

Reports are pushed by the engine’s own notifications, not polled, and those arriving within one frame (a burst of progress estimates) are coalesced into one write. The binding is only written when the state changed. web-dom’s iframe reports only the URL and title of same-origin frames after each load.

Source

pub fn scroll_state(self, state: impl Binding<ScrollState>) -> Self

Keep state current with where the page is scrolled (see ScrollState): what a browser’s chrome reads to slide its bars away as the user scrolls down, the way Safari and Chrome do on a phone. Reports arriving within one frame are coalesced into one write.

Reported on iOS (the web view’s scroll view) and Android (the view’s scroll listener), the platforms whose browsers hide their bars; elsewhere the binding keeps its value.

Source

pub fn resources(self, provider: ResourceProvider) -> Self

Serve provider’s namespace in this view, which otherwise browses like any remote view: it navigates anywhere, reports URLs, opens new tabs, and keeps its history across provider pages and remote ones. Pages are reached at ResourceProvider::url (or under ResourceProvider::base_url); a query reaches the handler as ResourceRequest::query.

web_view_resources is the other shape: a view confined to the provider’s site, whose links out of it go through WebView::on_external_link. A provider given here replaces any provider the view already had.

Source

pub fn on_load(self, callback: impl Fn() + 'static) -> Self

Called on the UI thread after the backend reports a completed navigation. Useful for applying the latest presentation state through JsHandle, including same-URL reloads. Available on native backends that report navigation; not on emulated iframe hosts.

Source

pub fn go(self, trigger: Trigger) -> Self

Load the current value of the bound url whenever trigger fires.

Source

pub fn back(self, trigger: Trigger) -> Self

Navigate back in history whenever trigger fires.

Source

pub fn forward(self, trigger: Trigger) -> Self

Navigate forward in history whenever trigger fires.

Source

pub fn stop(self, trigger: Trigger) -> Self

Stop the current load whenever trigger fires.

Source

pub fn reload(self, trigger: Trigger) -> Self

Reload the current page whenever trigger fires.

Source

pub fn force_reload(self, trigger: Trigger) -> Self

Reload from the server, bypassing cached resources. Check force_reload_support.

Source

pub fn js(self, handle: JsHandle) -> Self

Bind a JsHandle so handle.eval(…) runs in this view (docs/webview-eval.md).

Source

pub fn session(self, session: WebSession) -> Self

Show a retained WebSession, so the loaded page survives navigating away and back.

Source

pub fn start_page(self, page: impl Into<String>) -> Self

Inline mode only: the page within the site to open first, instead of index.html. A query or fragment is part of the page ("player.html?src=hello"), and the site reads it back through location.search / location.hash as it would on a server.

Source

pub fn app_assets(self) -> Self

Inline mode only: let the site read the app’s whole resource/assets/ tree, not just its own directory.

A self-contained site needs nothing here. Ask for it when the page’s job is to show the app’s own files — a player, a viewer, a renderer — because those files live in the app’s asset namespace and the site’s relative URLs have to reach them (day-piece-lottie’s player is this: one page, any of the app’s animations).

Source

pub fn transparent(self) -> Self

Draw no background of the view’s own: where the page’s own background is transparent, the app shows through, the way an image with an alpha channel sits on whatever is behind it.

What a web view is for here is content that belongs to the app’s own surface (an animation player, a rendered diagram, a badge), where the view’s usual white sheet reads as a hole in the window. A page that sets a background of its own still draws it. Every arm honors it (docs/webview.md “A transparent view”).

Source

pub fn zoom<M>(self, factor: impl IntoReactive<f64, M>) -> Self

Zoom the page by factor, 1.0 being 100%: a constant, a signal or a closure. The engine keeps the factor as the view navigates, the way a browser’s zoom control does, and a change applies to the page on screen at once. Factors are clamped to WebSettings::ZOOM_RANGE. Check zoom_support: Android and ArkWeb scale text, and web-dom zooms same-origin pages only (docs/webview.md).

Source

pub fn desktop_mode<M>(self, desktop: impl IntoReactive<bool, M>) -> Self

Ask sites for the layout they serve a desktop browser, like Safari’s “Request Desktop Website” and Chrome’s “Desktop site”. When the value changes, the view reloads its page so the site can answer. false leaves the engine’s choice, which is already the desktop layout on a Mac, an iPad and every desktop toolkit. Check desktop_mode_support.

Source

pub fn javascript<M>(self, enabled: impl IntoReactive<bool, M>) -> Self

Let pages run their scripts (true, the default) or stop them. When the value changes, the view reloads its page, because a page cannot lose or gain its scripts while it runs.

The app’s own evaluation (JsHandle::eval) keeps working with page scripts off on the WebKit, WebKitGTK, Qt, WebView2 and ArkWeb engines. Android WebView and web-dom have no such split: there, evaluation fails until scripts are on again. Check javascript_support and docs/webview.md.

Source

pub fn request_filter(self, filter: Arc<dyn RequestFilter>) -> Self

Ask filter about every request the view’s pages make, before it leaves the device (docs/webview.md, “Content blocking and page scripts”). A RequestDecision::Block fails the request; WebView::on_blocked hears about it.

Runs on the engine’s own thread: a WebView worker on Android, the UI thread on WebView2 and Qt, ArkWeb’s IO thread. Check request_filter_support: WebKit engines have no per-request hook and take WebView::content_rules instead.

Source

pub fn on_blocked(self, f: impl Fn(&[BlockedLoad]) + 'static) -> Self

Hear about the requests WebView::request_filter blocked, on the UI thread, in batches: at most one call every 100 ms, holding every load blocked since the last one.

Source

pub fn content_rules<M>( self, lists: impl IntoReactive<Vec<ContentRuleList>, M>, ) -> Self

Block and hide content with WebKit content rule lists: a constant, a signal or a closure. Each list is compiled once, off the UI thread, and kept compiled across launches under its id and version; a change swaps the view’s lists once the new ones are ready. A view built with lists holds its first page until they are attached. Check content_rules_support: only the WebKit engines apply them.

Source

pub fn on_content_rules_error( self, f: impl Fn(&ContentRulesError) + 'static, ) -> Self

Hear about a content rule list that failed to compile (it is also logged). The other lists still apply.

Source

pub fn user_script(self, script: UserScript) -> Self

Run script in every page the view loads, in the page’s own JavaScript world. Call it again for more; they run in the order added. Check user_script_support.

Source

pub fn user_style(self, css: impl Into<Arc<str>>) -> Self

Apply css to every page and frame the view loads, as a user style sheet where the engine has one (WebKitGTK) and as a <style> element added at document start elsewhere.

Source

pub fn on_script_message( self, name: impl Into<String>, handler: impl Fn(ScriptMessage) -> Option<String> + 'static, ) -> Self

Answer page messages posted to name: a page calls window.dayMessage(name, text) and gets a promise of the handler’s reply (null for None). The handler runs on the UI thread. Any frame can post, third-party ones included: treat ScriptMessage::payload as untrusted input. Check script_message_support.

Source

pub fn on_media_request( self, f: impl Fn(&MediaRequest) -> bool + 'static, ) -> Self

Decide whether a page may use the camera or microphone (getUserMedia). Android only asks this: without it, a page gets what the app itself may use, the system asking the user once for a permission the app declares but does not hold yet. The other engines ask the user themselves.

Source

pub fn on_new_tab<M1, M2>( self, foreground_label: impl IntoText<M1>, background_label: impl IntoText<M2>, f: impl Fn(&NewTabRequest) + 'static, ) -> Self

Decide what happens to a navigation that leaves an inline/resource site. On Apple backends, also opts ordinary documents into reporting user-activated links and new windows; initial loads, subframes and same-document fragments stay in view. Runs on the main thread with the target URL; without it every external link is LinkPolicy::OpenSystem. The closure may do arbitrary in-app work (navigate the day app, log) and return LinkPolicy::Ignore. Handle a request for a separate tab without replacing the source document. Labels must be localized by the application. Background requests preserve focus.

Decide what happens to a navigation whose address another program opens: mailto:, tel:, an app’s own scheme, Android’s intent:. The view never loads such an address; without this (and without WebView::on_external_link) each goes to the system, which is LinkPolicy::OpenSystem. A browser asks the user here before an unfamiliar scheme leaves for another app. LinkPolicy::InView is treated as LinkPolicy::Ignore.

Source

pub fn on_dialog( self, f: impl Fn(DialogRequest, DialogResponder) + 'static, ) -> Self

Answer a page’s alert(), confirm() and prompt(). The page’s script waits for the responder. Without this the view presents Day’s own dialogs, titled with the site that asked.

Source

pub fn on_auth(self, f: impl Fn(AuthRequest, AuthResponder) + 'static) -> Self

Answer a server’s or proxy’s request for a name and password (HTTP Basic, Digest, NTLM). Without this the sign-in is canceled and the server’s “unauthorized” page loads.

Source

pub fn on_download( self, f: impl Fn(DownloadRequest, DownloadResponder) + 'static, ) -> Self

Take the files the engine offers to save rather than show. The handler names where a file goes (DownloadResponder::save_to) or declines it; without a handler nothing is downloaded. See download_support.

Source

pub fn on_load_error(self, f: impl Fn(&LoadError) + 'static) -> Self

Hear that a page did not load: no connection, no such server, an untrusted certificate. The view is left on whatever the engine shows for a failed load, so a browser covers it with its own error page until the next load starts.

Source

pub fn on_renderer_gone(self, f: impl Fn(&RendererGone) + 'static) -> Self

Hear that the process running this view’s page is gone. On Android the view is dead from then on and ignores every command: build a new one in its place. On Apple platforms the view survives and a reload brings the page back; without this handler WebKit views reload themselves.

Source

pub fn user_agent(self, user_agent: UserAgent) -> Self

What the view tells sites it is: the engine’s own string (the default), the platform browser’s (UserAgent::Browser, which a browser wants), or a string of the app’s. It is read when the view is created; build a new view to change it. WebKit and Android honor it, and a view in WebView::desktop_mode sends the desktop string instead.

Source

pub fn swipe_navigation(self, on: bool) -> Self

Swiping in from a screen edge goes back and forward through the view’s history (WebKit). Off unless asked for, since an app’s own navigation may own those edges.

Trait Implementations§

Source§

impl Piece for WebView

Source§

fn build(self, cx: &mut BuildCx) -> RNode

Source§

impl WebViewBuilder for WebView

Source§

fn profile(self, profile: WebProfile) -> Self

Share cookies, local storage, cache and engine site data with other views using this profile.
Source§

fn url_binding(self, url: impl Binding<String>) -> Self

Bind the actual page URL, including native navigation reports, to application state. Useful for an address bar on bundled/resource views. Notify .go() to load the value.
Source§

fn page_state(self, state: impl Binding<PageState>) -> Self

Keep state current with the page’s URL, title, load progress and history, as the engine reports them (see PageState). The view writes the binding; the app reads it to drive a title, a progress line, or Back/Forward buttons. Read more
Source§

fn scroll_state(self, state: impl Binding<ScrollState>) -> Self

Keep state current with where the page is scrolled (see ScrollState): what a browser’s chrome reads to slide its bars away as the user scrolls down, the way Safari and Chrome do on a phone. Reports arriving within one frame are coalesced into one write. Read more
Source§

fn resources(self, provider: ResourceProvider) -> Self

Serve provider’s namespace in this view, which otherwise browses like any remote view: it navigates anywhere, reports URLs, opens new tabs, and keeps its history across provider pages and remote ones. Pages are reached at ResourceProvider::url (or under ResourceProvider::base_url); a query reaches the handler as ResourceRequest::query. Read more
Source§

fn on_load(self, callback: impl Fn() + 'static) -> Self

Called on the UI thread after the backend reports a completed navigation. Useful for applying the latest presentation state through JsHandle, including same-URL reloads. Available on native backends that report navigation; not on emulated iframe hosts.
Source§

fn go(self, trigger: Trigger) -> Self

Load the current value of the bound url whenever trigger fires.
Source§

fn back(self, trigger: Trigger) -> Self

Navigate back in history whenever trigger fires.
Source§

fn forward(self, trigger: Trigger) -> Self

Navigate forward in history whenever trigger fires.
Source§

fn stop(self, trigger: Trigger) -> Self

Stop the current load whenever trigger fires.
Source§

fn reload(self, trigger: Trigger) -> Self

Reload the current page whenever trigger fires.
Source§

fn force_reload(self, trigger: Trigger) -> Self

Reload from the server, bypassing cached resources. Check force_reload_support.
Source§

fn js(self, handle: JsHandle) -> Self

Bind a JsHandle so handle.eval(…) runs in this view (docs/webview-eval.md).
Source§

fn session(self, session: WebSession) -> Self

Show a retained WebSession, so the loaded page survives navigating away and back.
Source§

fn start_page(self, page: impl Into<String>) -> Self

Inline mode only: the page within the site to open first, instead of index.html. A query or fragment is part of the page ("player.html?src=hello"), and the site reads it back through location.search / location.hash as it would on a server.
Source§

fn app_assets(self) -> Self

Inline mode only: let the site read the app’s whole resource/assets/ tree, not just its own directory. Read more
Source§

fn transparent(self) -> Self

Draw no background of the view’s own: where the page’s own background is transparent, the app shows through, the way an image with an alpha channel sits on whatever is behind it. Read more
Source§

fn zoom<M>(self, factor: impl IntoReactive<f64, M>) -> Self

Zoom the page by factor, 1.0 being 100%: a constant, a signal or a closure. The engine keeps the factor as the view navigates, the way a browser’s zoom control does, and a change applies to the page on screen at once. Factors are clamped to WebSettings::ZOOM_RANGE. Check zoom_support: Android and ArkWeb scale text, and web-dom zooms same-origin pages only (docs/webview.md).
Source§

fn desktop_mode<M>(self, desktop: impl IntoReactive<bool, M>) -> Self

Ask sites for the layout they serve a desktop browser, like Safari’s “Request Desktop Website” and Chrome’s “Desktop site”. When the value changes, the view reloads its page so the site can answer. false leaves the engine’s choice, which is already the desktop layout on a Mac, an iPad and every desktop toolkit. Check desktop_mode_support.
Source§

fn javascript<M>(self, enabled: impl IntoReactive<bool, M>) -> Self

Let pages run their scripts (true, the default) or stop them. When the value changes, the view reloads its page, because a page cannot lose or gain its scripts while it runs. Read more
Source§

fn request_filter(self, filter: Arc<dyn RequestFilter>) -> Self

Ask filter about every request the view’s pages make, before it leaves the device (docs/webview.md, “Content blocking and page scripts”). A RequestDecision::Block fails the request; WebView::on_blocked hears about it. Read more
Source§

fn on_blocked(self, f: impl Fn(&[BlockedLoad]) + 'static) -> Self

Hear about the requests WebView::request_filter blocked, on the UI thread, in batches: at most one call every 100 ms, holding every load blocked since the last one.
Source§

fn content_rules<M>( self, lists: impl IntoReactive<Vec<ContentRuleList>, M>, ) -> Self

Block and hide content with WebKit content rule lists: a constant, a signal or a closure. Each list is compiled once, off the UI thread, and kept compiled across launches under its id and version; a change swaps the view’s lists once the new ones are ready. A view built with lists holds its first page until they are attached. Check content_rules_support: only the WebKit engines apply them.
Source§

fn on_content_rules_error( self, f: impl Fn(&ContentRulesError) + 'static, ) -> Self

Hear about a content rule list that failed to compile (it is also logged). The other lists still apply.
Source§

fn user_script(self, script: UserScript) -> Self

Run script in every page the view loads, in the page’s own JavaScript world. Call it again for more; they run in the order added. Check user_script_support.
Source§

fn user_style(self, css: impl Into<Arc<str>>) -> Self

Apply css to every page and frame the view loads, as a user style sheet where the engine has one (WebKitGTK) and as a <style> element added at document start elsewhere.
Source§

fn on_script_message( self, name: impl Into<String>, handler: impl Fn(ScriptMessage) -> Option<String> + 'static, ) -> Self

Answer page messages posted to name: a page calls window.dayMessage(name, text) and gets a promise of the handler’s reply (null for None). The handler runs on the UI thread. Any frame can post, third-party ones included: treat ScriptMessage::payload as untrusted input. Check script_message_support.
Source§

fn on_media_request(self, f: impl Fn(&MediaRequest) -> bool + 'static) -> Self

Decide whether a page may use the camera or microphone (getUserMedia). Android only asks this: without it, a page gets what the app itself may use, the system asking the user once for a permission the app declares but does not hold yet. The other engines ask the user themselves.
Source§

fn on_new_tab<M1, M2>( self, foreground_label: impl IntoText<M1>, background_label: impl IntoText<M2>, f: impl Fn(&NewTabRequest) + 'static, ) -> Self

Decide what happens to a navigation that leaves an inline/resource site. On Apple backends, also opts ordinary documents into reporting user-activated links and new windows; initial loads, subframes and same-document fragments stay in view. Runs on the main thread with the target URL; without it every external link is LinkPolicy::OpenSystem. The closure may do arbitrary in-app work (navigate the day app, log) and return LinkPolicy::Ignore. Handle a request for a separate tab without replacing the source document. Labels must be localized by the application. Background requests preserve focus.
Decide what happens to a navigation whose address another program opens: mailto:, tel:, an app’s own scheme, Android’s intent:. The view never loads such an address; without this (and without WebView::on_external_link) each goes to the system, which is LinkPolicy::OpenSystem. A browser asks the user here before an unfamiliar scheme leaves for another app. LinkPolicy::InView is treated as LinkPolicy::Ignore.
Source§

fn on_dialog(self, f: impl Fn(DialogRequest, DialogResponder) + 'static) -> Self

Answer a page’s alert(), confirm() and prompt(). The page’s script waits for the responder. Without this the view presents Day’s own dialogs, titled with the site that asked.
Source§

fn on_auth(self, f: impl Fn(AuthRequest, AuthResponder) + 'static) -> Self

Answer a server’s or proxy’s request for a name and password (HTTP Basic, Digest, NTLM). Without this the sign-in is canceled and the server’s “unauthorized” page loads.
Source§

fn on_download( self, f: impl Fn(DownloadRequest, DownloadResponder) + 'static, ) -> Self

Take the files the engine offers to save rather than show. The handler names where a file goes (DownloadResponder::save_to) or declines it; without a handler nothing is downloaded. See download_support.
Source§

fn on_load_error(self, f: impl Fn(&LoadError) + 'static) -> Self

Hear that a page did not load: no connection, no such server, an untrusted certificate. The view is left on whatever the engine shows for a failed load, so a browser covers it with its own error page until the next load starts.
Source§

fn on_renderer_gone(self, f: impl Fn(&RendererGone) + 'static) -> Self

Hear that the process running this view’s page is gone. On Android the view is dead from then on and ignores every command: build a new one in its place. On Apple platforms the view survives and a reload brings the page back; without this handler WebKit views reload themselves.
Source§

fn user_agent(self, user_agent: UserAgent) -> Self

What the view tells sites it is: the engine’s own string (the default), the platform browser’s (UserAgent::Browser, which a browser wants), or a string of the app’s. It is read when the view is created; build a new view to change it. WebKit and Android honor it, and a view in WebView::desktop_mode sends the desktop string instead.
Source§

fn swipe_navigation(self, on: bool) -> Self

Swiping in from a screen edge goes back and forward through the view’s history (WebKit). Off unless asked for, since an app’s own navigation may own those edges.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<P> Decorate for P
where P: Piece,

Source§

fn id(self, id: ElementId) -> Decorated<Self>

Stable element identifier: a11y identifier + dayscript locator + lint uniqueness (§5.5). Read more
Source§

fn wrapper_id(self, id: ElementId) -> Decorated<Self>

Name the node that is outermost at this point in the chain: the padding box, the frame, the background, whichever wrapper the modifiers before it built. For a dayscript frame assertion on the wrapper rather than on the piece. Ordered, unlike id.
Source§

fn apply_if( self, cond: bool, f: impl FnOnce(Decorated<Self>) -> Decorated<Self>, ) -> Decorated<Self>

Apply f to the chain when cond holds, else continue unchanged (see Decorated::apply_if): nav(sel).apply_if(!primary, |n| n.local()). The closure receives the decorated piece, so forwarded builder methods and modifiers both chain inside it.
Source§

fn apply_some<T>( self, value: Option<T>, f: impl FnOnce(Decorated<Self>, T) -> Decorated<Self>, ) -> Decorated<Self>

Apply f with the value when there is one, else continue unchanged (see Decorated::apply_some): canvas(draw).apply_some(id, |c, id| c.id(id)).
Source§

fn id_of(self, id: impl Fn() -> ElementId + 'static) -> Decorated<Self>

Reactive element id: the id for rows inside a recycling list. A plain id is assigned once at build, but a recycled cell rebinds to different items over its life (and drag-to-reorder rebinds eagerly), so a static item-derived id keeps naming the first-bound item. This variant re-registers whenever the closure’s value changes; read your ItemSlot inside it: .id_of(move || day_core::id!(row_remove, slot.key())).
Source§

fn tweak(self, f: impl FnOnce(RNode) + 'static) -> Decorated<Self>

Apply a tweak: f runs once at mount, after the native widget exists, with the realized node (docs/tweaks.md). Reach the typed native handle through the compiled backend’s ext accessor (day_toolkit_appkit::with_native, day_toolkit_gtk::with_native, …), or apply a packaged day-tweak-* crate’s modifier instead of calling this directly. If the native change affects the widget’s intrinsic size, follow it with day_core::invalidate_size. Day may overwrite managed properties (title, value, enabled, frame, a11y) on its next patch; unmanaged properties are stable. Read more
Source§

fn selectable(self) -> Decorated<Self>

Make this piece’s text user-selectable, so the reader can select and copy it (docs/text.md). Most useful on a label: text is not selectable by default on any backend, matching each platform’s native behavior. Read more
Source§

fn cursor<M>(self, cursor: impl IntoReactive<Cursor, M>) -> Decorated<Self>

Shape the pointer while it is over this piece and its descendants (docs/cursor.md): a Cursor constant, a Signal<Cursor>, or a closure, so a canvas tool or a busy state moves the shape without rebuilding the piece. The nearest ancestor’s cursor wins, and Cursor::Default releases the piece back to the platform. capability(Cap::Cursor) says whether this toolkit draws the requested shapes, a nearest neighbor, or nothing; a touch-only host never shows one, which is correct rather than a failure.
Source§

fn window_drag_region(self) -> Decorated<Self>

Let the user move the window by dragging this piece, as a title bar does (docs/window-chrome.md): what a custom title bar in a WindowChrome::Overlay or WindowChrome::Frameless window needs. The piece’s own background starts the drag, with the platform’s snapping and tiling; buttons and fields inside it keep their clicks; a double click does what the user’s title-bar setting says (zoom, minimize, nothing). capability(Cap::DragRegion); on a phone the piece is an ordinary view.
Source§

fn native_ref(self, r: &NativeRef) -> Decorated<Self>

Capture a NativeRef to this piece’s realized node for later imperative access (docs/tweaks.md). The ref clears automatically when the piece’s scope is disposed.
Source§

fn padding(self, insets: impl IntoInsets) -> Decorated<Self>

Source§

fn max_width(self, max: f64) -> Decorated<Self>

Cap this piece’s width at max points: the child is never PROPOSED more, so text wraps inside the cap (chat bubbles, readable columns) while narrower content hugs.
Source§

fn max_height(self, max: f64) -> Decorated<Self>

Cap this piece’s height at max points, the vertical twin of Decorate::max_width: a scroll or another piece that takes the height it is offered stops at max, and still gets less where its parent has less to give.
Source§

fn min_width(self, min: f64) -> Decorated<Self>

Source§

fn min_height(self, min: f64) -> Decorated<Self>

Keep at least min points of height, expanding for taller content.
Source§

fn reserving<M>(self, sample: impl IntoText<M>) -> Decorated<Self>

Reserve at least the space sample needs, so this piece’s size stops changing with its content. Read more
Source§

fn frame<Mw, Mh>( self, width: impl IntoReactive<f64, Mw>, height: impl IntoReactive<f64, Mh>, ) -> Decorated<Self>

Source§

fn width<M>(self, width: impl IntoReactive<f64, M>) -> Decorated<Self>

Fix this piece’s width to width points while its height stays flexible (hugging its content or filling on the cross axis). The single-axis complement to Self::frame, e.g. a fixed-width sidebar pane in a row whose height fills the window.
Source§

fn height<M>(self, height: impl IntoReactive<f64, M>) -> Decorated<Self>

Fix this piece’s height to height points while its width stays flexible. The single-axis complement to Self::frame, e.g. a fixed-height header/toolbar bar that fills its width.
Source§

fn a11y( self, f: impl FnOnce(A11yBuilder) -> A11yBuilder + 'static, ) -> Decorated<Self>

Source§

fn on_tap(self, f: impl Fn() + 'static) -> Decorated<Self>

Fire when this piece is tapped (bounding-box; shapes override with path-precise testing). Read more
Source§

fn on_tap_at(self, f: impl Fn(Point) + 'static) -> Decorated<Self>

on_tap, told where: the point in the piece’s own coordinate space, origin at its top-leading corner. Read more
Source§

fn focused<M>(self, binding: impl IntoFocusBinding<M>) -> Decorated<Self>

Bind this control’s keyboard focus to a signal (docs/focus.md), two-way like every other binding: native focus changes write the signal; writing the signal moves focus. Takes a Signal<bool> for one control, or (Signal<Option<K>>, K::Variant) binding one control of a group; writing false/None resigns focus (dismissing the soft keyboard on mobile). Focus applies asynchronously: a write is a request, resolved on the next turn, and the signal always ends up reflecting what the platform actually did.
Source§

fn on_key(self, f: impl Fn(&KeyEvent) + 'static) -> Decorated<Self>

Handle the non-text keys (the arrows) that reach this piece while it has focus (docs/menus.md). Keys follow focus, so pair it with Decorate::focused or with a piece the user can click into: a canvas takes focus on a press, and only the focused piece hears the keys, so a nudge handler can never fire while a text field, a list or a sidebar is the one being typed into. Read more
Source§

fn toolbar<M>(self, content: impl ToolbarContent<M>) -> Decorated<Self>

Declare toolbar items on the chrome this piece sits under (docs/toolbars.md). Read more
Source§

fn searchable(self, search: Search) -> Decorated<Self>

A search field for this navigation page (docs/search.md, “Page search”), drawn where the platform puts a page’s search: the window toolbar on a desktop, the page’s navigation bar on iOS (a UISearchController), its app bar on Android. It shows while this page does, and its text is the app’s query both ways. For a search the server runs, act on crate::Search::on_submit; for a local filter, read the query. Declare it on a nav_stack destination, as .toolbar(…) is declared; a whole navigation surface takes crate::Nav::searchable instead.
Source§

fn focusable(self) -> Decorated<Self>

Opt this piece into the platform’s focus system (docs/focus.md): the canvas contract for anything composed: it joins the key loop, takes focus on a press, reports through .focused(…), and hears the arrows through .on_key(…) while focused. A composed list column is the motivating case (docs/navigation.md). On a backend without the set_focusable duty the piece renders normally and never takes focus.
Source§

fn keyboard(self) -> Decorated<Self>

Take the whole keyboard while this piece is focused (docs/menus.md “The full route”): every key the platform delivers reaches Decorate::on_key, not only the arrows and digits. A key that types nothing is named by its web name, a key that types by its unmodified character, and what it typed rides in day_spec::KeyEvent::text: the character, or the whole string an input method committed (a dead-key accent, a Japanese phrase), delivered once, after the composition. Control chords arrive with day_spec::KeyEvent::CONTROL set and no text; only the platform’s own command chords (⌘ on Apple platforms) stay with the menu. On a phone, focusing the piece raises the soft keyboard, the way focusing a text field does, and what it types arrives the same way. For a terminal, a code editor or a game that reads letters, on a canvas: Read more
Source§

fn drag_source( self, source: impl Fn(Point) -> Option<Offer> + 'static, ) -> Decorated<Self>

Attach a context menu, shown with the platform’s native affordance on secondary-click (desktop) or long-press (mobile). Items are built with menu_item/sub_menu/menu_role/ menu_separator. Passing an empty Vec removes any menu.
Source§

fn drop_target(self, target: Target) -> Decorated<Self>

Source§

fn context_menu<M>(self, menu: impl ContextMenuContent<M>) -> Decorated<Self>

A context menu (docs/menus.md): shown on secondary-click / long-press, built from the same menu_item/sub_menu entries as everywhere else. Takes a fixed list, or a closure built when the menu is summoned (“Dynamic context menus”): with no argument, or with the summon point in this piece’s own coordinates, so a canvas can select what is under the pointer and offer commands for that selection. An empty result shows nothing. Read more
Source§

fn on_drag(self, f: impl Fn(Drag) + 'static) -> Decorated<Self>

Source§

fn on_pinch(self, f: impl Fn(Pinch) + 'static) -> Decorated<Self>

Fire on each phase of a pinch/magnify over this piece (docs/canvas.md “Zoom and pan”). Only backends with a native recognizer wired emit it; pair a zoom with visible controls.
Source§

fn on_rotate(self, f: impl Fn(Rotate) + 'static) -> Decorated<Self>

Fire on each phase of a two-finger rotation over this piece (docs/canvas.md “Zoom and pan”). rotation is in radians, cumulative within a gesture, positive clockwise; a trackpad tick arrives as a lone Changed. Pair it with a visible way back to north.
Source§

fn on_pan(self, f: impl Fn(Pan) + 'static) -> Decorated<Self>

Fire on each viewport-pan event over this piece (docs/canvas.md “Zoom and pan”): trackpad two-finger scroll, two-finger touch pan. delta is incremental; apply it as it arrives.
Source§

fn on_hover(self, f: impl Fn(Option<Point>) + 'static) -> Decorated<Self>

The pointer moving over this piece: Some(point) in its own coordinates while inside, None when it leaves (docs/canvas.md “Interaction”). Pointer-only; wire on_tap_at alongside it so a touch-only device can reach the same thing.
Source§

fn card(self) -> Decorated<Self>

Fill the piece’s bounds with a solid color painted behind it: a message-bubble / card / badge surface. Accepts a constant Color, a Signal<Color>, or a Fn() -> Color; a reactive color repaints the surface when its source changes. Wraps the piece in a native container that carries the fill, so it composes with Self::corner_radius for a rounded colored surface and with Self::padding for interior inset. The platform’s card around this piece: the grouped-content surface with rounded corners and a Space::M inset (see Decorated::card).
Source§

fn background<M>(self, color: impl IntoReactive<Color, M>) -> Decorated<Self>

Source§

fn corner_radius(self, radius: f64) -> Decorated<Self>

Round the piece’s corners to radius points, clipping its background and content to the rounded rectangle. Compose after Self::background for a rounded colored surface, or use alone to round a clipped child (e.g. an avatar image).
Source§

fn opacity<M>(self, opacity: impl IntoReactive<f64, M>) -> Decorated<Self>

Animate/set the piece’s opacity (0.0 transparent … 1.0 opaque). Wrapped in a native layer so it composes with .background; the change animates when made inside with_animation or under a .animation ancestor (§8.4).
Source§

fn transform<M>(self, t: impl IntoReactive<Transform, M>) -> Decorated<Self>

Apply an animatable Transform (translate/scale/rotate about the center): the cheap movement/scaling channel that never triggers relayout (§8.4). Prefer this over .offset for animated motion.
Source§

fn scale<M>(self, factor: impl IntoReactive<f64, M>) -> Decorated<Self>

Uniformly scale the piece by factor about its center (animatable). Convenience over Self::transform.
Source§

fn rotation<M>(self, degrees: impl IntoReactive<f64, M>) -> Decorated<Self>

Rotate the piece by degrees clockwise about its center (animatable).
Source§

fn translation<Mx, My>( self, x: impl IntoReactive<f64, Mx>, y: impl IntoReactive<f64, My>, ) -> Decorated<Self>

Translate the piece by (x, y) points without relayout (animatable): the animation-friendly sibling of .offset.
Source§

fn animation(self, anim: AnimSpec) -> Decorated<Self>

Attach an implicit animation (§8.4): changes to this piece’s (and its descendants’) animatable properties animate with anim even outside a with_animation. SwiftUI’s .animation. The ambient with_animation takes precedence when both apply.
Source§

fn modifier(self, m: impl Modifier) -> AnyPiece

Apply a Modifier (or, via the blanket impl, a plain FnOnce(AnyPiece) -> AnyPiece closure) to this piece. Pure composition: content.modifier(m) == m.apply(content.any()). Read more
Source§

fn overlay(self, over: impl Piece) -> Decorated<Self>

Draw over on top of this piece, centered, without affecting layout size: a badge / annotation overlay. self is the sizing content (bottom of the z-order); over is proposed self’s size and drawn on top. For an explicit alignment use Self::overlay_aligned; for a stack that sizes to the union of its children use zstack.
Source§

fn overlay_aligned(self, align: Alignment, over: impl Piece) -> Decorated<Self>

Self::overlay with an explicit Alignment for the annotation (e.g. a corner badge with Alignment::TopTrailing).
Source§

fn aspect_ratio(self, ratio: f64) -> Decorated<Self>

Constrain this piece to a width / height ratio: the largest box of that shape which fits whatever the parent offers (SwiftUI’s .aspectRatio(_:contentMode: .fit)). Read more
Source§

fn aligned(self, alignment: Alignment) -> Decorated<Self>

Position this piece within its assigned space without stretching its content. Read more
Source§

fn grow(self, dimension: Dimension) -> Decorated<Self>

Expand to fill the space offered in the selected dimensions. Read more
Source§

fn grow_w(self) -> Decorated<Self>

👎Deprecated:

use .grow(Dimension::Width)

Source§

fn grow_h(self) -> Decorated<Self>

👎Deprecated:

use .grow(Dimension::Height)

Source§

fn grid_align(self, a: Alignment) -> Decorated<Self>

Override this cell’s alignment within its cell rect of the enclosing grid (docs/grid.md). Like Decorated::grid_span, this applies outside wrapping modifiers regardless of its position in the chain.
Source§

fn defers_system_gestures(self, edges: Edges) -> Decorated<Self>

While this subtree is mounted, ask the OS to require a second swipe for its edge gestures on edges (docs/cover.md), the SwiftUI defersSystemGestures(on:) analogue. Put it on a game or drawing surface whose touches run to the screen edge, so a swipe up from the bottom doesn’t leave the app. iOS defers the chosen edges’ system gestures; Android enters swipe-to-reveal immersive mode while any subtree requests deferral; desktop backends no-op.
Source§

fn status_bar_hidden<M>( self, hidden: impl IntoReactive<bool, M>, ) -> Decorated<Self>

While this subtree is mounted and hidden is true, hide the system status bar, the SwiftUI statusBarHidden(_:) analogue (docs/cover.md). hidden is a constant, a Signal, or a closure, so a setting can turn it on and off in place. Put it on a page that wants the whole screen (a reader, a game, a photo viewer); the bar returns when the page unmounts. Any mounted request that answers true hides the bar. iOS, Android and HarmonyOS hide it (Cap::StatusBarHidden); desktop and web have none and ignore it.
Source§

fn interactive_dismiss_disabled(self) -> Decorated<Self>

While this subtree is mounted, the enclosing cover (or other modal surface) must not be dismissed interactively, the SwiftUI interactiveDismissDisabled() analogue (docs/cover.md). System back / sheet gestures are ignored; only programmatic writes (an explicit close control) dismiss it.
Source§

fn on_system_back<M>( self, enabled: impl IntoReactive<bool, M>, handler: impl Fn() + 'static, ) -> Decorated<Self>

While this subtree is mounted and enabled holds, a back nothing else takes runs handler instead of the platform’s default: Jetpack Compose’s BackHandler(enabled) (docs/navigation.md “Handling the system Back”). enabled is a constant, a Signal, or a closure, followed as it changes. Read more
Source§

fn any(self) -> AnyPiece

Erase to a single AnyPiece: for a Vec<AnyPiece>, a -> AnyPiece signature, or any other place one concrete type is required. AnyPiece::any is inherent and returns self, so erasing an already-erased piece costs nothing.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.