Expand description
View — chainable modifier API for ergonomic view construction.
ⓘ
use swiftui_native::prelude::*;
text("Hello").bold().padding(16.0).bg(Color::BLUE).opacity(0.9)Modules§
- style
- Swift’s generic modifiers, as Rust traits.
Structs§
- Image
- A SwiftUI
Image, before it becomes a view. - Shape
- A shape, before it is given something to draw with.
- View
- A SwiftUI view with chainable modifiers.
Enums§
- Transition
- Which transition a view uses when it appears or leaves.
Traits§
- Into
View - Anything that can become a
View.
Functions§
- async_
image AsyncImage(url:scale:)— an image fetched from a URL.- button
- Create a
Button. - button_
labelled Button { action } label: { … }— a button whose label is a view rather than a string.- canvas
Canvas { … }— immediate-mode drawing.- capsule
Capsule()- capsule_
shape Capsule(), ready to be filled.- circle
Circle()- circle_
shape Circle(), ready to be filled.- color
- Create a
Colorview. - color_
picker - Create a
ColorPickershowing a fixed colour the user cannot change. Seecolor_picker_bound. - color_
picker_ bound - Create a
ColorPickerwired to Rust state. - conditional
- A
ViewBuilderif/else, preserving branch identity. - content_
unavailable ContentUnavailableView— the placeholder for a screen with nothing on it.- control_
group ControlGroup { … }- date_
picker - Create a
DatePickershowing a fixed date the user cannot change, as seconds since the reference date. Seedate_picker_bound. - date_
picker_ bound - Create a
DatePickerwired to Rust state, in seconds since the reference date. - date_
picker_ range DatePicker(_:selection:in:displayedComponents:)— a date picker with bounds.- disclosure_
group DisclosureGroup(_:content:)- divider
- Create a
Divider. - ellipse
Ellipse()- ellipse_
shape Ellipse(), ready to be filled.- empty
- Create an
EmptyView. - environment_
reader - A view whose content is a function of the environment.
- equatable_
text EquatableView(content:)— let SwiftUI skip redrawing when the value has not changed.- for_
each ForEach(0..<count) { … }.- for_
each_ items GeometryReader { … }ForEachover a Rust collection.- form
Form { … }- gauge
Gauge(value:in:) { label }- geometry_
reader - grid
Grid { … }over rows.- grid_
row GridRow { … }- grid_
row_ aligned GridRow(alignment:) { … }— this row’s own vertical alignment, which overrides the grid’s for the row alone.- group
Group { … }— several views where one is wanted, with no layout of its own.- group_
box GroupBox { … }- hstack
- hstack_
aligned HStack(alignment:) { … }— how children line up across the stack’s height. The baseline cases align on the children’s text rather than on their boxes.- hstack_
aligned_ spacing HStack(alignment:spacing:) { … }—Nonekeeps SwiftUI’s own spacing.- hstack_
spacing HStack(spacing:) { … }.- image
- Create an SF Symbol
Image. - label
- Create a
Label(_:systemImage:). - laid_
out - A layout written in Rust, given children —
MyLayout { … }. - layout
- Build a layout from a sizing pass and a placement pass.
- lazy_
hstack - Create a
LazyHStack. - lazy_
hstack_ aligned LazyHStack(alignment:).- lazy_
vstack - Create a
LazyVStack. - lazy_
vstack_ aligned LazyVStack(alignment:).- link
Link(_:destination:)— opens a URL.- list
List { … }- list_
identified List(ids, id: \.self) { id in … }— rows identified by value.- list_
identified_ str List(names, id: \.self) { name in … }— the same, keyed byString.- menu
Menu(_:) { … }- named_
image Image(_:)— a named asset, kept as anImage.- navigation_
link - navigation_
link_ labelled NavigationLink(_:destination:)NavigationLink(destination:) { label }— a link whose label is a view.- navigation_
split_ view NavigationSplitView { sidebar } detail: { detail }- navigation_
split_ view3 NavigationSplitView { sidebar } content: { content } detail: { detail }- navigation_
stack NavigationStack { … }- ns_view
- An AppKit view hosted in a SwiftUI tree.
- outline_
group OutlineGroup(_:children:)over anIntroot.- picker
- Create a
Pickerovercontent, showing a fixed selection the user cannot change. Seepicker_bound(). - picker_
bound - Create a
Pickerwired to Rust state — choosing a row writes its tag intostate. - progress
- Create a
ProgressView. - progress_
indeterminate ProgressView()with no value — the indeterminate spinner, as distinct fromprogress, which shows a fraction.- rectangle
Rectangle()- rectangle_
shape Rectangle(), ready to be filled.- rounded_
rectangle RoundedRectangle(cornerRadius:)- rounded_
rectangle_ shape RoundedRectangle(cornerRadius:), ready to be filled.- rounded_
rectangle_ shape_ styled RoundedRectangle(cornerRadius:style:)—falsegives the circular arc rather than Swift’s default squircle.- scroll_
reader - A
ScrollViewReader, whose content is handed a proxy it can scroll with. - scroll_
view ScrollView { … }— a vertical scroll view with indicators.- section
Section { … }with no header.- section_
expanded Section(isExpanded:) { … } header: { … }— a section that collapses.- section_
footer Section { … } footer: { … }- section_
titled Section { … } header: { … }- section_
titled_ footer Section { … } header: { … } footer: { … }- securefield
- Create a
SecureFieldshowing a fixed string, which the user cannot edit. Seesecurefield_bound. - securefield_
bound - Create a
SecureFieldwired to Rust state — every keystroke writes into it. - shape
- A
Shapewritten in Rust, drawn with the foreground style. - share_
link ShareLink(item:)over a URL.- slider
- Create a
Slidershowing a fixed value, which the user cannot move. - slider_
bound - Create a
Sliderwired to Rust state, readable and writable from both sides. - slider_
step_ bound Slider(value:in:step:)— a slider that snaps to multiples ofstep.- spacer
- Create a
Spacer. - stepper
- Create a
Stepper. - stepper_
actions Stepper(_:onIncrement:onDecrement:)— a stepper driven by callbacks.- stepper_
bound - Create a
Stepperwired to Rust state — the+/−buttons write back. - system_
image Image(systemName:), kept as anImageso its own modifiers are reachable.- tab
Tab("Home", systemImage: "house") { … }— one tab of a modernTabView.- tab_
view TabView { … }- tab_
view_ tabs TabView { Tab(…); Tab(…); … }— the modern tab view.- table
Table(of:)over interface orientations, with a single column.- text
- Create a
Textview. - text_
editor TextEditor(text:)showing a fixed string, which the user cannot edit.- text_
verbatim Text(verbatim:)— shown exactly as given.- textfield
- Create a
TextFieldshowing a fixed string, which the user cannot edit. - textfield_
axis TextField(_:text:axis:)— a field that grows alongaxisas it is typed into.- textfield_
bound - Create a
TextFieldwired to Rust state — every keystroke writes into it. - timeline
TimelineView(.animation) { … }— rebuild on SwiftUI’s clock so that Rust state changes appear without an explicit redisplay.- toggle
- Create a
Toggle. - toggle_
bound - Create a
Togglewired to Rust state, readable and writable from both sides. - toggle_
labelled Toggle(isOn:) { label }— a toggle whose label is any view.- toggle_
sources Toggle(_:sources:isOn:)— one toggle over several bindings.- tuple_
view TupleView<(A, B, …)>— several views with no container around them.- view_
that_ fits ViewThatFits(in:) { … }— the first child that fits, along the given axes.- vstack
- Create a
VStack. - vstack_
aligned VStack(alignment:) { … }— how children line up across the stack’s width.- vstack_
aligned_ spacing VStack(alignment:spacing:) { … }—Nonekeeps SwiftUI’s own spacing.- vstack_
spacing VStack(spacing:) { … }.- zstack
- Create a
ZStack. - zstack_
aligned ZStack(alignment:) { … }.