Added board creation

This commit is contained in:
Maddox Werts 2024-06-23 14:57:48 -04:00
parent dcbd030a48
commit a73c72fa93
2 changed files with 32 additions and 8 deletions

View file

@ -14,10 +14,7 @@ impl TaskBoard {
let name: String = name;
// Init default cards
let mut cards: Vec<card::TaskCard> = Vec::new();
// Creating a new default card
cards.push(card::TaskCard::init(String::new(), String::new()));
let cards: Vec<card::TaskCard> = Vec::new();
// Return the board!
return TaskBoard {name: name, cards: cards};

View file

@ -22,9 +22,10 @@ impl<'a> Interface<'a> {
fn p_0(&mut self) {
// Showing options
println!(" - Tasky - ");
println!("1) Open Boards");
println!("2) Exit");
println!("\nSelect option [1-2]: ");
println!("1) Open Board");
println!("2) Create Board");
println!("3) Exit");
println!("\nSelect option [1-3]: ");
// Listening for option
let mut user_input: String = String::new();
@ -35,7 +36,9 @@ impl<'a> Interface<'a> {
// Deciding what to do
if user_input == "1" {
self.page = 1;
} else if user_input == "2" {
} else if user_input == "2"{
self.page = 6;
} else if user_input == "3" {
exit(0);
}
}
@ -283,6 +286,29 @@ impl<'a> Interface<'a> {
self.on = 0;
}
}
fn p_6(&mut self){
// Title
println!(" - Create Board - \n");
// Variables
let mut user_input: String = String::new();
// Asking the user what the name is
println!("What is your boards's name?");
println!("Select name: ");
// Reading input
io::stdin().read_line(&mut user_input).expect("Failed to read line");
let _name: String = String::from(user_input.trim());
println!("");
// Creating the new board
self.manager.boards.push(board::TaskBoard::init(_name));
// Open the board
self.page = 2;
self.on = (self.manager.boards.len()-1) as u32;
}
fn error(msg: &str){
println!("INTERFACE ERROR: {}", msg);
@ -297,6 +323,7 @@ impl<'a> Interface<'a> {
3 => self.p_3(),
4 => self.p_4(),
5 => self.p_5(),
6 => self.p_6(),
_ => Interface::error("Invalid Page")
}