swiftui-native 0.0.1

SwiftUI from pure Rust — no Swift bridge, no shim, only swift-runtime calls
Documentation
//! Modifiers with several plain arguments.

use super::*;
use crate::abi;
use crate::resolve;
//
// Generated from each function's demangled signature: integer-shaped arguments
// fill x0 upward and floats fill d0 upward, in declaration order, with strings
// taking two words and a `LocalizedStringKey` or a `Text` taking four.

swift_statics! {
    /// `SwiftUI.AccessibilityChildBehavior`.
    ///
    /// The cases are the type's documented static properties.
    pub enum AccessibilityChildBehavior {
        Combine = c"$s7SwiftUI26AccessibilityChildBehaviorV7combineACvgZ",
        Contain = c"$s7SwiftUI26AccessibilityChildBehaviorV7containACvgZ",
        Ignore = c"$s7SwiftUI26AccessibilityChildBehaviorV6ignoreACvgZ",
    }
}

swift_statics! {
    /// `SwiftUI.ContentMarginPlacement`.
    ///
    /// The cases are the type's documented static properties.
    pub enum ContentMarginPlacement {
        Automatic = c"$s7SwiftUI22ContentMarginPlacementV9automaticACvgZ",
        ScrollIndicators = c"$s7SwiftUI22ContentMarginPlacementV16scrollIndicatorsACvgZ",
    }
}

swift_statics! {
    /// `SwiftUI.HandGestureShortcut`.
    ///
    /// The cases are the type's documented static properties.
    pub enum HandGestureShortcut {
        PrimaryAction = c"$s7SwiftUI19HandGestureShortcutV13primaryActionACvgZ",
    }
}

swift_statics! {
    /// `SwiftUI.RedactionReasons`.
    ///
    /// The cases are the type's documented static properties.
    pub enum RedactionReasons {
        Invalidated = c"$s7SwiftUI16RedactionReasonsV11invalidatedACvgZ",
        Placeholder = c"$s7SwiftUI16RedactionReasonsV11placeholderACvgZ",
        Privacy = c"$s7SwiftUI16RedactionReasonsV7privacyACvgZ",
    }
}

swift_statics! {
    /// `SwiftUI.TabBarMinimizeBehavior`.
    ///
    /// The cases are the type's documented static properties.
    pub enum TabBarMinimizeBehavior {
        Automatic = c"$s7SwiftUI22TabBarMinimizeBehaviorV9automaticACvgZ",
    }
}

swift_statics! {
    /// `SwiftUI.ToolbarRole`.
    ///
    /// The cases are the type's documented static properties.
    pub enum ToolbarRole {
        Automatic = c"$s7SwiftUI11ToolbarRoleV9automaticACvgZ",
        Editor = c"$s7SwiftUI11ToolbarRoleV6editorACvgZ",
    }
}

swift_statics! {
    /// `SwiftUI.TypesettingLanguage`.
    ///
    /// The cases are the type's documented static properties.
    pub enum TypesettingLanguage {
        Automatic = c"$s7SwiftUI19TypesettingLanguageV9automaticACvgZ",
    }
}

/// Apply `.accessibilityElement(_:)`.
pub fn accessibility_element(view: &ViewHandle, v0: AccessibilityChildBehavior) -> ViewHandle {
    unsafe {
        let m0 = abi::metadata0(resolve::accessibility_child_behavior_ma());
        let mut a0 = static_getter_indirect(v0.resolved(), m0, 0);
        opaque_modifier(
            resolve::accessibility_element_fn(),
            resolve::accessibility_element_oret(),
            view,
            &[a0.as_mut_ptr() as u64],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.accessibilityShowsLargeContentViewer(_:)`.
pub fn accessibility_shows_large_content_viewer(view: &ViewHandle, ) -> ViewHandle {
    unsafe {
        // no argument needs building
        opaque_modifier(
            resolve::accessibility_shows_large_content_viewer_fn(),
            resolve::accessibility_shows_large_content_viewer_oret(),
            view,
            &[],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.assistiveAccessNavigationIcon(_:)`.
pub fn assistive_access_navigation_icon(view: &ViewHandle, v0: &str) -> ViewHandle {
    unsafe {
        let s0 = abi::swift_string(v0);
        opaque_modifier(
            resolve::assistive_access_navigation_icon_fn(),
            resolve::assistive_access_navigation_icon_oret(),
            view,
            &[u64::from_le_bytes(s0[..8].try_into().expect("lo")), u64::from_le_bytes(s0[8..].try_into().expect("hi"))],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.contentMargins(_:)`.
pub fn content_margins(view: &ViewHandle, v0: f64, v1: ContentMarginPlacement) -> ViewHandle {
    unsafe {
        let m1 = abi::metadata0(resolve::content_margin_placement_ma());
        let mut a1 = static_getter_indirect(v1.resolved(), m1, 0);
        opaque_modifier(
            resolve::content_margins_fn(),
            resolve::content_margins_oret(),
            view,
            &[a1.as_mut_ptr() as u64],
            [v0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.handGestureShortcut(_:)`.
pub fn hand_gesture_shortcut(view: &ViewHandle, v0: HandGestureShortcut, v1: bool) -> ViewHandle {
    unsafe {
        let m0 = abi::metadata0(resolve::hand_gesture_shortcut_ma());
        let mut a0 = static_getter_indirect(v0.resolved(), m0, 0);
        opaque_modifier(
            resolve::hand_gesture_shortcut_fn(),
            resolve::hand_gesture_shortcut_oret(),
            view,
            &[a0.as_mut_ptr() as u64, u64::from(v1)],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.position(_:)`.
pub fn position(view: &ViewHandle, v0: f64, v1: f64) -> ViewHandle {
    unsafe {
        // no argument needs building
        opaque_modifier(
            resolve::position_fn(),
            resolve::position_oret(),
            view,
            &[],
            [v0, v1, 0.0, 0.0],
        )
    }
}


/// Apply `.redacted(_:)`.
pub fn redacted(view: &ViewHandle, v0: RedactionReasons) -> ViewHandle {
    unsafe {
        let m0 = abi::metadata0(resolve::redaction_reasons_ma());
        let mut a0 = static_getter_indirect(v0.resolved(), m0, 0);
        opaque_modifier(
            resolve::redacted_fn(),
            resolve::redacted_oret(),
            view,
            &[a0.as_mut_ptr() as u64],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.scrollIndicatorsFlash(_:)`.
pub fn scroll_indicators_flash(view: &ViewHandle, v0: bool) -> ViewHandle {
    unsafe {
        // no argument needs building
        opaque_modifier(
            resolve::scroll_indicators_flash_fn(),
            resolve::scroll_indicators_flash_oret(),
            view,
            &[u64::from(v0)],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.scrollTargetLayout(_:)`.
pub fn scroll_target_layout(view: &ViewHandle, v0: bool) -> ViewHandle {
    unsafe {
        // no argument needs building
        opaque_modifier(
            resolve::scroll_target_layout_fn(),
            resolve::scroll_target_layout_oret(),
            view,
            &[u64::from(v0)],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.tabBarMinimizeBehavior(_:)`.
pub fn tab_bar_minimize_behavior(view: &ViewHandle, v0: TabBarMinimizeBehavior) -> ViewHandle {
    unsafe {
        let m0 = abi::metadata0(resolve::tab_bar_minimize_behavior_ma());
        let mut a0 = static_getter_indirect(v0.resolved(), m0, 0);
        opaque_modifier(
            resolve::tab_bar_minimize_behavior_fn(),
            resolve::tab_bar_minimize_behavior_oret(),
            view,
            &[a0.as_mut_ptr() as u64],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.toolbarRole(_:)`.
pub fn toolbar_role(view: &ViewHandle, v0: ToolbarRole) -> ViewHandle {
    unsafe {
        let m0 = abi::metadata0(resolve::toolbar_role_ma());
        let mut a0 = static_getter_indirect(v0.resolved(), m0, 0);
        opaque_modifier(
            resolve::toolbar_role_fn(),
            resolve::toolbar_role_oret(),
            view,
            &[a0.as_mut_ptr() as u64],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.typesettingLanguage(_:)`.
pub fn typesetting_language(view: &ViewHandle, v0: TypesettingLanguage, v1: bool) -> ViewHandle {
    unsafe {
        let m0 = abi::metadata0(resolve::typesetting_language_ma());
        let mut a0 = static_getter_indirect(v0.resolved(), m0, 0);
        opaque_modifier(
            resolve::typesetting_language_fn(),
            resolve::typesetting_language_oret(),
            view,
            &[a0.as_mut_ptr() as u64, u64::from(v1)],
            [0.0, 0.0, 0.0, 0.0],
        )
    }
}

/// Apply `.inspectorColumnWidth(min:ideal:max:)` — a width the user can drag
/// within.
///
/// `min` and `max` are `Optional<CGFloat>` and `ideal` is not, which is exactly
/// how they travel: an `Optional<CGFloat>` is lowered as payload-then-tag in
/// *integer* registers — the same shape [`frame_optional`](super::frame_optional)
/// passes — while the bare `ideal` goes in `d0` with the floats. Leaving a bound
/// out is not the same as pinning it to zero: `None` means the column is
/// unconstrained in that direction.
pub fn inspector_column_width_range(
    view: &ViewHandle,
    min: Option<f64>,
    ideal: f64,
    max: Option<f64>,
) -> ViewHandle {
    unsafe {
        opaque_modifier(
            resolve::inspector_column_width_range_fn(),
            resolve::inspector_column_width_range_oret(),
            view,
            &[
                min.map_or(0, f64::to_bits),
                u64::from(min.is_none()),
                max.map_or(0, f64::to_bits),
                u64::from(max.is_none()),
            ],
            [ideal, 0.0, 0.0, 0.0],
        )
    }
}

// `.scrollInputBehavior(_:for:)` is deliberately not bound.
//
// The modifier itself is available from macOS 15, and its two arguments are
// reachable — but every `ScrollInputKind` is `@available(macOS, unavailable)`
// *and* `@available(iOS, unavailable)`: `handGestureShortcut` is watchOS-only
// and `look` visionOS-only. So on both platforms this crate targets there is no
// value to pass, and calling it reaches the trap stub with "Unavailable code
// reached".
//
// It was bound, and the binding worked — which is the point of the note. A
// modifier that compiles and traps on every platform anyone here can run is
// worse than an absent one, because it looks available.
//
// Worth recording separately: the two argument types measure one byte and
// three, and neither is `@frozen`. Size says nothing about how a value
// travels; resilient types go by address, and reading these into registers on
// the strength of their size was a SIGBUS.