Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ resolver = "2"

[workspace.dependencies]
rex-shared = "0.1.0"
rex-db = "0.1.0"
rex-app = "0.1.0"
rex-db = "0.1.1"
rex-app = "0.1.1"
chrono = "0.4.42"
diesel = { version = "2.3.2", default-features = false, features = [
"returning_clauses_for_sqlite_3_35",
Expand Down
4 changes: 2 additions & 2 deletions app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rex-app"
version = "0.1.0"
version = "0.1.1"
edition = "2024"
description = """
Core functionality for Rex
Expand All @@ -10,7 +10,7 @@ repository = "https://github.com/TheRustyPickle/Rex"
license = "MIT"

[dependencies]
db = { package = "rex-db", version = "0.1.0" }
db = { package = "rex-db", version = "0.1.1" }
shared = { package = "rex-shared", version = "0.1.0" }
chrono.workspace = true
anyhow.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions app/src/modifier/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ pub fn parse_search_fields<'a>(
let year = split_date[0].parse::<i32>()?;

let start_date = NaiveDate::from_ymd_opt(year, 1, 1)
.ok_or_else(|| anyhow!("{} is an invalid year", year))?
.ok_or_else(|| anyhow!("{year} is an invalid year"))?
.and_time(NaiveTime::MIN);

let end_date = NaiveDate::from_ymd_opt(year + 1, 1, 1)
.ok_or_else(|| anyhow!("{} is an invalid year", year))?
.ok_or_else(|| anyhow!("{year} is an invalid year"))?
.and_time(NaiveTime::MIN);

Some(DateNature::ByYear {
Expand Down
2 changes: 1 addition & 1 deletion db/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rex-db"
version = "0.1.0"
version = "0.1.1"
edition = "2024"
description = """
Rex database models using diesel
Expand Down
6 changes: 3 additions & 3 deletions db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ impl Cache {
.values()
.find(|m| m.name == name)
.map(|m| m.id)
.ok_or_else(|| anyhow!("method '{}' not found", name))
.ok_or_else(|| anyhow!("method '{name}' not found"))
}

pub fn get_method_by_name(&self, name: &str) -> Result<&TxMethod> {
self.tx_methods
.values()
.find(|m| m.name == name)
.ok_or_else(|| anyhow!("method '{}' not found", name))
.ok_or_else(|| anyhow!("method '{name}' not found"))
}

pub fn get_method_by_name_mut(&mut self, name: &str) -> Result<&mut TxMethod> {
Expand All @@ -50,7 +50,7 @@ impl Cache {
.values()
.find(|m| m.name == name)
.map(|m| m.id)
.ok_or_else(|| anyhow!("tag '{}' not found", name))
.ok_or_else(|| anyhow!("tag '{name}' not found"))
}

pub fn new_tags(&mut self, tags: Vec<Tag>) {
Expand Down
2 changes: 1 addition & 1 deletion tui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test = false
bench = false

[dependencies]
app = { package = "rex-app", version = "0.1.0" }
app = { package = "rex-app", version = "0.1.1" }
shared = { package = "rex-shared", version = "0.1.0" }
anyhow.workspace = true
crossterm = "0.29.0"
Expand Down
15 changes: 7 additions & 8 deletions tui/src/key_checker/initial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ use crate::pages::PopupType;

/// Tracks the keys of the Initial page and calls relevant function based on it
pub fn initial_keys(handler: &mut InputKeyHandler) -> Result<Option<HandlingOutput>> {
match handler.popup_status {
PopupType::Nothing => match handler.key.code {
if let PopupType::Nothing = handler.popup_status {
match handler.key.code {
KeyCode::Char('q') => return Ok(Some(HandlingOutput::QuitUi)),
_ => handler.go_home(),
},
_ => {
if let KeyCode::Char('q') = handler.key.code {
return Ok(Some(HandlingOutput::QuitUi));
};
return popup_keys(handler);
}
} else {
if let KeyCode::Char('q') = handler.key.code {
return Ok(Some(HandlingOutput::QuitUi));
}
return popup_keys(handler);
}
Ok(None)
}
2 changes: 1 addition & 1 deletion tui/src/page_handler/ui_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ pub fn start_app<B: Backend>(
&& let PopupType::Nothing = popup_status
{
popup_status = PopupType::new_choice_config_forced();
};
}

// Passing out relevant data to the UI function
terminal
Expand Down
2 changes: 1 addition & 1 deletion tui/src/pages/add_tx_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub fn add_tx_ui(
.style(Style::default().fg(TEXT))
});

let balance_area = Table::new(bal_data, width_data.to_owned())
let balance_area = Table::new(bal_data, width_data.clone())
.block(styled_block("Balance Change"))
.style(Style::default().fg(BOX));

Expand Down
2 changes: 1 addition & 1 deletion tui/src/pages/home_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ pub fn home_ui(

// Use the acquired width data to the allocated spaces
// between columns on Balance widget.
let balance_area = Table::new(bal_data, width_data.to_owned())
let balance_area = Table::new(bal_data, width_data.clone())
.block(styled_block("Balance"))
.style(Style::default().fg(BOX));

Expand Down
21 changes: 13 additions & 8 deletions tui/src/pages/popups/choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use ratatui::widgets::{BorderType, Borders, Clear, Paragraph, Row, Table, Wrap};

use crate::page_handler::{BACKGROUND, BOX, TEXT};
use crate::pages::{ChoicePopup, ChoicePopupState};
use crate::utility::{centered_rect, main_block, styled_block};
use crate::utility::{centered_rect_exact, main_block, styled_block};

impl ChoicePopup {
pub fn show_ui(&mut self, f: &mut Frame) {
let size = f.area();
let x_value = 40;
let mut x_value = 40;
let mut y_value = 10;

let title;
Expand All @@ -34,7 +34,7 @@ impl ChoicePopup {
title = "Configuration";
message = "Select an option to configure";

y_value = 20;
y_value = 12;

constraints = vec![
Constraint::Length(4),
Expand All @@ -46,23 +46,28 @@ impl ChoicePopup {
title = "Configuration";
message = "Please add at least 1 Transaction Method to get started. Example Transaction Method: Bank, Cash, Paypal";

y_value = 20;
y_value = 10;
x_value = 60;

constraints = vec![
Constraint::Length(4),
Constraint::Min(1),
Constraint::Length(7),
Constraint::Length(3),
];
}
ChoicePopupState::TxMethods => {
title = "Rename Method";
message = "Select a method to rename";

y_value = 20;
y_value = 5 + self.table.items.len() as u16 + 2;

if y_value > 20 {
y_value = 20;
}

constraints = vec![
Constraint::Length(4),
Constraint::Min(1),
Constraint::Length(1),
Constraint::Length((self.table.items.len() + 2) as u16),
];
}
Expand All @@ -77,7 +82,7 @@ impl ChoicePopup {
.title(title)
.borders(Borders::ALL);

let area = centered_rect(x_value, y_value, size);
let area = centered_rect_exact(x_value, y_value, size);

let new_chunks = Layout::default()
.direction(Direction::Vertical)
Expand Down
8 changes: 4 additions & 4 deletions tui/src/pages/popups/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ use crate::pages::{
InfoPopup, InfoPopupState, activity_help_text, add_tx_help_text, chart_help_text, choice_help,
home_help_text, new_update_text, reposition_help, search_help_text, summary_help_text,
};
use crate::utility::{centered_rect, create_bolded_text, main_block};
use crate::utility::{centered_rect_exact, create_bolded_text, main_block};

impl InfoPopup {
pub fn show_ui(&mut self, f: &mut Frame) {
let size = f.area();
let mut x_value = 60;
let mut y_value = 60;
let mut x_value = 80;
let mut y_value = 30;

let mut title = "Help";
let message;
Expand Down Expand Up @@ -83,7 +83,7 @@ impl InfoPopup {

let text = create_bolded_text(&message);

let area = centered_rect(x_value, y_value, size);
let area = centered_rect_exact(x_value, y_value, size);

let block = main_block()
.title(title)
Expand Down
8 changes: 4 additions & 4 deletions tui/src/pages/popups/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use ratatui::widgets::{BorderType, Borders, Clear, Paragraph};

use crate::page_handler::{BACKGROUND, TEXT};
use crate::pages::InputPopup;
use crate::utility::{centered_rect, create_bolded_text, main_block, styled_block};
use crate::utility::{centered_rect_exact, create_bolded_text, main_block, styled_block};

impl InputPopup {
pub fn show_ui(&mut self, f: &mut Frame) {
let size = f.area();
let x_value = 40;
let y_value = 10;
let x_value = 50;
let y_value = 7;

let title = if self.modifying_method.is_none() {
"New Method"
Expand All @@ -31,7 +31,7 @@ impl InputPopup {
.title(title)
.borders(Borders::ALL);

let area = centered_rect(x_value, y_value, size);
let area = centered_rect_exact(x_value, y_value, size);

let new_chunks = Layout::default()
.direction(Direction::Vertical)
Expand Down
2 changes: 1 addition & 1 deletion tui/src/pages/popups/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ impl PopupType {
pub fn new_choice_methods(conn: &mut DbConn) -> Result<Self> {
let tx_methods = conn.get_tx_methods_sorted();

if tx_methods.len() <= 1 {
if tx_methods.is_empty() {
return Err(anyhow!(
"There needs to be at least 1 transaction method existing for this option"
));
Expand Down
12 changes: 6 additions & 6 deletions tui/src/pages/popups/new_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ use std::fmt::Write;

use crate::page_handler::{BACKGROUND, BLUE, BOX, TEXT};
use crate::pages::NewPathsPopup;
use crate::utility::{centered_rect, main_block, styled_block};
use crate::utility::{centered_rect_exact, main_block, styled_block};

impl NewPathsPopup {
pub fn show_ui(&mut self, f: &mut Frame) {
let size = f.area();
let x_value = 40;
let y_value = 30;
let x_value = 50;
let y_value = 20;

let title = if self.new_location {
"New Location"
Expand All @@ -28,7 +28,7 @@ impl NewPathsPopup {
.title(title)
.borders(Borders::ALL);

let area = centered_rect(x_value, y_value, size);
let area = centered_rect_exact(x_value, y_value, size);

let new_chunks = Layout::default()
.direction(Direction::Vertical)
Expand All @@ -47,8 +47,8 @@ impl NewPathsPopup {

let mut path_text = String::new();

for path in self.paths.iter() {
writeln!(path_text, "{}", path.display()).unwrap()
for path in &self.paths {
writeln!(path_text, "{}", path.display()).unwrap();
}

let path_list = Paragraph::new(Text::from(path_text))
Expand Down
10 changes: 7 additions & 3 deletions tui/src/pages/popups/reposition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ use ratatui::widgets::{BorderType, Borders, Clear, Row, Table};

use crate::page_handler::{BLUE, BOX, TEXT};
use crate::pages::RepositionPopup;
use crate::utility::{centered_rect, main_block, styled_block};
use crate::utility::{centered_rect_exact, main_block, styled_block};

impl RepositionPopup {
pub fn show_ui(&mut self, f: &mut Frame) {
let size = f.area();
let x_value = 40;
let y_value = 20;
let mut y_value = self.reposition_table.items.len() as u16 + 4 + 3;

if y_value > 20 {
y_value = 20;
}

let title = "Reposition Tx Methods";

Expand All @@ -23,7 +27,7 @@ impl RepositionPopup {
.title(title)
.borders(Borders::ALL);

let area = centered_rect(x_value, y_value, size);
let area = centered_rect_exact(x_value, y_value, size);

let new_chunks = Layout::default()
.direction(Direction::Vertical)
Expand Down
Loading
Loading