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