Documentation
¶
Overview ¶
Package swiftui provides Go bindings for Apple's SwiftUI framework, enabling declarative UI construction from pure Go on macOS 26 or later.
SwiftUI is a Swift-only framework. This package includes a vendored Swift bridge (under internal/swift/) that is automatically built on first use. No external dependencies or manual setup required — just go run.
Threading ¶
All View construction and modifier calls must happen on the main thread. Call runtime.LockOSThread() in init() or TestMain to pin the main goroutine. State.Set() is safe from any goroutine — the Swift bridge dispatches updates to the MainActor automatically. For view operations from background goroutines, use dispatch.MainQueue().Async().
Environment ¶
By default, the package loads the embedded bridge from a per-user cache under $HOME/Library/Caches/swiftui/bridge-cache.
To override the dylib path, set $LIBSWIFTUI_BRIDGE_PATH.
Index ¶
- func PlaySystemSound(name string)
- func RenderPNG(path string, root View, width, height, scale float64) error
- func Run(config AppConfig, root View)
- func RunMenuBar(config MenuBarConfig, content View)
- func RunWithMenuBar(appConfig AppConfig, content View, menuConfig MenuBarConfig, menuContent View)
- func UpdateMenuBarLabel(label string)
- func UpdateMenuBarLabelStyled(label string, style MenuBarLabelStyle)
- type AccessibilityTrait
- type AnimationKind
- type AppConfig
- type Axis
- type BoolState
- type ButtonStyleKind
- type Color
- type ColorState
- type ContentMode
- type ControlSize
- type DateState
- type Design
- type Edge
- type FloatState
- type Font
- type GlassButtonStyleKind
- type GlassShape
- type GlassStyle
- type HorizontalAlignment
- type HoverEffectKind
- type ImageScale
- type IntState
- type LabelStyleKind
- type ListStyleKind
- type MenuBarConfig
- type MenuBarLabelStyle
- type MenuOrderKind
- type NavigationSplitViewStyleKind
- type NavigationSplitViewVisibilityKind
- type PickerStyleKind
- type PointerStyleKind
- type PresentationDragIndicatorKind
- type ScrollAnchor
- type ScrollBounce
- type ScrollTargetBehaviorKind
- type ShapeView
- func (v ShapeView) AsView() View
- func (v ShapeView) Background(r float64, g float64, b float64, a float64) ShapeView
- func (v ShapeView) Fill(r float64, g float64, b float64, a float64) ShapeView
- func (v ShapeView) Font(f Font) ShapeView
- func (v ShapeView) FontDesign(design Design) ShapeView
- func (v ShapeView) FontWeight(weight Weight) ShapeView
- func (v ShapeView) ForegroundStyle(r float64, g float64, b float64, a float64) ShapeView
- func (v ShapeView) ForegroundStyleNamed(name string) ShapeView
- func (v ShapeView) Frame(width float64, height float64) ShapeView
- func (v ShapeView) Offset(x float64, y float64) ShapeView
- func (v ShapeView) Opacity(opacity float64) ShapeView
- func (v ShapeView) Padding(amount float64) ShapeView
- func (v ShapeView) Stroke(r float64, g float64, b float64, a float64, lineWidth float64) ShapeView
- type ShortcutModifier
- type StringState
- type SubmitLabelKind
- type SymbolRenderingMode
- type TextAlignment
- type TextFieldStyleKind
- type TextView
- func (v TextView) AsView() View
- func (v TextView) Background(r float64, g float64, b float64, a float64) TextView
- func (v TextView) Bold() TextView
- func (v TextView) Font(f Font) TextView
- func (v TextView) FontDesign(design Design) TextView
- func (v TextView) FontWeight(weight Weight) TextView
- func (v TextView) ForegroundStyle(r float64, g float64, b float64, a float64) TextView
- func (v TextView) ForegroundStyleNamed(name string) TextView
- func (v TextView) Frame(width float64, height float64) TextView
- func (v TextView) Italic() TextView
- func (v TextView) LineLimit(n int) TextView
- func (v TextView) MonospacedDigit() TextView
- func (v TextView) MultilineTextAlignment(alignment TextAlignment) TextView
- func (v TextView) Offset(x float64, y float64) TextView
- func (v TextView) Opacity(opacity float64) TextView
- func (v TextView) Padding(amount float64) TextView
- func (v TextView) Strikethrough() TextView
- func (v TextView) SymbolRenderingMode(mode SymbolRenderingMode) TextView
- func (v TextView) TruncationMode(mode TruncationMode) TextView
- func (v TextView) Underline() TextView
- type ToggleStyleKind
- type ToolbarItemPlacement
- type ToolbarRole
- type Transition
- type TruncationMode
- type VerticalAlignment
- type View
- func AnimatedDynamicBoolView(state *BoolState, transition Transition, builder func(value bool) View) View
- func AnimatedDynamicFloatView(state *FloatState, transition Transition, builder func(value float64) View) View
- func AnimatedDynamicView(state *IntState, transition Transition, builder func(value int) View) View
- func Button(label string, action func()) View
- func ButtonWithImage(systemName string, action func()) View
- func ButtonWithLabel(text string, systemImage string, action func()) View
- func ColorPicker(label string, state *ColorState, onChange func()) View
- func ColorView(r float64, g float64, b float64, a float64) View
- func DatePicker(label string, state *DateState, onChange func()) View
- func Divider() View
- func DynamicBoolView(state *BoolState, builder func(value bool) View) View
- func DynamicFloatView(state *FloatState, builder func(value float64) View) View
- func DynamicView(state *IntState, builder func(value int) View) View
- func EmptyView() View
- func FloatGauge(label string, state *FloatState, min float64, max float64) View
- func FloatProgressView(state *FloatState, total float64) View
- func FloatSlider(label string, state *FloatState, min float64, max float64, onChange func()) View
- func Form(children ...Viewable) View
- func Gauge(value float64, label string) View
- func GeometryReader(builder func(width, height float64) View) View
- func GroupBox(label string, content View) View
- func HStack(children ...Viewable) View
- func HStackSpaced(spacing float64, children ...Viewable) View
- func Image(systemName string) View
- func LazyHStack(children ...Viewable) View
- func LazyVStack(children ...Viewable) View
- func Link(title string, url string) View
- func List(children ...Viewable) View
- func Menu(label string, content View) View
- func NavigationLink(label string, destination View) View
- func NavigationStack(content View) View
- func PickerMenu(label string, state *IntState, options View, onChange func()) View
- func PickerSegmented(label string, state *IntState, options View, onChange func()) View
- func ProgressLinear(value float64, total float64) View
- func ProgressSpinning() View
- func ScrollView(content View) View
- func Section(header string, content View) View
- func SecureField(placeholder string, state *StringState, onSubmit func()) View
- func Slider(label string, state *IntState, min float64, max float64, onChange func()) View
- func Spacer() View
- func Stepper(label string, state *IntState, min int32, max int32, onChange func()) View
- func TabView(children ...Viewable) View
- func TextEditor(state *StringState) View
- func TextField(placeholder string, state *StringState, onSubmit func()) View
- func Toggle(label string, state *IntState, onChange func()) View
- func VStack(children ...Viewable) View
- func VStackSpaced(spacing float64, children ...Viewable) View
- func ViewFromPointer(ptr uintptr) View
- func ZStack(children ...Viewable) View
- func (v View) AccessibilityHidden(hidden bool) View
- func (v View) AccessibilityHint(hint string) View
- func (v View) AccessibilityLabel(label string) View
- func (v View) Alert(title string, message string, state *IntState) View
- func (v View) AllowsHitTesting(enabled bool) View
- func (v View) Animation(kind AnimationKind) View
- func (v View) AspectRatio(ratio float64, contentMode ContentMode) View
- func (v View) Background(r float64, g float64, b float64, a float64) View
- func (v View) BackgroundRoundedRect(r float64, g float64, b float64, a float64, cornerRadius float64) View
- func (v View) BackgroundStyle(name string) View
- func (v View) Blur(radius float64) View
- func (v View) Border(r float64, g float64, b float64, a float64, width float64) View
- func (v View) ButtonStyle(style ButtonStyleKind) View
- func (v View) ClipRoundedRect(cornerRadius float64) View
- func (v View) Clipped() View
- func (v View) ConfirmationDialog(title string, state *IntState, actions View) View
- func (v View) ContextMenu(content View) View
- func (v View) ControlSize(size ControlSize) View
- func (v View) CornerRadius(radius float64) View
- func (v View) Disabled(disabled bool) View
- func (v View) FixedSize() View
- func (v View) FixedSizeAxis(horizontal bool, vertical bool) View
- func (v View) Focusable(focusable bool) View
- func (v View) Font(f Font) View
- func (v View) FontDesign(design Design) View
- func (v View) FontWeight(weight Weight) View
- func (v View) ForegroundStyle(r float64, g float64, b float64, a float64) View
- func (v View) ForegroundStyleNamed(name string) View
- func (v View) Frame(width float64, height float64) View
- func (v View) FullScreenCover(state *IntState, content View) View
- func (v View) Help(text string) View
- func (v View) ImageScale(scale ImageScale) View
- func (v View) LayoutPriority(priority float64) View
- func (v View) ListRowBackground(background View) View
- func (v View) ListStyle(style ListStyleKind) View
- func (v View) Mask(mask View) View
- func (v View) MaxFrame(maxWidth float64, maxHeight float64) View
- func (v View) NavigationTitle(title string) View
- func (v View) Offset(x float64, y float64) View
- func (v View) OnAppear(action func()) View
- func (v View) OnDisappear(action func()) View
- func (v View) OnHover(action func()) View
- func (v View) OnTapGesture(action func()) View
- func (v View) Opacity(opacity float64) View
- func (v View) Overlay(overlay View) View
- func (v View) Padding(amount float64) View
- func (v View) PaddingEdge(edges Edge, amount float64) View
- func (v View) Pointer() uintptr
- func (v View) Popover(state *IntState, content View) View
- func (v *View) Release()
- func (v View) RotationEffect(degrees float64) View
- func (v View) ScaleEffect(scale float64) View
- func (v View) Shadow(r float64, g float64, b float64, a float64, radius float64, x float64, ...) View
- func (v View) Sheet(state *IntState, content View) View
- func (v View) TabItem(label string, systemImage string) View
- func (v View) Tag(tag int32) View
- func (v View) TextFieldStyle(style TextFieldStyleKind) View
- func (v View) Tint(r float64, g float64, b float64, a float64) View
- func (v View) WebViewBackForwardNavigationGestures(behavior WebViewBehavior) View
- func (v View) WebViewContentBackground(visibility WebViewContentBackgroundVisibility) View
- func (v View) WebViewElementFullscreenBehavior(behavior WebViewBehavior) View
- func (v View) WebViewLinkPreviews(behavior WebViewBehavior) View
- func (v View) WebViewMagnificationGestures(behavior WebViewBehavior) View
- func (v View) WebViewTextSelection(enabled bool) View
- func (v View) ZIndex(index float64) View
- type Viewable
- type WebPagedeprecated
- func NewWebPage() *WebPagedeprecated
- func NewWebPageURL(url string) *WebPagedeprecated
- type WebViewBehavior
- type WebViewContentBackgroundVisibility
- type Weight
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PlaySystemSound ¶
func PlaySystemSound(name string)
PlaySystemSound plays a macOS system sound by name. Common names: "Basso", "Blow", "Bottle", "Frog", "Funk", "Glass", "Hero", "Morse", "Ping", "Pop", "Purr", "Sosumi", "Submarine", "Tink".
func Run ¶
Run starts the application event loop with the given root view. This blocks until the application exits.
func RunMenuBar ¶
func RunMenuBar(config MenuBarConfig, content View)
RunMenuBar starts a menu-bar-only app with no dock icon. The content View is shown in a popover when the status item is clicked. This blocks until the application exits.
func RunWithMenuBar ¶
func RunWithMenuBar(appConfig AppConfig, content View, menuConfig MenuBarConfig, menuContent View)
RunWithMenuBar starts a windowed app that also has a menu bar item. The menuContent View is shown in a popover when the status item is clicked. This blocks until the application exits.
func UpdateMenuBarLabel ¶
func UpdateMenuBarLabel(label string)
UpdateMenuBarLabel changes the status item text at runtime.
func UpdateMenuBarLabelStyled ¶
func UpdateMenuBarLabelStyled(label string, style MenuBarLabelStyle)
UpdateMenuBarLabelStyled updates the status item text with optional styling. If the styled bridge symbol is unavailable, this falls back to UpdateMenuBarLabel.
Types ¶
type AccessibilityTrait ¶
type AccessibilityTrait int32
AccessibilityTrait identifies accessibility trait flags.
const ( AccessibilityTraitNone AccessibilityTrait = 0 AccessibilityTraitHeader AccessibilityTrait = 2 AccessibilityTraitButton AccessibilityTrait = 4 AccessibilityTraitSearchField AccessibilityTrait = 8 AccessibilityTraitStaticText AccessibilityTrait = 16 )
type AnimationKind ¶
type AnimationKind int32
AnimationKind identifies animation curve presets.
const ( AnimationEaseInOut AnimationKind = 0 AnimationEaseIn AnimationKind = 1 AnimationEaseOut AnimationKind = 2 AnimationSpring AnimationKind = 3 AnimationBouncy AnimationKind = 4 )
type BoolState ¶
type BoolState struct {
// contains filtered or unexported fields
}
BoolState is an observable boolean state value.
func NewBoolState ¶
NewBoolState creates a new observable boolean state.
func (*BoolState) Release ¶
func (s *BoolState) Release()
Release decrements the underlying Swift retain count.
func (*BoolState) SetAnimated ¶
SetAnimated updates the boolean value with the default ease-in-out animation.
func (*BoolState) SetAnimatedWith ¶
func (s *BoolState) SetAnimatedWith(v bool, kind AnimationKind)
SetAnimatedWith updates the boolean value using the provided animation curve.
type ButtonStyleKind ¶
type ButtonStyleKind int32
ButtonStyleKind identifies button display styles.
const ( ButtonStyleAutomatic ButtonStyleKind = 0 ButtonStyleBordered ButtonStyleKind = 1 ButtonStyleBorderedProminent ButtonStyleKind = 2 ButtonStyleBorderless ButtonStyleKind = 3 ButtonStylePlain ButtonStyleKind = 4 )
type Color ¶
type Color struct {
R, G, B, A float64
}
Color represents an RGBA color value.
type ColorState ¶
type ColorState struct {
// contains filtered or unexported fields
}
ColorState is a reactive RGBA color state that bridges Go and SwiftUI.
func NewColorState ¶
func NewColorState(r, g, b, a float64) *ColorState
NewColorState creates a new reactive color state from RGBA values (0.0-1.0).
func (*ColorState) Release ¶
func (s *ColorState) Release()
Release decrements the underlying Swift retain count.
func (*ColorState) Set ¶
func (s *ColorState) Set(r, g, b, a float64)
Set updates the RGBA color values.
type ContentMode ¶
type ContentMode int32
ContentMode identifies aspect ratio content modes.
const ( ContentModeFit ContentMode = 0 ContentModeFill ContentMode = 1 )
type ControlSize ¶
type ControlSize int32
ControlSize identifies control sizing presets.
const ( ControlSizeMini ControlSize = 0 ControlSizeSmall ControlSize = 1 ControlSizeRegular ControlSize = 2 ControlSizeLarge ControlSize = 3 ControlSizeExtraLarge ControlSize = 4 )
type DateState ¶
type DateState struct {
// contains filtered or unexported fields
}
DateState is a reactive date state that bridges Go and SwiftUI. Dates are represented as Unix epoch seconds (float64).
func NewDateState ¶
NewDateState creates a new reactive date state from Unix epoch seconds.
type FloatState ¶
type FloatState struct {
// contains filtered or unexported fields
}
FloatState is a reactive float64 state that bridges Go and SwiftUI.
func NewFloatState ¶
func NewFloatState(initial float64) *FloatState
NewFloatState creates a new reactive float64 state with the given initial value.
func (*FloatState) Release ¶
func (s *FloatState) Release()
Release decrements the underlying Swift retain count.
func (*FloatState) Set ¶
func (s *FloatState) Set(v float64)
Set updates the float64 value, triggering SwiftUI view updates.
func (*FloatState) SetAnimated ¶
func (s *FloatState) SetAnimated(v float64)
SetAnimated updates the float64 value inside withAnimation.
func (*FloatState) SetAnimatedWith ¶
func (s *FloatState) SetAnimatedWith(v float64, kind AnimationKind)
SetAnimatedWith updates the float64 value using the provided animation curve.
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font is an opaque handle to a SwiftUI font in the Swift bridge.
var ( FontLargeTitle Font FontTitle Font FontTitle2 Font FontTitle3 Font FontHeadline Font FontSubheadline Font FontBody Font FontCallout Font FontFootnote Font FontCaption Font FontCaption2 Font )
Preset font variables, initialized after the dylib loads.
func FontSystem ¶
FontSystem returns a system font at the given point size.
func FontSystemDesign ¶
FontSystemDesign returns a system font with explicit weight and design. Use Weight* and Design* constants for the weight and design parameters.
type GlassButtonStyleKind ¶
type GlassButtonStyleKind int32
GlassButtonStyleKind identifies glass button styles.
const ( GlassButtonStyleRegular GlassButtonStyleKind = 0 GlassButtonStyleProminent GlassButtonStyleKind = 1 )
type GlassShape ¶
type GlassShape int32
GlassShape identifies glass effect shapes.
const ( GlassShapeRoundedRectangle GlassShape = 0 GlassShapeCapsule GlassShape = 1 GlassShapeCircle GlassShape = 2 )
type GlassStyle ¶
type GlassStyle int32
GlassStyle identifies glass effect styles.
const ( GlassStyleRegular GlassStyle = 0 GlassStyleProminent GlassStyle = 1 GlassStyleThin GlassStyle = 2 GlassStyleThick GlassStyle = 3 GlassStyleUltraThin GlassStyle = 4 )
type HorizontalAlignment ¶
type HorizontalAlignment int32
HorizontalAlignment identifies horizontal alignment options.
const ( HorizontalAlignmentLeading HorizontalAlignment = 0 HorizontalAlignmentCenter HorizontalAlignment = 1 HorizontalAlignmentTrailing HorizontalAlignment = 2 )
type HoverEffectKind ¶
type HoverEffectKind int32
HoverEffectKind identifies hover effect styles.
const ( HoverEffectAutomatic HoverEffectKind = 0 HoverEffectHighlight HoverEffectKind = 1 )
type ImageScale ¶
type ImageScale int32
ImageScale identifies SF Symbol image scales.
const ( ImageScaleSmall ImageScale = 0 ImageScaleMedium ImageScale = 1 ImageScaleLarge ImageScale = 2 )
type IntState ¶
type IntState struct {
// contains filtered or unexported fields
}
IntState is a reactive integer state that bridges Go and SwiftUI. When the value changes via Set, any SwiftUI views observing this state update automatically.
func NewIntState ¶
NewIntState creates a new reactive integer state with the given initial value.
func (*IntState) Release ¶
func (s *IntState) Release()
Release decrements the underlying Swift retain count.
func (*IntState) SetAnimated ¶
SetAnimated updates the value inside withAnimation, triggering animated SwiftUI transitions.
func (*IntState) SetAnimatedWith ¶
func (s *IntState) SetAnimatedWith(v int, kind AnimationKind)
SetAnimatedWith updates the value using the provided animation curve.
type LabelStyleKind ¶
type LabelStyleKind int32
LabelStyleKind identifies label display styles.
const ( LabelStyleAutomatic LabelStyleKind = 0 LabelStyleIconOnly LabelStyleKind = 1 LabelStyleTitleOnly LabelStyleKind = 2 LabelStyleTitleAndIcon LabelStyleKind = 3 )
type ListStyleKind ¶
type ListStyleKind int32
ListStyleKind identifies list display styles.
const ( ListStyleAutomatic ListStyleKind = 0 ListStyleSidebar ListStyleKind = 1 ListStyleInset ListStyleKind = 2 ListStylePlain ListStyleKind = 3 )
type MenuBarConfig ¶
type MenuBarConfig struct {
Label string // Text shown next to the icon
SystemImage string // SF Symbol name for the icon
Width float64 // Popover width
Height float64 // Popover height
OpenOnLaunch bool // Show the popover immediately after app launch.
}
MenuBarConfig configures a menu bar status item.
type MenuBarLabelStyle ¶
MenuBarLabelStyle controls visual behavior when updating the status label.
type MenuOrderKind ¶
type MenuOrderKind int32
MenuOrderKind identifies menu ordering behavior.
const ( MenuOrderAutomatic MenuOrderKind = 0 MenuOrderFixed MenuOrderKind = 1 )
type NavigationSplitViewStyleKind ¶
type NavigationSplitViewStyleKind int32
NavigationSplitViewStyleKind identifies navigation split view styles.
const ( )
type NavigationSplitViewVisibilityKind ¶
type NavigationSplitViewVisibilityKind int32
NavigationSplitViewVisibilityKind identifies column visibility.
const ( )
type PickerStyleKind ¶
type PickerStyleKind int32
PickerStyleKind identifies picker display styles.
const ( PickerStyleAutomatic PickerStyleKind = 0 PickerStyleInline PickerStyleKind = 1 PickerStyleMenu PickerStyleKind = 2 PickerStyleSegmented PickerStyleKind = 3 PickerStyleWheel PickerStyleKind = 4 PickerStylePalette PickerStyleKind = 6 )
type PointerStyleKind ¶
type PointerStyleKind int32
PointerStyleKind identifies pointer cursor styles.
const ( PointerStyleAutomatic PointerStyleKind = 0 PointerStyleLink PointerStyleKind = 1 PointerStyleCrosshair PointerStyleKind = 2 )
type PresentationDragIndicatorKind ¶
type PresentationDragIndicatorKind int32
PresentationDragIndicatorKind identifies drag indicator visibility.
const ( PresentationDragIndicatorAutomatic PresentationDragIndicatorKind = 0 PresentationDragIndicatorVisible PresentationDragIndicatorKind = 1 PresentationDragIndicatorHidden PresentationDragIndicatorKind = 2 )
type ScrollAnchor ¶
type ScrollAnchor int32
ScrollAnchor identifies scroll anchor positions.
const ( ScrollAnchorTop ScrollAnchor = 0 ScrollAnchorCenter ScrollAnchor = 1 ScrollAnchorBottom ScrollAnchor = 2 ScrollAnchorLeading ScrollAnchor = 3 ScrollAnchorTrailing ScrollAnchor = 4 )
type ScrollBounce ¶
type ScrollBounce int32
ScrollBounce identifies scroll bounce behavior.
const ( ScrollBounceBasedOnSize ScrollBounce = 0 ScrollBounceAlways ScrollBounce = 1 )
type ScrollTargetBehaviorKind ¶
type ScrollTargetBehaviorKind int32
ScrollTargetBehaviorKind identifies scroll target snapping behavior.
const ( ScrollTargetBehaviorPaging ScrollTargetBehaviorKind = 0 ScrollTargetBehaviorViewAligned ScrollTargetBehaviorKind = 1 )
type ShapeView ¶
type ShapeView struct {
View
}
ShapeView is a View created from a shape constructor (Circle, Rectangle, etc.). It provides shape-specific modifiers like Fill and Stroke in addition to all universal View modifiers.
func Rectangle ¶
func Rectangle() ShapeView
Rectangle creates a rectangle shape filling available space.
func RoundedRectangle ¶
RoundedRectangle creates a rounded rectangle shape.
func (ShapeView) Background ¶
Background sets a background color using RGBA values.
func (ShapeView) FontDesign ¶
FontDesign sets the font design for text in the view.
func (ShapeView) FontWeight ¶
FontWeight sets the font weight for text in the view.
func (ShapeView) ForegroundStyle ¶
ForegroundStyle sets the foreground color using RGBA values.
func (ShapeView) ForegroundStyleNamed ¶
ForegroundStyleNamed sets a named foreground style (primary, secondary, tertiary, quaternary).
type ShortcutModifier ¶
type ShortcutModifier int32
ShortcutModifier identifies keyboard shortcut modifier keys.
const ( ShortcutModifierCommand ShortcutModifier = 1 ShortcutModifierShift ShortcutModifier = 2 ShortcutModifierOption ShortcutModifier = 4 ShortcutModifierControl ShortcutModifier = 8 )
type StringState ¶
type StringState struct {
// contains filtered or unexported fields
}
StringState is a reactive string state that bridges Go and SwiftUI.
func NewStringState ¶
func NewStringState(initial string) *StringState
NewStringState creates a new reactive string state with the given initial value.
func (*StringState) Release ¶
func (s *StringState) Release()
Release decrements the underlying Swift retain count.
func (*StringState) Set ¶
func (s *StringState) Set(v string)
Set updates the string value, triggering SwiftUI view updates.
type SubmitLabelKind ¶
type SubmitLabelKind int32
SubmitLabelKind identifies submit label presets.
const ( SubmitLabelReturn SubmitLabelKind = 0 SubmitLabelDone SubmitLabelKind = 1 SubmitLabelGo SubmitLabelKind = 2 SubmitLabelSend SubmitLabelKind = 3 SubmitLabelJoin SubmitLabelKind = 4 SubmitLabelContinue SubmitLabelKind = 5 SubmitLabelNext SubmitLabelKind = 6 SubmitLabelSearch SubmitLabelKind = 7 SubmitLabelRoute SubmitLabelKind = 8 )
type SymbolRenderingMode ¶
type SymbolRenderingMode int32
SymbolRenderingMode identifies SF Symbol rendering modes.
const ( SymbolRenderingModeMonochrome SymbolRenderingMode = 0 SymbolRenderingModeHierarchical SymbolRenderingMode = 1 SymbolRenderingModePalette SymbolRenderingMode = 2 SymbolRenderingModeMulticolor SymbolRenderingMode = 3 )
type TextAlignment ¶
type TextAlignment int32
TextAlignment identifies multiline text alignment.
const ( TextAlignmentLeading TextAlignment = 0 TextAlignmentCenter TextAlignment = 1 TextAlignmentTrailing TextAlignment = 2 )
type TextFieldStyleKind ¶
type TextFieldStyleKind int32
TextFieldStyleKind identifies text field display styles.
const ( TextFieldStyleAutomatic TextFieldStyleKind = 0 TextFieldStyleRoundedBorder TextFieldStyleKind = 1 TextFieldStylePlain TextFieldStyleKind = 2 )
type TextView ¶
type TextView struct {
View
}
TextView is a View created from a text constructor (Text, Label, etc.). It provides text-specific modifiers like Bold, Italic, and Font in addition to all universal View modifiers.
func TextFromString ¶
func TextFromString(state *StringState) TextView
TextFromString creates a text view that reactively displays a StringState value.
func (TextView) Background ¶
Background sets a background color using RGBA values.
func (TextView) FontDesign ¶
FontDesign sets the font design for text in the view.
func (TextView) FontWeight ¶
FontWeight sets the font weight for text in the view.
func (TextView) ForegroundStyle ¶
ForegroundStyle sets the foreground color using RGBA values.
func (TextView) ForegroundStyleNamed ¶
ForegroundStyleNamed sets a named foreground style (primary, secondary, tertiary, quaternary).
func (TextView) LineLimit ¶
LineLimit sets the maximum number of lines for text views. Pass 0 for unlimited.
func (TextView) MonospacedDigit ¶
MonospacedDigit applies monospaced digit formatting.
func (TextView) MultilineTextAlignment ¶
func (v TextView) MultilineTextAlignment(alignment TextAlignment) TextView
MultilineTextAlignment sets the alignment for multiline text.
func (TextView) Strikethrough ¶
Strikethrough adds a strikethrough to text in the view.
func (TextView) SymbolRenderingMode ¶
func (v TextView) SymbolRenderingMode(mode SymbolRenderingMode) TextView
SymbolRenderingMode sets the rendering mode for SF Symbols.
func (TextView) TruncationMode ¶
func (v TextView) TruncationMode(mode TruncationMode) TextView
TruncationMode sets how text is truncated when it overflows.
type ToggleStyleKind ¶
type ToggleStyleKind int32
ToggleStyleKind identifies toggle display styles.
const ( ToggleStyleAutomatic ToggleStyleKind = 0 ToggleStyleButton ToggleStyleKind = 1 ToggleStyleCheckbox ToggleStyleKind = 2 ToggleStyleSwitch ToggleStyleKind = 3 )
type ToolbarItemPlacement ¶
type ToolbarItemPlacement int32
ToolbarItemPlacement identifies toolbar item positions.
const ( ToolbarItemPlacementAutomatic ToolbarItemPlacement = 0 ToolbarItemPlacementPrincipal ToolbarItemPlacement = 1 ToolbarItemPlacementPrimaryAction ToolbarItemPlacement = 3 ToolbarItemPlacementSecondaryAction ToolbarItemPlacement = 4 ToolbarItemPlacementCancellationAction ToolbarItemPlacement = 5 ToolbarItemPlacementConfirmationAction ToolbarItemPlacement = 6 ToolbarItemPlacementDestructiveAction ToolbarItemPlacement = 7 ToolbarItemPlacementStatus ToolbarItemPlacement = 8 )
type ToolbarRole ¶
type ToolbarRole int32
ToolbarRole identifies toolbar roles.
const ( ToolbarRoleAutomatic ToolbarRole = 0 ToolbarRoleEditor ToolbarRole = 1 )
type Transition ¶
type Transition int32
Transition identifies view transition animations.
const ( TransitionSlide Transition = 0 TransitionOpacity Transition = 1 TransitionMove Transition = 2 TransitionScale Transition = 3 TransitionPush Transition = 4 )
type TruncationMode ¶
type TruncationMode int32
TruncationMode identifies text truncation behavior.
const ( TruncationModeHead TruncationMode = 0 TruncationModeMiddle TruncationMode = 1 TruncationModeTail TruncationMode = 2 )
type VerticalAlignment ¶
type VerticalAlignment int32
VerticalAlignment identifies vertical alignment options.
const ( VerticalAlignmentTop VerticalAlignment = 0 VerticalAlignmentCenter VerticalAlignment = 1 VerticalAlignmentBottom VerticalAlignment = 2 VerticalAlignmentFirstTextBaseline VerticalAlignment = 3 VerticalAlignmentLastTextBaseline VerticalAlignment = 4 )
type View ¶
type View struct {
// contains filtered or unexported fields
}
View is an opaque handle to a SwiftUI view in the Swift bridge.
func AnimatedDynamicBoolView ¶
func AnimatedDynamicBoolView(state *BoolState, transition Transition, builder func(value bool) View) View
AnimatedDynamicBoolView creates a BoolState-driven view with animated transitions.
func AnimatedDynamicFloatView ¶
func AnimatedDynamicFloatView(state *FloatState, transition Transition, builder func(value float64) View) View
AnimatedDynamicFloatView creates a FloatState-driven view with animated transitions.
func AnimatedDynamicView ¶
func AnimatedDynamicView(state *IntState, transition Transition, builder func(value int) View) View
AnimatedDynamicView creates a view with animated transitions between states.
func ButtonWithImage ¶
ButtonWithImage creates a clickable button with an SF Symbol icon.
func ButtonWithLabel ¶
ButtonWithLabel creates a clickable button with both text and an SF Symbol icon.
func ColorPicker ¶
func ColorPicker(label string, state *ColorState, onChange func()) View
ColorPicker creates a color picker bound to a ColorState.
func DatePicker ¶
DatePicker creates a date picker bound to a DateState.
func DynamicBoolView ¶
DynamicBoolView creates a view whose content is rebuilt by a Go callback whenever the observed BoolState changes.
func DynamicFloatView ¶
func DynamicFloatView(state *FloatState, builder func(value float64) View) View
DynamicFloatView creates a view whose content is rebuilt by a Go callback whenever the observed FloatState changes.
func DynamicView ¶
DynamicView creates a view whose content is rebuilt by a Go callback whenever the observed IntState changes.
func FloatGauge ¶
func FloatGauge(label string, state *FloatState, min float64, max float64) View
FloatGauge displays a gauge bound to a FloatState.
func FloatProgressView ¶
func FloatProgressView(state *FloatState, total float64) View
FloatProgressView displays a progress bar bound to a FloatState.
func FloatSlider ¶
func FloatSlider(label string, state *FloatState, min float64, max float64, onChange func()) View
FloatSlider creates a slider bound to a FloatState within a range.
func GeometryReader ¶
GeometryReader creates a view whose content is built with the available width and height.
func HStackSpaced ¶
HStackSpaced arranges child views in a horizontal stack with explicit spacing.
func LazyHStack ¶
LazyHStack arranges child views in a horizontal stack with lazy rendering.
func LazyVStack ¶
LazyVStack arranges child views in a vertical stack with lazy rendering.
func NavigationLink ¶
NavigationLink creates a link to a destination view within a NavigationStack.
func NavigationStack ¶
NavigationStack wraps content in a navigation container.
func PickerMenu ¶
PickerMenu creates a dropdown menu picker bound to an IntState.
func PickerSegmented ¶
PickerSegmented creates a segmented picker bound to an IntState.
func ProgressLinear ¶
ProgressLinear creates a determinate linear progress indicator.
func ProgressSpinning ¶
func ProgressSpinning() View
ProgressSpinning creates an indeterminate spinning progress indicator.
func ScrollView ¶
ScrollView wraps content in a vertically scrollable container.
func SecureField ¶
func SecureField(placeholder string, state *StringState, onSubmit func()) View
SecureField creates a password input field bound to a StringState.
func TextEditor ¶
func TextEditor(state *StringState) View
TextEditor creates a multiline text editor bound to a StringState.
func TextField ¶
func TextField(placeholder string, state *StringState, onSubmit func()) View
TextField creates a text input field bound to a StringState.
func VStackSpaced ¶
VStackSpaced arranges child views in a vertical stack with explicit spacing.
func ViewFromPointer ¶
ViewFromPointer creates a View from a raw pointer. This is used by companion packages (e.g. charts) that construct views via their own Swift bridge functions.
func (View) AccessibilityHidden ¶
AccessibilityHidden hides the view from accessibility features.
func (View) AccessibilityHint ¶
AccessibilityHint sets the accessibility hint for the view.
func (View) AccessibilityLabel ¶
AccessibilityLabel sets the accessibility label for the view.
func (View) AllowsHitTesting ¶
AllowsHitTesting controls whether the view receives hit-test events.
func (View) Animation ¶
func (v View) Animation(kind AnimationKind) View
Animation applies an animation curve to the view.
func (View) AspectRatio ¶
func (v View) AspectRatio(ratio float64, contentMode ContentMode) View
AspectRatio constrains the view to the given aspect ratio. ContentMode: 0=fit, 1=fill.
func (View) Background ¶
Background sets a background color using RGBA values.
func (View) BackgroundRoundedRect ¶
func (v View) BackgroundRoundedRect(r float64, g float64, b float64, a float64, cornerRadius float64) View
BackgroundRoundedRect sets a rounded rectangle background.
func (View) BackgroundStyle ¶
BackgroundStyle sets a named background style (e.g. "regularMaterial", "windowBackground").
func (View) ButtonStyle ¶
func (v View) ButtonStyle(style ButtonStyleKind) View
ButtonStyle sets the button style for the view hierarchy.
func (View) ClipRoundedRect ¶
ClipRoundedRect clips the view to a rounded rectangle.
func (View) ConfirmationDialog ¶
ConfirmationDialog presents a confirmation dialog with custom actions when the IntState is nonzero.
func (View) ContextMenu ¶
ContextMenu adds a right-click context menu to the view.
func (View) ControlSize ¶
func (v View) ControlSize(size ControlSize) View
ControlSize sets the control size for the view hierarchy.
func (View) CornerRadius ¶
CornerRadius clips the view to a rounded rectangle.
func (View) FixedSizeAxis ¶
FixedSizeAxis prevents expansion along specific axes.
func (View) FontDesign ¶
FontDesign sets the font design for text in the view.
func (View) FontWeight ¶
FontWeight sets the font weight for text in the view.
func (View) ForegroundStyle ¶
ForegroundStyle sets the foreground color using RGBA values.
func (View) ForegroundStyleNamed ¶
ForegroundStyleNamed sets a named foreground style (primary, secondary, tertiary, quaternary).
func (View) FullScreenCover ¶
FullScreenCover presents a full-screen modal when the IntState is nonzero.
func (View) ImageScale ¶
func (v View) ImageScale(scale ImageScale) View
ImageScale sets the scale for SF Symbol images.
func (View) LayoutPriority ¶
LayoutPriority sets the layout priority for this view.
func (View) ListRowBackground ¶
ListRowBackground sets a custom background for a list row.
func (View) ListStyle ¶
func (v View) ListStyle(style ListStyleKind) View
ListStyle sets the list display style.
func (View) MaxFrame ¶
MaxFrame sets maximum width/height constraints. Use -1 for .infinity, 0 for nil.
func (View) NavigationTitle ¶
NavigationTitle sets the navigation title for the view.
func (View) OnDisappear ¶
OnDisappear adds an action to perform when the view disappears.
func (View) OnTapGesture ¶
OnTapGesture adds a tap gesture handler to the view.
func (View) PaddingEdge ¶
PaddingEdge applies padding to specific edges.
func (View) Pointer ¶
Pointer returns the underlying opaque pointer. This is used by companion packages that need to pass views to bridge functions.
func (*View) Release ¶
func (v *View) Release()
Release decrements the underlying Swift retain count.
func (View) RotationEffect ¶
RotationEffect rotates the view by the given angle in degrees.
func (View) ScaleEffect ¶
ScaleEffect scales the view uniformly.
func (View) Shadow ¶
func (v View) Shadow(r float64, g float64, b float64, a float64, radius float64, x float64, y float64) View
Shadow adds a shadow effect to the view.
func (View) TextFieldStyle ¶
func (v View) TextFieldStyle(style TextFieldStyleKind) View
TextFieldStyle sets the style for text fields.
func (View) WebViewBackForwardNavigationGestures ¶
func (v View) WebViewBackForwardNavigationGestures(behavior WebViewBehavior) View
WebViewBackForwardNavigationGestures controls web view back/forward gesture behavior.
func (View) WebViewContentBackground ¶
func (v View) WebViewContentBackground(visibility WebViewContentBackgroundVisibility) View
WebViewContentBackground controls visibility of the web view content background.
func (View) WebViewElementFullscreenBehavior ¶
func (v View) WebViewElementFullscreenBehavior(behavior WebViewBehavior) View
WebViewElementFullscreenBehavior controls full-screen behavior for web page elements.
func (View) WebViewLinkPreviews ¶
func (v View) WebViewLinkPreviews(behavior WebViewBehavior) View
WebViewLinkPreviews controls whether link previews are shown.
func (View) WebViewMagnificationGestures ¶
func (v View) WebViewMagnificationGestures(behavior WebViewBehavior) View
WebViewMagnificationGestures controls magnification gesture behavior.
func (View) WebViewTextSelection ¶
WebViewTextSelection enables or disables text selection in the web view.
type Viewable ¶
type Viewable interface {
// contains filtered or unexported methods
}
Viewable is satisfied by View, ShapeView, and TextView. Container functions accept Viewable so any view type can be passed directly.
type WebPage
deprecated
type WebPage struct {
// contains filtered or unexported fields
}
WebPage is a retained handle to a Swift WebPage object.
Deprecated: Use webkit.NewWebPage from swift-bridge/webkit instead. This type provides only basic navigation; the webkit package exposes the full WebPage API (Title, URL, EstimatedProgress, JavaScript, PDF export, and more). To embed a web page in SwiftUI, use swiftui.ViewFromPointer(webkit.NewWebView(page)).
func NewWebPage
deprecated
func NewWebPage() *WebPage
NewWebPage creates a new WebPage handle.
Deprecated: Use webkit.NewWebPage from swift-bridge/webkit instead.
func NewWebPageURL
deprecated
type WebViewBehavior ¶
type WebViewBehavior int32
WebViewBehavior identifies web view feature behavior.
const ( WebViewBehaviorAutomatic WebViewBehavior = 0 WebViewBehaviorEnabled WebViewBehavior = 1 WebViewBehaviorDisabled WebViewBehavior = 2 )
type WebViewContentBackgroundVisibility ¶
type WebViewContentBackgroundVisibility int32
WebViewContentBackgroundVisibility identifies web view content background visibility.
const ( WebViewContentBackgroundAutomatic WebViewContentBackgroundVisibility = 0 WebViewContentBackgroundVisible WebViewContentBackgroundVisibility = 1 WebViewContentBackgroundHidden WebViewContentBackgroundVisibility = 2 )
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package arkit provides Go bindings for Apple's ARKit SwiftUI cross-import overlay (_ARKit_SwiftUI).
|
Package arkit provides Go bindings for Apple's ARKit SwiftUI cross-import overlay (_ARKit_SwiftUI). |
|
Package avkit provides Go bindings for Apple's AVKit SwiftUI cross-import overlay (_AVKit_SwiftUI).
|
Package avkit provides Go bindings for Apple's AVKit SwiftUI cross-import overlay (_AVKit_SwiftUI). |
|
Package charts provides Go bindings for Apple's Charts framework.
|
Package charts provides Go bindings for Apple's Charts framework. |
|
Package charts3d provides Go bindings for the 3D portion of Apple's Charts framework.
|
Package charts3d provides Go bindings for the 3D portion of Apple's Charts framework. |
|
cmd
|
|
|
swiftgovet
command
Command swiftgovet provides project-specific vet checks for SwiftUI Go code.
|
Command swiftgovet provides project-specific vet checks for SwiftUI Go code. |
|
dist
|
|
|
examples
|
|
|
accessibility
command
Command accessibility demonstrates SwiftUI accessibility modifiers from Go.
|
Command accessibility demonstrates SwiftUI accessibility modifiers from Go. |
|
animation
command
Command animation demonstrates SwiftUI animations and transitions from Go.
|
Command animation demonstrates SwiftUI animations and transitions from Go. |
|
benchview
command
|
|
|
calculator
command
Command calculator demonstrates a working calculator app built with SwiftUI from Go.
|
Command calculator demonstrates a working calculator app built with SwiftUI from Go. |
|
charts
command
Command charts showcases native Swift Charts bindings generated for Go.
|
Command charts showcases native Swift Charts bindings generated for Go. |
|
color-lab
command
Command color-lab is an interactive color mixing and exploration tool.
|
Command color-lab is an interactive color mixing and exploration tool. |
|
counter
command
Command counter demonstrates reactive state management with SwiftUI from Go.
|
Command counter demonstrates reactive state management with SwiftUI from Go. |
|
dark-light
command
Command dark-light showcases semantic foreground and background styles.
|
Command dark-light showcases semantic foreground and background styles. |
|
dashboard
command
Command dashboard demonstrates a multi-tab live dashboard with real-time Go runtime metrics, navigation, and interactive controls.
|
Command dashboard demonstrates a multi-tab live dashboard with real-time Go runtime metrics, navigation, and interactive controls. |
|
dynamic-list
command
Command dynamic-list demonstrates reactive list updates with SwiftUI from Go.
|
Command dynamic-list demonstrates reactive list updates with SwiftUI from Go. |
|
form
command
Command form demonstrates SwiftUI form controls from Go.
|
Command form demonstrates SwiftUI form controls from Go. |
|
glass
command
Command glass demonstrates material and translucency effects in SwiftUI from Go, showcasing the liquid glass aesthetic on macOS 26+.
|
Command glass demonstrates material and translucency effects in SwiftUI from Go, showcasing the liquid glass aesthetic on macOS 26+. |
|
hello-world
command
Command hello-world is a minimal but polished SwiftUI app from Go.
|
Command hello-world is a minimal but polished SwiftUI app from Go. |
|
kanban
command
Command kanban demonstrates a three-column Kanban board with card management.
|
Command kanban demonstrates a three-column Kanban board with card management. |
|
layout
command
Command layout demonstrates SwiftUI layout composition and visual styling from Go.
|
Command layout demonstrates SwiftUI layout composition and visual styling from Go. |
|
markdown-editor
command
Command markdown-editor demonstrates a split-pane text editor with live preview.
|
Command markdown-editor demonstrates a split-pane text editor with live preview. |
|
menu-bar
command
Command menu-bar demonstrates modal presentations in SwiftUI from Go.
|
Command menu-bar demonstrates modal presentations in SwiftUI from Go. |
|
music-player
command
Command music-player demonstrates a rich music player UI with playlist navigation, now-playing view, and audio visualizer using SwiftUI from Go.
|
Command music-player demonstrates a rich music player UI with playlist navigation, now-playing view, and audio visualizer using SwiftUI from Go. |
|
password-generator
command
Command password-generator demonstrates a password generator and strength analyzer built with SwiftUI from Go.
|
Command password-generator demonstrates a password generator and strength analyzer built with SwiftUI from Go. |
|
pomodoro
command
Command pomodoro demonstrates a Pomodoro technique timer built with SwiftUI from Go.
|
Command pomodoro demonstrates a Pomodoro technique timer built with SwiftUI from Go. |
|
quicklook-preview
command
Command quicklook-preview demonstrates the QuickLook SwiftUI overlay bridge.
|
Command quicklook-preview demonstrates the QuickLook SwiftUI overlay bridge. |
|
quiz
command
Command quiz demonstrates an interactive Go trivia game with animated transitions, scoring, and results using SwiftUI from Go.
|
Command quiz demonstrates an interactive Go trivia game with animated transitions, scoring, and results using SwiftUI from Go. |
|
settings
command
Command settings demonstrates a comprehensive macOS settings panel built with SwiftUI from Go.
|
Command settings demonstrates a comprehensive macOS settings panel built with SwiftUI from Go. |
|
system-monitor
command
Command system-monitor displays live Go runtime metrics using SwiftUI gauges and progress bars, updated every two seconds from a background goroutine.
|
Command system-monitor displays live Go runtime metrics using SwiftUI gauges and progress bars, updated every two seconds from a background goroutine. |
|
tabs
command
Command tabs demonstrates a polished tabbed workspace built with SwiftUI from Go.
|
Command tabs demonstrates a polished tabbed workspace built with SwiftUI from Go. |
|
timer
command
Command timer demonstrates Go goroutines driving reactive SwiftUI updates.
|
Command timer demonstrates Go goroutines driving reactive SwiftUI updates. |
|
video-player
command
Command video-player demonstrates the AVKit SwiftUI overlay bridge.
|
Command video-player demonstrates the AVKit SwiftUI overlay bridge. |
|
web-browser
command
Command web-browser demonstrates WebView embedding in SwiftUI from Go.
|
Command web-browser demonstrates WebView embedding in SwiftUI from Go. |
|
internal
|
|
|
swiftgovet/browseraction
Package browseraction reports browser controls wired to no-op callbacks.
|
Package browseraction reports browser controls wired to no-op callbacks. |
|
swiftgovet/settingsaction
Package settingsaction reports misleading Save and Revert button handlers.
|
Package settingsaction reports misleading Save and Revert button handlers. |
|
swiftgovet/swiftuiast
Package swiftuiast provides small helpers for SwiftUI-specific analyzers.
|
Package swiftuiast provides small helpers for SwiftUI-specific analyzers. |
|
Package localauth provides Go bindings for Apple's LocalAuthentication SwiftUI cross-import overlay (_LocalAuthentication_SwiftUI).
|
Package localauth provides Go bindings for Apple's LocalAuthentication SwiftUI cross-import overlay (_LocalAuthentication_SwiftUI). |
|
Package quicklook provides Go bindings for Apple's QuickLook SwiftUI cross-import overlay (_QuickLook_SwiftUI).
|
Package quicklook provides Go bindings for Apple's QuickLook SwiftUI cross-import overlay (_QuickLook_SwiftUI). |
|
Package scenekit provides Go bindings for Apple's SceneKit SwiftUI cross-import overlay (_SceneKit_SwiftUI).
|
Package scenekit provides Go bindings for Apple's SceneKit SwiftUI cross-import overlay (_SceneKit_SwiftUI). |
|
Package spritekit provides Go bindings for Apple's SpriteKit SwiftUI cross-import overlay (_SpriteKit_SwiftUI).
|
Package spritekit provides Go bindings for Apple's SpriteKit SwiftUI cross-import overlay (_SpriteKit_SwiftUI). |
|
Package translation provides Go bindings for Apple's Translation SwiftUI cross-import overlay (_Translation_SwiftUI).
|
Package translation provides Go bindings for Apple's Translation SwiftUI cross-import overlay (_Translation_SwiftUI). |
|
Package workoutkit provides Go bindings for Apple's WorkoutKit SwiftUI cross-import overlay (_WorkoutKit_SwiftUI).
|
Package workoutkit provides Go bindings for Apple's WorkoutKit SwiftUI cross-import overlay (_WorkoutKit_SwiftUI). |