Skip to content

Commit

Permalink
Updated to v0.10.1!! (Minor Hotfix)
Browse files Browse the repository at this point in the history
  • Loading branch information
yashs662 committed Jul 10, 2024
1 parent 40d57b1 commit a6215cb
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-kanban"
version = "0.10.0"
version = "0.10.1"
authors = ["Yash Sharma <yashs662@gmail.com>"]
edition = "2021"
license = "MIT"
Expand Down
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/app/app_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4185,9 +4185,9 @@ fn handle_date_time_picker_action(app: &mut App, key: Option<Key>, 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 {
Expand Down Expand Up @@ -4304,13 +4304,16 @@ 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 {
app.state.set_focus(*previous_focus);
}
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;
}
Expand Down Expand Up @@ -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) {
Expand Down
23 changes: 20 additions & 3 deletions src/ui/ui_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/ui/widgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down

0 comments on commit a6215cb

Please sign in to comment.