rustyclaw_tui/components/
input_bar.rs1use crate::theme;
4use iocraft::prelude::*;
5
6#[derive(Default, Props)]
7pub struct InputBarProps {
8 pub value: String,
9 pub on_change: HandlerMut<'static, String>,
10 pub on_submit: HandlerMut<'static, String>,
11 pub gateway_icon: String,
12 pub gateway_label: String,
13 pub gateway_color: Option<Color>,
14 pub has_focus: bool,
16}
17
18#[component]
19pub fn InputBar(props: &mut InputBarProps) -> impl Into<AnyElement<'static>> {
20 let status_color = props.gateway_color.unwrap_or(theme::MUTED);
21
22 element! {
23 View(
24 width: 100pct,
25 height: 3,
26 flex_direction: FlexDirection::Column,
27 border_style: BorderStyle::Round,
28 border_color: theme::ACCENT,
29 border_edges: Edges::Top,
30 ) {
31 View(width: 100pct, height: 1, flex_direction: FlexDirection::Row) {
32 Text(content: "❯ ", color: theme::ACCENT_BRIGHT, weight: Weight::Bold)
33 View(flex_grow: 1.0, height: 1, background_color: theme::BG_MAIN) {
34 TextInput(
35 has_focus: props.has_focus,
36 value: props.value.clone(),
37 on_change: props.on_change.take(),
38 color: theme::TEXT,
39 )
40 }
41 View(padding_left: 1) {
42 Text(content: format!("{} {}", props.gateway_icon, props.gateway_label), color: status_color)
43 }
44 }
45 }
46 }
47}