input: Move number input into input (#549)
This commit is contained in:
parent
8dca96469e
commit
0312e47554
5 changed files with 10 additions and 9 deletions
|
|
@ -10,8 +10,7 @@ use ui::{
|
||||||
button::{Button, ButtonVariant, ButtonVariants as _},
|
button::{Button, ButtonVariant, ButtonVariants as _},
|
||||||
checkbox::Checkbox,
|
checkbox::Checkbox,
|
||||||
h_flex,
|
h_flex,
|
||||||
input::{InputEvent, OtpInput, TextInput},
|
input::{InputEvent, NumberInput, NumberInputEvent, OtpInput, TextInput},
|
||||||
number_input::{NumberInput, NumberInputEvent},
|
|
||||||
prelude::FluentBuilder as _,
|
prelude::FluentBuilder as _,
|
||||||
v_flex, FocusableCycle, IconName, Sizable,
|
v_flex, FocusableCycle, IconName, Sizable,
|
||||||
};
|
};
|
||||||
|
|
@ -260,13 +259,13 @@ impl InputStory {
|
||||||
InputEvent::Blur => println!("Blur"),
|
InputEvent::Blur => println!("Blur"),
|
||||||
},
|
},
|
||||||
NumberInputEvent::Step(step_action) => match step_action {
|
NumberInputEvent::Step(step_action) => match step_action {
|
||||||
ui::number_input::StepAction::Decrement => {
|
ui::input::StepAction::Decrement => {
|
||||||
self.number_input1_value = self.number_input1_value - 1;
|
self.number_input1_value = self.number_input1_value - 1;
|
||||||
self.number_input1.update(cx, |input, cx| {
|
self.number_input1.update(cx, |input, cx| {
|
||||||
input.set_value(self.number_input1_value.to_string(), cx);
|
input.set_value(self.number_input1_value.to_string(), cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ui::number_input::StepAction::Increment => {
|
ui::input::StepAction::Increment => {
|
||||||
self.number_input1_value = self.number_input1_value + 1;
|
self.number_input1_value = self.number_input1_value + 1;
|
||||||
self.number_input1.update(cx, |input, cx| {
|
self.number_input1.update(cx, |input, cx| {
|
||||||
input.set_value(self.number_input1_value.to_string(), cx);
|
input.set_value(self.number_input1_value.to_string(), cx);
|
||||||
|
|
@ -290,7 +289,7 @@ impl InputStory {
|
||||||
InputEvent::Blur => println!("Blur"),
|
InputEvent::Blur => println!("Blur"),
|
||||||
},
|
},
|
||||||
NumberInputEvent::Step(step_action) => match step_action {
|
NumberInputEvent::Step(step_action) => match step_action {
|
||||||
ui::number_input::StepAction::Decrement => {
|
ui::input::StepAction::Decrement => {
|
||||||
if self.number_input2_value.le(&0) {
|
if self.number_input2_value.le(&0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -300,7 +299,7 @@ impl InputStory {
|
||||||
input.set_value(self.number_input2_value.to_string(), cx);
|
input.set_value(self.number_input2_value.to_string(), cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
ui::number_input::StepAction::Increment => {
|
ui::input::StepAction::Increment => {
|
||||||
self.number_input2_value = self.number_input2_value + 1;
|
self.number_input2_value = self.number_input2_value + 1;
|
||||||
self.number_input2.update(cx, |input, cx| {
|
self.number_input2.update(cx, |input, cx| {
|
||||||
input.set_value(self.number_input2_value.to_string(), cx);
|
input.set_value(self.number_input2_value.to_string(), cx);
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ use gpui::{
|
||||||
use super::blink_cursor::BlinkCursor;
|
use super::blink_cursor::BlinkCursor;
|
||||||
use super::change::Change;
|
use super::change::Change;
|
||||||
use super::element::TextElement;
|
use super::element::TextElement;
|
||||||
use super::ClearButton;
|
use super::{number_input, ClearButton};
|
||||||
|
|
||||||
use crate::history::History;
|
use crate::history::History;
|
||||||
use crate::indicator::Indicator;
|
use crate::indicator::Indicator;
|
||||||
|
|
@ -155,6 +155,8 @@ pub fn init(cx: &mut AppContext) {
|
||||||
#[cfg(not(target_os = "macos"))]
|
#[cfg(not(target_os = "macos"))]
|
||||||
KeyBinding::new("ctrl-y", Redo, Some(CONTEXT)),
|
KeyBinding::new("ctrl-y", Redo, Some(CONTEXT)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
number_input::init(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TextInput {
|
pub struct TextInput {
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@ mod change;
|
||||||
mod clear_button;
|
mod clear_button;
|
||||||
mod element;
|
mod element;
|
||||||
mod input;
|
mod input;
|
||||||
|
mod number_input;
|
||||||
mod otp_input;
|
mod otp_input;
|
||||||
|
|
||||||
pub(crate) use clear_button::*;
|
pub(crate) use clear_button::*;
|
||||||
pub use input::*;
|
pub use input::*;
|
||||||
|
pub use number_input::{NumberInput, NumberInputEvent, StepAction};
|
||||||
pub use otp_input::*;
|
pub use otp_input::*;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ pub mod link;
|
||||||
pub mod list;
|
pub mod list;
|
||||||
pub mod modal;
|
pub mod modal;
|
||||||
pub mod notification;
|
pub mod notification;
|
||||||
pub mod number_input;
|
|
||||||
pub mod popover;
|
pub mod popover;
|
||||||
pub mod popup_menu;
|
pub mod popup_menu;
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
|
@ -91,7 +90,6 @@ pub fn init(cx: &mut gpui::AppContext) {
|
||||||
drawer::init(cx);
|
drawer::init(cx);
|
||||||
dropdown::init(cx);
|
dropdown::init(cx);
|
||||||
input::init(cx);
|
input::init(cx);
|
||||||
number_input::init(cx);
|
|
||||||
list::init(cx);
|
list::init(cx);
|
||||||
modal::init(cx);
|
modal::init(cx);
|
||||||
popover::init(cx);
|
popover::init(cx);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue