swiftui-native 0.0.1

SwiftUI from pure Rust — no Swift bridge, no shim, only swift-runtime calls
Documentation
//! Styling the standard controls, and the lists and tabs that hold them.
//!
//! Part of [`crate::view::View`]'s chainable API; Rust allows a type's
//! inherent methods to be split across modules, and 400 of them in one file
//! was a file nobody could find anything in.

use super::{Color, View};
use crate::views;

impl View {
    // ── Control styles ──
    //
    // SwiftUI styles a control through the environment, so each of these is set
    // on a container and applies to every control of that kind below it. They
    // are one-liners over functions that were all already here.

    /// `.toggleStyle(_:)`
    pub fn toggle_style(self, style: views::ToggleStyle) -> Self {
        Self::new(views::toggle_style(&self.handle, style))
    }

    /// `.pickerStyle(_:)`
    pub fn picker_style(self, style: views::PickerStyle) -> Self {
        Self::new(views::picker_style(&self.handle, style))
    }

    /// `.datePickerStyle(_:)`
    pub fn date_picker_style(self, style: views::DatePickerStyle) -> Self {
        Self::new(views::date_picker_style(&self.handle, style))
    }

    /// `.gaugeStyle(_:)`
    pub fn gauge_style(self, style: views::GaugeStyle) -> Self {
        Self::new(views::gauge_style(&self.handle, style))
    }

    /// `.formStyle(_:)`
    pub fn form_style(self, style: views::FormStyle) -> Self {
        Self::new(views::form_style(&self.handle, style))
    }

    /// `.groupBoxStyle(_:)`
    pub fn group_box_style(self, style: views::GroupBoxStyle) -> Self {
        Self::new(views::group_box_style(&self.handle, style))
    }

    /// `.controlGroupStyle(_:)`
    pub fn control_group_style(self, style: views::ControlGroupStyle) -> Self {
        Self::new(views::control_group_style(&self.handle, style))
    }

    /// `.disclosureGroupStyle(_:)`
    pub fn disclosure_group_style(self, style: views::DisclosureGroupStyle) -> Self {
        Self::new(views::disclosure_group_style(&self.handle, style))
    }

    /// `.tableStyle(_:)`
    pub fn table_style(self, style: views::TableStyle) -> Self {
        Self::new(views::table_style(&self.handle, style))
    }

    /// `.textEditorStyle(_:)`
    pub fn text_editor_style(self, style: views::TextEditorStyle) -> Self {
        Self::new(views::text_editor_style(&self.handle, style))
    }

    /// `.labeledContentStyle(_:)`
    pub fn labeled_content_style(self, style: views::LabeledContentStyle) -> Self {
        Self::new(views::labeled_content_style(&self.handle, style))
    }

    /// `.textSelection(_:)` — whether the user can select and copy the text.
    pub fn text_selection(self, style: views::TextSelectability) -> Self {
        Self::new(views::text_selection(&self.handle, style))
    }

    /// `.buttonRepeatBehavior(_:)` — whether holding repeats the action.
    pub fn button_repeat_behavior(self, value: views::ButtonRepeatBehavior) -> Self {
        Self::new(views::button_repeat_behavior(&self.handle, value))
    }

    /// `.buttonSizing(_:)`
    pub fn button_sizing(self, value: views::ButtonSizing) -> Self {
        Self::new(views::button_sizing(&self.handle, value))
    }

    /// `.menuButtonStyle(_:)`
    pub fn menu_button_style(self, style: views::MenuButtonStyle) -> Self {
        Self::new(views::menu_button_style(&self.handle, style))
    }

    /// `.menuActionDismissBehavior(_:)` — whether choosing an item closes the menu.
    pub fn menu_action_dismiss_behavior(self, value: views::MenuActionDismissBehavior) -> Self {
        Self::new(views::menu_action_dismiss_behavior(&self.handle, value))
    }

    /// `.sliderThumbVisibility(_:)`
    pub fn slider_thumb_visibility(self, value: views::Visibility) -> Self {
        Self::new(views::slider_thumb_visibility(&self.handle, value))
    }

    /// `.springLoadingBehavior(_:)` — whether hovering a drag over this opens it.
    pub fn spring_loading_behavior(self, value: views::SpringLoadingBehavior) -> Self {
        Self::new(views::spring_loading_behavior(&self.handle, value))
    }

    /// `.paletteSelectionEffect(_:)`
    pub fn palette_selection_effect(self, value: views::PaletteSelectionEffect) -> Self {
        Self::new(views::palette_selection_effect(&self.handle, value))
    }

    /// `.materialActiveAppearance(_:)`
    pub fn material_active_appearance(self, value: views::MaterialActiveAppearance) -> Self {
        Self::new(views::material_active_appearance(&self.handle, value))
    }

    /// `.progressViewStyle(.circular)`
    pub fn progress_view_style_circular(self) -> Self {
        Self::new(views::progress_view_style_circular(&self.handle))
    }

    // ── Menus, labels and badges ──

    /// `.menuIndicator(_:)` — the chevron that says a control opens a menu.
    pub fn menu_indicator(self, visibility: views::Visibility) -> Self {
        Self::new(views::menu_indicator(&self.handle, visibility))
    }

    /// `.menuOrder(_:)`
    pub fn menu_order(self, order: views::MenuOrder) -> Self {
        Self::new(views::menu_order(&self.handle, order))
    }

    /// `.labelsVisibility(_:)` — hiding a label keeps it for VoiceOver while
    /// taking it off the screen, which `.hidden()` does not.
    pub fn labels_visibility(self, visibility: views::Visibility) -> Self {
        Self::new(views::labels_visibility(&self.handle, visibility))
    }

    /// `.headerProminence(_:)`
    pub fn header_prominence(self, prominence: views::Prominence) -> Self {
        Self::new(views::header_prominence(&self.handle, prominence))
    }

    /// `.badgeProminence(_:)`
    pub fn badge_prominence(self, prominence: views::BadgeProminence) -> Self {
        Self::new(views::badge_prominence(&self.handle, prominence))
    }

    // ── Lists and tables ──

    /// `.listStyle(_:)`
    pub fn list_style(self, style: views::ListStyle) -> Self {
        Self::new(views::list_style(&self.handle, style))
    }

    /// `.listRowInsets(_:)` as `[top, leading, bottom, trailing]`; `None`
    /// restores the default inset.
    pub fn list_row_insets(self, insets: Option<[f64; 4]>) -> Self {
        Self::new(views::list_row_insets(&self.handle, insets))
    }

    /// `.listRowSeparator(_:edges:)`
    pub fn list_row_separator(
        self,
        visibility: views::Visibility,
        edges: views::VerticalEdgeSet,
    ) -> Self {
        Self::new(views::list_row_separator(&self.handle, visibility, edges))
    }

    /// `.listSectionSeparator(_:edges:)`
    pub fn list_section_separator(
        self,
        visibility: views::Visibility,
        edges: views::VerticalEdgeSet,
    ) -> Self {
        Self::new(views::list_section_separator(&self.handle, visibility, edges))
    }

    /// `.selectionDisabled(_:)` — a row that shows but cannot be picked.
    pub fn selection_disabled(self, disabled: bool) -> Self {
        Self::new(views::selection_disabled(&self.handle, disabled))
    }

    /// `.swipeActions(edge:allowsFullSwipe:content:)`
    pub fn swipe_actions(
        self,
        edge: views::HorizontalEdge,
        allows_full_swipe: bool,
        content: View,
    ) -> Self {
        Self::new(views::swipe_actions(
            &self.handle,
            edge,
            allows_full_swipe,
            content.handle(),
        ))
    }

    /// `.refreshable(action:)` — pull to refresh.
    pub fn refreshable(self, action: impl Fn() + Send + Sync + 'static) -> Self {
        Self::new(views::refreshable(&self.handle, action))
    }

    /// `.scrollDismissesKeyboard(_:)` — what scrolling does to an open keyboard.
    pub fn scroll_dismisses_keyboard(self, mode: views::ScrollDismissesKeyboardMode) -> Self {
        Self::new(views::scroll_dismisses_keyboard(&self.handle, mode))
    }

    /// `.listRowSeparatorTint(_:edges:)` — `None` restores the default.
    pub fn list_row_separator_tint(
        self,
        color: Option<Color>,
        edges: &[views::VerticalEdgeSet],
    ) -> Self {
        Self::new(views::list_row_separator_tint(&self.handle, color, edges))
    }

    /// `.listSectionSeparatorTint(_:edges:)`
    pub fn list_section_separator_tint(
        self,
        color: Option<Color>,
        edges: &[views::VerticalEdgeSet],
    ) -> Self {
        Self::new(views::list_section_separator_tint(&self.handle, color, edges))
    }

    /// `.listItemTint(.monochrome)`
    pub fn list_item_tint_monochrome(self, tinted: bool) -> Self {
        Self::new(views::list_item_tint_monochrome(&self.handle, tinted))
    }

    /// `.alternatingRowBackgrounds(_:)`
    pub fn alternating_row_backgrounds(
        self,
        value: views::AlternatingRowBackgroundBehavior,
    ) -> Self {
        Self::new(views::alternating_row_backgrounds(&self.handle, value))
    }

    /// `.sectionActions(content:)` — controls in a section's header area.
    pub fn section_actions(self, content: View) -> Self {
        Self::new(views::section_actions(&self.handle, content.handle()))
    }

    /// `.sectionIndexLabel(_:)` — the letter this section shows in a scrubber.
    pub fn section_index_label(self, label: &str) -> Self {
        Self::new(views::section_index_label(&self.handle, label))
    }

    /// `.tableColumnHeaders(_:)`
    pub fn table_column_headers(self, visibility: views::Visibility) -> Self {
        Self::new(views::table_column_headers(&self.handle, visibility))
    }

    // ── Tab chrome ──

    /// `.tabViewStyle(.automatic)`
    pub fn tab_view_style_automatic(self) -> Self {
        Self::new(views::tab_view_style_automatic(&self.handle))
    }

    /// `.tabViewCustomization(nil)`
    pub fn tab_view_customization_none(self) -> Self {
        Self::new(views::tab_view_customization_none(&self.handle))
    }

    /// `.tabViewSearchActivation(.automatic)`
    pub fn tab_view_search_activation_automatic(self) -> Self {
        Self::new(views::tab_view_search_activation_automatic(&self.handle))
    }

    /// `.tabViewSidebarHeader { … }`
    pub fn tab_view_sidebar_header(self, content: View) -> Self {
        Self::new(views::tab_view_sidebar_header(&self.handle, content.handle()))
    }

    /// `.tabViewSidebarFooter { … }`
    pub fn tab_view_sidebar_footer(self, content: View) -> Self {
        Self::new(views::tab_view_sidebar_footer(&self.handle, content.handle()))
    }

    /// `.tabViewSidebarBottomBar { … }`
    pub fn tab_view_sidebar_bottom_bar(self, content: View) -> Self {
        Self::new(views::tab_view_sidebar_bottom_bar(&self.handle, content.handle()))
    }

    /// `.tabBarMinimizeBehavior(_:)`
    pub fn tab_bar_minimize_behavior(self, value: views::TabBarMinimizeBehavior) -> Self {
        Self::new(views::tab_bar_minimize_behavior(&self.handle, value))
    }

}