Skip to content

Commit

Permalink
chore: update Add Card form
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh0412 committed Apr 3, 2024
1 parent 6f85f18 commit 78bee9c
Showing 1 changed file with 69 additions and 12 deletions.
81 changes: 69 additions & 12 deletions src/components/add_card.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,84 @@
use gpui::{div, prelude::*, Render, View, WindowContext};
use gpui::{div, prelude::*, Pixels, Render, View, WindowContext};

use crate::ui::{button::button::Button, clickable::Clickable, text_field::text_field::TextField};
use crate::{
theme::Theme,
ui::{button::button::Button, clickable::Clickable, text_field::text_field::TextField},
};

pub struct AddCardView {
text_input: TextField,
front_input: TextField,
back_input: TextField,
deck_input: TextField,
}

impl AddCardView {
pub fn view(cx: &mut WindowContext) -> View<Self> {
cx.new_view(|cx: &mut gpui::ViewContext<'_, AddCardView>| Self {
text_input: TextField::new(cx, "Add a card".to_string()),
front_input: TextField::new(cx, "".to_string()),
back_input: TextField::new(cx, "".to_string()),
deck_input: TextField::new(cx, "".to_string()),
})
}
}

impl Render for AddCardView {
fn render(&mut self, _cx: &mut gpui::ViewContext<Self>) -> impl gpui::prelude::IntoElement {
div()
.flex()
.justify_center()
.child(self.text_input.clone())
.child(Button::new("", "Click me").on_click(|event, _cx| {
log::info!("Button clicked: {:?}", event);
}))
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> impl gpui::prelude::IntoElement {
let theme = cx.global::<Theme>();

div().flex().size_full().justify_center().child(
div().mt_20().child(
div()
.flex()
.w_full()
.flex_col()
.text_color(theme.text)
.relative()
.h_full()
.child(
div()
.w(Pixels(500.0))
.child(
div()
.text_xl()
.font_weight(gpui::FontWeight::EXTRA_BOLD)
.child("Add a new card"),
)
.child(
div()
.mt_5()
.child(
div()
.text_lg()
.font_weight(gpui::FontWeight::BOLD)
.child("Deck"),
)
.child(self.deck_input.clone())
.child(
div()
.mt_5()
.text_lg()
.font_weight(gpui::FontWeight::BOLD)
.child("Front"),
)
.child(self.front_input.clone())
.child(
div()
.mt_5()
.text_lg()
.font_weight(gpui::FontWeight::BOLD)
.child("Back"),
)
.child(self.back_input.clone())
.child(
div()
.mt_5()
.flex()
.justify_end()
.child(Button::new("create", "Create card")),
),
),
),
),
)
}
}

0 comments on commit 78bee9c

Please sign in to comment.