add input
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
App, AppContext as _, Bounds, ClickEvent, Context, InteractiveElement as _, IntoElement,
|
||||
ParentElement as _, Render, SharedString, StatefulInteractiveElement as _, Styled as _, Window,
|
||||
WindowBounds, WindowOptions, div, px, size,
|
||||
App, AppContext as _, Bounds, ClickEvent, Context, Entity, InteractiveElement as _,
|
||||
IntoElement, ParentElement as _, Render, SharedString, StatefulInteractiveElement as _,
|
||||
Styled as _, Window, WindowBounds, WindowOptions, div, px, size,
|
||||
};
|
||||
use gpui_native_core::avatar::Avatar;
|
||||
use gpui_native_core::button::{Button, ButtonVariant};
|
||||
use gpui_native_core::checkbox::Checkbox;
|
||||
use gpui_native_core::common::{h_flex, v_flex};
|
||||
use gpui_native_core::input::{Input, InputState};
|
||||
use gpui_native_core::link::Link;
|
||||
use gpui_native_core::progress::Progress;
|
||||
use gpui_native_core::radio::{Radio, RadioGroup};
|
||||
@@ -25,6 +26,7 @@ struct Gallery {
|
||||
plan: SharedString,
|
||||
toggle_pressed: bool,
|
||||
volume: f32,
|
||||
input_state: Entity<InputState>,
|
||||
}
|
||||
|
||||
impl Render for Gallery {
|
||||
@@ -211,6 +213,27 @@ impl Render for Gallery {
|
||||
.child(format!("clicked {} times", self.button_clicks)),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.child(section_label(
|
||||
"input · native refs — NSTextField, WinUI TextBox, Adwaita Entry, Breeze LineEdit",
|
||||
colors,
|
||||
))
|
||||
.child(
|
||||
Input::new("gallery-input", self.input_state.clone())
|
||||
.placeholder("Type here…"),
|
||||
)
|
||||
.child(
|
||||
div()
|
||||
.text_xs()
|
||||
.text_color(colors.muted_foreground)
|
||||
.child(format!(
|
||||
"value: {}",
|
||||
self.input_state.read(cx).value()
|
||||
)),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
@@ -566,6 +589,7 @@ where
|
||||
fn main() {
|
||||
application().with_assets(IconAssets).run(|cx: &mut App| {
|
||||
Theme::init(cx);
|
||||
let input_state = InputState::new(cx);
|
||||
let bounds = Bounds::centered(None, size(px(720.0), px(560.0)), cx);
|
||||
if let Err(err) = cx.open_window(
|
||||
WindowOptions {
|
||||
@@ -592,6 +616,7 @@ fn main() {
|
||||
plan: SharedString::from("starter"),
|
||||
toggle_pressed: false,
|
||||
volume: 40.0,
|
||||
input_state,
|
||||
})
|
||||
},
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user