GPUI Box GitHub

Components / datetime

TimeInput view

A segmented time field over the host's own clock.

A view survives a frame. Hold it in an Entity with cx.new(..) and reach it with .update(..).

use gpui_kit::datetime::TimeInput;

Reviewed in date-time touch-dates.

Construct
new(ident: impl Into<Ident>, adapter: SharedDateAdapter, _window: &mut Window, cx: &mut Context<Self>) -> Self
Options

Chain onto the value.

value(value: TimeOfDay) -> Self
seconds(seconds: bool) -> Self
invalid(invalid: bool) -> Self
Commands

Need a Context, so they need a view.

set_value(value: TimeOfDay, cx: &mut Context<Self>)
set_seconds(seconds: bool, cx: &mut Context<Self>)
set_control_size(size: ControlSize, cx: &mut Context<Self>)
set_disabled(disabled: bool, cx: &mut Context<Self>)
set_invalid(invalid: bool, cx: &mut Context<Self>)
Queries

Only answer; they change nothing.

is_disabled() -> bool
current() -> TimeOfDay
active_segment() -> Segment
clock() -> Clock
Reports

The variants of the event it emits. It never applies the change itself.

  • Changed
Example · date-time
fn date_time(window: &mut Window, cx: &mut App) -> AnyElement {
    ensure(window, cx);
    let theme = cx.theme().clone();
    let dates = cx.global::<SceneDates>();
    let (field, refused, clock, twelve) = (
        dates.field.clone(),
        dates.refused.clone(),
        dates.clock.clone(),
        dates.twelve.clone(),
    );
    stack(&theme)
        .child(div().w(px(280.0)).child(field))
        .child(div().w(px(280.0)).child(refused))
        .child(
            row(&theme)
                .gap(px(theme.space(Space::Lg)))
                .child(clock)
                .child(twelve),
        )
        .child(
            crate::foundation::text(
                &theme,
                TypeScale::Body,
                "What the field could not read is still in it, and the refusal is the \
                     adapter's own sentence.",
            )
            .max_w(px(560.0))
            .text_tone(&theme, TextTone::Muted),
        )
        .into_any_element()
}

Source: crates/gpui-kit/src/datetime/time_input.rs