This commit is contained in:
Oliver Atkinson 2025-05-16 09:43:49 -06:00
parent ba260b02bc
commit 035bd21466

View File

@ -2,7 +2,7 @@
use iced::keyboard::key::Named;
use iced::keyboard::{Key, Modifiers};
use iced::{event, Event, Subscription};
use iced::widget::scrollable;
use iced::widget::{scrollable, text_editor};
use iced::{
Element, Length, Task, Theme, clipboard, color,
widget::{
@ -68,6 +68,7 @@ enum Message {
DeleteColumn(usize),
SetErrorMessage(usize, String),
RecievedEvent(Event),
NoteInput(usize, text_editor::Action),
}
impl Message {
@ -82,7 +83,8 @@ impl Message {
Message::WordSearchInput(i, _) |
Message::SubmitWordSearch(i) |
Message::QuickSearch(i, _, _) |
Message::DeleteColumn(i)
Message::DeleteColumn(i) |
Message::NoteInput(i, _)
=> {
Some(*i)
},
@ -101,6 +103,8 @@ struct ColState {
word_search: String,
word_search_results: Option<Vec<(String, bool)>>,
notes: text_editor::Content,
error: Option<String>,
}
@ -116,6 +120,8 @@ impl Default for ColState {
word_search: String::new(),
word_search_results: None,
notes: text_editor::Content::new(),
error: None,
}
}
@ -191,6 +197,10 @@ impl State {
}
// match normal messages
match msg {
Message::NoteInput(i, action) => {
let notes = &mut self.states[i].notes;
notes.perform(action);
}
Message::CycleTheme => {
let len = self.themes.len();
let i = &mut self.theme_idx;
@ -332,7 +342,7 @@ impl State {
}
fn view(&self) -> Element<Message> {
//TODO error message
// Header bar, static, doesn't scroll
column![
button("Cycle Themes")
.on_press(Message::CycleTheme)
@ -341,7 +351,7 @@ impl State {
row![
row((0..self.states.len()).map(|col_index| {
column![
// header
// Top of Column, text entry boxes
combo_box(
&self.files,
"Select Bible",
@ -360,6 +370,8 @@ impl State {
.id(format!("tabId-{}", (col_index*2)+1))
.on_input(move |s| Message::WordSearchInput(col_index, s))
.on_submit(Message::SubmitWordSearch(col_index)),
// Horizontal Row just above scripture
row![
button("Clear All")
.on_press_with(move || Message::Clear(col_index))
@ -374,6 +386,7 @@ impl State {
.style(text::danger),
]
.spacing(5),
// Body
row![
// Word search results
scrollable(
@ -403,10 +416,11 @@ impl State {
.padding([5, 5])
)
.spacing(5),
// Body
// Scripture
scrollable(
if let Some(body) = &self.states[col_index].scripture_body {
column(body.split("\n").enumerate().map(|(i, msg)| {
// Color every other verse slightly differently
let msg = parse(msg);
if i & 1 == 0 {
text(msg.to_owned()).color(color![0xFFFFFF]).into()
@ -422,13 +436,22 @@ impl State {
)
}
)
// TODO make this dynamic
.height(600)
.spacing(5)
],
// Notes
text_editor(&self.states[col_index].notes)
.placeholder("Notes...")
.on_action(move |a| Message::NoteInput(col_index, a))
.height(100)
// .id(format!("tabId-{}", (col_index*2)+2))
]
.spacing(5)
.width(800.)
.into()
})),
// Right most vertical buttons
button(text("+").center())
.height(Length::Fixed(200.))
.style(button::primary)