From a6215cbc1ad66b31d8cc645f42c61f1816484b72 Mon Sep 17 00:00:00 2001 From: Yash Sharma Date: Wed, 10 Jul 2024 02:35:46 -0700 Subject: [PATCH] Updated to v0.10.1!! (Minor Hotfix) --- Cargo.lock | 2 +- Cargo.toml | 2 +- Changelog.md | 6 ++++++ src/app/app_helper.rs | 6 +++++- src/ui/ui_helper.rs | 23 ++++++++++++++++++++--- src/ui/widgets.rs | 4 +++- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32f1bcd..b7c3904 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1269,7 +1269,7 @@ dependencies = [ [[package]] name = "rust-kanban" -version = "0.10.0" +version = "0.10.1" dependencies = [ "aes-gcm", "base64", diff --git a/Cargo.toml b/Cargo.toml index cf18ca2..6eab750 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rust-kanban" -version = "0.10.0" +version = "0.10.1" authors = ["Yash Sharma "] edition = "2021" license = "MIT" diff --git a/Changelog.md b/Changelog.md index 7847b8c..12389ff 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,9 @@ +Changes in Version 0.10.1 +========================= +### Fixes +- Fixed a bug where date picker would not open on new card form when using the keyboard +- Fixed a bug where date picker in new card For was not anchored properly + Changes in Version 0.10.0 ========================= ### New Features diff --git a/src/app/app_helper.rs b/src/app/app_helper.rs index cfdbac5..db5eb5c 100644 --- a/src/app/app_helper.rs +++ b/src/app/app_helper.rs @@ -4185,9 +4185,9 @@ fn handle_date_time_picker_action(app: &mut App, key: Option, action: Optio .format(app.config.date_time_format.to_parser_string()) .to_string() } - app.widgets.date_time_picker.close_date_picker(); debug!("Changed due date to {}", card.due_date); } + app.widgets.date_time_picker.close_date_picker(); } Focus::DTPToggleTimePicker => { if app.widgets.date_time_picker.time_picker_active { @@ -4304,6 +4304,7 @@ fn handle_new_card_action(app: &mut App) { } else { warn!("New card name is empty or already exists"); app.send_warning_toast("New card name is empty or already exists", None); + return; } if let Some(previous_focus) = &app.state.prev_focus { @@ -4311,6 +4312,8 @@ fn handle_new_card_action(app: &mut App) { } refresh_visible_boards_and_cards(app); reset_new_card_form(app); + } else if app.state.focus == Focus::CardDueDate { + app.set_popup_mode(PopupMode::DateTimePicker); } else if app.state.app_status == AppStatus::Initialized { app.state.app_status = AppStatus::UserInput; } @@ -5528,6 +5531,7 @@ fn reset_new_board_form(app: &mut App) { fn reset_new_card_form(app: &mut App) { app.state.text_buffers.card_name.reset(); app.state.text_buffers.card_description.reset(); + app.widgets.date_time_picker.reset(); } fn reset_login_form(app: &mut App) { diff --git a/src/ui/ui_helper.rs b/src/ui/ui_helper.rs index 83223cc..16c8436 100644 --- a/src/ui/ui_helper.rs +++ b/src/ui/ui_helper.rs @@ -2611,6 +2611,22 @@ pub fn render_new_card_form(rect: &mut Frame, app: &mut App, popup_mode: bool) { ) .split(rect.size()); + let card_due_date = app.widgets.date_time_picker.get_date_time_as_string(app.config.date_time_format); + + if app.state.z_stack.last() == Some(&PopupMode::DateTimePicker) { + if app.widgets.date_time_picker.anchor.is_none() { + app.widgets.date_time_picker.anchor = Some(( + chunks[3].x + card_due_date.len() as u16 + 2, + chunks[3].y + 3, + )); // offsets to make sure date is visible + debug!( + "Setting anchor for date time picker to: {:?}", + app.widgets.date_time_picker.anchor + ); + } + app.widgets.date_time_picker.current_viewport = Some(rect.size()); + } + let general_style = check_for_popup_and_get_style( popup_mode, app.current_theme.inactive_text_style, @@ -7907,15 +7923,16 @@ pub fn render_date_time_widget(rect: &mut Frame, app: &mut App, popup_mode: bool app.widgets.date_time_picker.current_render_area = Some(render_area); - let title_length = (current_month.len() + 3 + current_year.len()) as u16; // 3 is for the " - " + let title_length = (current_month.len() + 3 + current_year.len() + 4) as u16; // 3 is for the " - ", + // additional 4 is to compensate for the borders that show when focus is on month or year let padding = (render_area .width .min(app.widgets.date_time_picker.date_target_width) - 3 - 2) .saturating_sub(title_length); // 3 is for the Time section expand button, 2 is for margin - let month_length = current_month.len() as u16 + (padding / 2); - let year_length = current_year.len() as u16 + (padding / 2); + let month_length = current_month.len() as u16 + (padding / 2) + 2; + let year_length = current_year.len() as u16 + (padding / 2) + 2; let (date_picker_render_area, time_picker_render_area) = if app.widgets.date_time_picker.widget_width diff --git a/src/ui/widgets.rs b/src/ui/widgets.rs index 3055ad1..59df38a 100644 --- a/src/ui/widgets.rs +++ b/src/ui/widgets.rs @@ -1516,7 +1516,9 @@ impl<'a> Widget for DateTimePickerWidget<'a> { } WidgetAnimState::Closed => { app.state.z_stack.pop(); - date_time_picker.reset(); + if app.state.ui_mode != UiMode::NewCard { + date_time_picker.reset(); + } } }