chore: refactor the input component (#165)

* refactor the input component

* fix clippy

* clean up
This commit is contained in:
reya
2025-09-25 08:03:14 +07:00
committed by GitHub
parent a87184214f
commit 61cad5dd96
20 changed files with 2529 additions and 1593 deletions

View File

@@ -89,11 +89,8 @@ impl Chat {
let input = cx.new(|cx| {
InputState::new(window, cx)
.placeholder(t!("chat.placeholder"))
.multi_line()
.prevent_new_line_on_enter()
.rows(1)
.multi_line()
.auto_grow(1, 20)
.prevent_new_line_on_enter()
.clean_on_escape()
});
@@ -155,14 +152,8 @@ impl Chat {
&input,
window,
move |this: &mut Self, _input, event, window, cx| {
match event {
InputEvent::PressEnter { .. } => {
this.send_message(window, cx);
}
InputEvent::Change(_) => {
// this.mention_popup(text, input, cx);
}
_ => {}
if let InputEvent::PressEnter { .. } = event {
this.send_message(window, cx);
};
},
),

View File

@@ -424,7 +424,7 @@ impl Compose {
impl Render for Compose {
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let error = self.error_message.read(cx).as_ref();
let loading = self.user_input.read(cx).loading(cx);
let loading = self.user_input.read(cx).loading;
let contacts = self.contacts.read(cx);
v_flex()

View File

@@ -204,7 +204,7 @@ impl Render for Preferences {
.on_click(move |_, _window, cx| {
if let Some(input) = input_state.upgrade() {
let Ok(url) =
Url::parse(input.read(cx).value())
Url::parse(&input.read(cx).value())
else {
return;
};

View File

@@ -100,12 +100,12 @@ impl Sidebar {
subscriptions.push(
// Subscribe for find input events
cx.subscribe_in(&find_input, window, |this, _state, event, window, cx| {
cx.subscribe_in(&find_input, window, |this, state, event, window, cx| {
match event {
InputEvent::PressEnter { .. } => this.search(window, cx),
InputEvent::Change(text) => {
InputEvent::Change => {
// Clear the result when input is empty
if text.is_empty() {
if state.read(cx).value().is_empty() {
this.clear_search_results(window, cx);
} else {
// Run debounced search
@@ -722,6 +722,7 @@ impl Render for Sidebar {
.small()
.cleanable()
.appearance(true)
.text_xs()
.suffix(
Button::new("find")
.icon(IconName::Search)