Added delete row button, styling improvements

This commit is contained in:
rushmore75 2025-04-02 00:30:55 -06:00
parent 8d8bba1ccc
commit 46987e11ad

View File

@ -1,9 +1,14 @@
#![feature(iter_map_windows)] #![feature(iter_map_windows)]
use iced::widget::scrollable;
use iced::{ use iced::{
clipboard, color, widget::{ Color, Element, Length, Task, Theme, clipboard, color,
self, button, column, combo_box, row, scrollable, scrollable::{Direction, Scrollbar}, text, text_input widget::{
}, Element, Length, Task, Theme self, button, column, combo_box, row,
scrollable::{Direction, Scrollbar},
text, text_input,
},
}; };
use std::{env, fs, path::PathBuf}; use std::{env, fs, path::PathBuf};
use texts::*; use texts::*;
@ -30,6 +35,30 @@ fn main() -> iced::Result {
} }
} }
// ALL BUILTIN THEMES
// Light
// Dark
// Dracula
// Nord
// SolarizedLight
// SolarizedDark
// GruvboxLight
// GruvboxDark
// CatppuccinLatte
// CatppuccinFrappe
// CatppuccinMacchiato
// CatppuccinMocha
// TokyoNight
// TokyoNightStorm
// TokyoNightLight
// KanagawaWave
// KanagawaDragon
// KanagawaLotus
// Moonfly
// Nightfly
// Oxocarbon
// Ferra
// GUI // GUI
iced::application("Bible Study", State::update, State::view) iced::application("Bible Study", State::update, State::view)
.theme(|_| Theme::Nord) .theme(|_| Theme::Nord)
@ -47,6 +76,7 @@ enum Message {
SubmitWordSearch(usize), SubmitWordSearch(usize),
QuickSearch(usize, String), QuickSearch(usize, String),
AddColRight, AddColRight,
DeleteColumn(usize),
} }
struct ColState { struct ColState {
@ -116,6 +146,10 @@ impl Default for State {
impl State { impl State {
fn update(&mut self, msg: Message) -> Task<Message> { fn update(&mut self, msg: Message) -> Task<Message> {
match msg { match msg {
Message::DeleteColumn(idx) => {
self.cols -= 1;
self.states.remove(idx);
}
Message::AddColRight => { Message::AddColRight => {
self.cols += 1; self.cols += 1;
// clone this state into the new one // clone this state into the new one
@ -178,6 +212,11 @@ impl State {
row((0..self.cols).map(|col_index| { row((0..self.cols).map(|col_index| {
column![ column![
// header // header
button("Delete Column")
.on_press_with(move || Message::DeleteColumn(col_index))
.width(Length::Fill)
.style(button::danger)
,
combo_box( combo_box(
&self.files, &self.files,
"Select Bible", "Select Bible",
@ -194,10 +233,16 @@ impl State {
.on_input(move |s| Message::WordSearchInput(col_index, s)) .on_input(move |s| Message::WordSearchInput(col_index, s))
.on_submit(Message::SubmitWordSearch(col_index)), .on_submit(Message::SubmitWordSearch(col_index)),
row![ row![
button("Clear All").on_press_with(move || Message::Clear(col_index)), button("Clear All")
.on_press_with(move || Message::Clear(col_index))
.style(button::secondary)
,
button("Copy Scripture") button("Copy Scripture")
.on_press_with(move || Message::CopyText(col_index)), .on_press_with(move || Message::CopyText(col_index))
], .style(button::primary)
,
]
.spacing(5),
row![ row![
// Word search results // Word search results
scrollable( scrollable(
@ -218,35 +263,39 @@ impl State {
) )
.spacing(5), .spacing(5),
// Body // Body
scrollable( scrollable(if let Some(body) = &self.states[col_index].scripture_body {
if let Some(body) = &self.states[col_index].scripture_body {
column(body.split("\n").enumerate().map(|(i, msg)| { column(body.split("\n").enumerate().map(|(i, msg)| {
let msg = parse(msg); let msg = parse(msg);
if i & 1 == 0 { if i & 1 == 0 {
text(msg.to_owned()) text(msg.to_owned()).color(color![0xFFFFFF]).into()
.color(color![0xFFFFFF])
.into()
} else { } else {
text(msg.to_owned()).color(color![0xAAAAAA]).into() text(msg.to_owned()).color(color![0xAAAAAA]).into()
} }
})) }))
} else { } else {
column( column(
Vec::<String>::new().iter().map(|_| text(String::new()).into()) Vec::<String>::new()
) .iter()
} .map(|_| text(String::new()).into()),
) )
})
.spacing(5) .spacing(5)
], ],
] ]
.padding([10, 5]) .spacing(5)
.width(800.) .width(800.)
.into() .into()
})), })),
button(text("+").center()) button(text("+").center())
.height(Length::Fixed(200.)) .height(Length::Fixed(200.))
.style(button::primary)
.on_press(Message::AddColRight) .on_press(Message::AddColRight)
]) ]
// 5 pixles css-like padding
.padding([5,5])
// space elements inside this 5 pixels apart
.spacing(5)
)
.direction(Direction::Horizontal(Scrollbar::new())) .direction(Direction::Horizontal(Scrollbar::new()))
.into() .into()
} }
@ -331,4 +380,3 @@ fn parse(input: &str) -> String {
modified modified
} }