fn add_item(s: &mut Cursive) {
    // Set-up the EditViews
    let edit_title = EditView::new().with_name("title_edit").fixed_width(50);

    let edit_option = EditView::new().with_name("opt_edit").fixed_width(10);

    let title_text = TextView::new("Title:");
    let option_text = TextView::new("Option:");

    // Function runs when the <Ok> button is pressed
    fn ok(s: &mut Cursive, value: String, opt: String) {
        if !&value.is_empty() && !&opt.is_empty() {
            let set_path = settings::settings_dir();
            let list = Watchlist {
                title: value,
                option: opt,
            };
            settings::db_write_wl(&set_path, &list.title, &list.option)
                .expect("Failed to write into database");
            s.call_on_name(
                "watch-list",
                |wl: &mut TableView<Watchlist, WatchColumn>| {
                    wl.insert_item(list);
                },
            );
            s.pop_layer();
        } else {
            s.pop_layer();
        }
    }

    // Sets up the Add Item Dialog
    s.add_layer(
        Dialog::around(
            LinearLayout::vertical()
                .child(title_text)
                .child(edit_title)
                .child(option_text)
                .child(edit_option),
        )
        .button("Ok", |s| {
            let value = s
                .call_on_name("title_edit", |view: &mut EditView| {
                    view.get_content().to_string()
                })
                .unwrap();
            let opt = s
                .call_on_name("opt_edit", |view: &mut EditView| {
                    view.get_content().to_string()
                })
                .unwrap();
            ok(s, value, opt);
        }),
    )
}
/// Adds an item in the watch-list

Adds an item in the watch-list
Adds an item in the watch - list
fn add_item(s: &mut Cursive) {
    // Set-up the EditViews
    let edit_title = EditView::new().with_name("title_edit").fixed_width(50);
    let edit_option = EditView::new().with_name("opt_edit").fixed_width(10);
    let title_text = TextView::new("Title:");
    let option_text = TextView::new("Option:");
    // Function runs when the <Ok> button is pressed
    fn ok(s: &mut Cursive, value: String, opt: String) {
        if !&value.is_empty() && !&opt.is_empty() {
            let set_path = settings::settings_dir();
            let list = Watchlist {
                title: value,
                option: opt,
            };
            settings::db_write_wl(&set_path, &list.title, &list.option)
                .expect("Failed to write into database");
            s.call_on_name(
                "watch-list",
                |wl: &mut TableView<Watchlist, WatchColumn>| {
                    wl.insert_item(list);
                },
            );
            s.pop_layer();
        } else {
            s.pop_layer();
        }
    }
    // Sets up the Add Item Dialog
    s.add_layer(
        Dialog::around(
            LinearLayout::vertical()
                .child(title_text)
                .child(edit_title)
                .child(option_text)
                .child(edit_option),
        )
        .button("Ok", |s| {
            let value = s
                .call_on_name("title_edit", |view: &mut EditView| {
                    view.get_content().to_string()
                })
                .unwrap();
            let opt = s
                .call_on_name("opt_edit", |view: &mut EditView| {
                    view.get_content().to_string()
                })
                .unwrap();
            ok(s, value, opt);
        }),
    )
}
fn add_item ( s : & mut Cursive ) { // Set-up the EditViews
 let edit_title = EditView :: new ( ) . with_name ( " " ) . fixed_width ( 50 ) ; let edit_option = EditView :: new ( ) . with_name ( " " ) . fixed_width ( 10 ) ; let title_text = TextView :: new ( " " ) ; let option_text = TextView :: new ( " " ) ; // Function runs when the <Ok> button is pressed
 fn ok ( s : & mut Cursive , value : String , opt : String ) { if ! & value . is_empty ( ) && ! & opt . is_empty ( ) { let set_path = settings :: settings_dir ( ) ; let list = Watchlist { title : value , option : opt , } ; settings :: db_write_wl ( & set_path , & list . title , & list . option ) . expect ( " " ) ; s . call_on_name ( " " , | wl : & mut TableView < Watchlist , WatchColumn > | { wl . insert_item ( list ) ; } , ) ; s . pop_layer ( ) ; } else { s . pop_layer ( ) ; } } // Sets up the Add Item Dialog
 s . add_layer ( Dialog :: around ( LinearLayout :: vertical ( ) . child ( title_text ) . child ( edit_title ) . child ( option_text ) . child ( edit_option ) , ) . button ( " " , | s | { let value = s . call_on_name ( " " , | view : & mut EditView | { view . get_content ( ) . to_string ( ) } ) . unwrap ( ) ; let opt = s . call_on_name ( " " , | view : & mut EditView | { view . get_content ( ) . to_string ( ) } ) . unwrap ( ) ; ok ( s , value , opt ) ; } ) , ) }
Adds an item in the watch-list
Adds an item in the watch - list
s
&mut Cursive
s
&mut Cursive