merge GUI #1
							
								
								
									
										42
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										42
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -1,11 +1,8 @@ | ||||
| #![feature(iter_map_windows)] | ||||
| use iced::{ | ||||
|     Element, Length, Task, clipboard, | ||||
|     widget::{ | ||||
|         self, button, column, combo_box, row, scrollable, | ||||
|         scrollable::{Direction, Scrollbar}, | ||||
|         text, text_input, | ||||
|     }, | ||||
|     clipboard, color, widget::{ | ||||
|         self, button, column, combo_box, row, scrollable, scrollable::{Direction, Scrollbar}, text, text_input | ||||
|     }, Element, Length, Task, Theme | ||||
| }; | ||||
| use std::{env, fs, path::PathBuf}; | ||||
| use texts::*; | ||||
| @@ -34,7 +31,9 @@ fn main() -> iced::Result { | ||||
|     } | ||||
|  | ||||
|     // GUI | ||||
|     iced::run("Bible Search", State::update, State::view) | ||||
|     iced::application("Bible Study", State::update, State::view) | ||||
|         .theme(|_| Theme::Nord) | ||||
|         .run() | ||||
| } | ||||
|  | ||||
| #[derive(Debug, Clone)] | ||||
| @@ -178,6 +177,7 @@ impl State { | ||||
|         scrollable(row![ | ||||
|             row((0..self.cols).map(|col_index| { | ||||
|                 column![ | ||||
|                     // header | ||||
|                     combo_box( | ||||
|                         &self.files, | ||||
|                         "Select Bible", | ||||
| @@ -199,6 +199,7 @@ impl State { | ||||
|                             .on_press_with(move || Message::CopyText(col_index)), | ||||
|                     ], | ||||
|                     row![ | ||||
|                         // Word search results | ||||
|                         scrollable( | ||||
|                             column( | ||||
|                                 self.states[col_index] | ||||
| @@ -214,14 +215,28 @@ impl State { | ||||
|                                         .into()) | ||||
|                             ) | ||||
|                             .padding([5, 5]) | ||||
|                         ), | ||||
|                         scrollable(text( | ||||
|                             if let Some(body) = self.states[col_index].scripture_body.clone() { | ||||
|                                 parse(&body) | ||||
|                         ) | ||||
|                         .spacing(5), | ||||
|                         // Body | ||||
|                         scrollable( | ||||
|                             if let Some(body) = &self.states[col_index].scripture_body { | ||||
|                                 column(body.split("\n").enumerate().map(|(i, msg)| { | ||||
|                                     let msg = parse(msg); | ||||
|                                     if i & 1 == 0 { | ||||
|                                         text(msg.to_owned()) | ||||
|                                             .color(color![0xFFFFFF]) | ||||
|                                             .into() | ||||
|                                     } else { | ||||
|                                         text(msg.to_owned()).color(color![0xAAAAAA]).into() | ||||
|                                     } | ||||
|                                 })) | ||||
|                             } else { | ||||
|                                 String::new() | ||||
|                                 column( | ||||
|                                     Vec::<String>::new().iter().map(|_| text(String::new()).into()) | ||||
|                                     ) | ||||
|                             } | ||||
|                         )) | ||||
|                         ) | ||||
|                         .spacing(5) | ||||
|                     ], | ||||
|                 ] | ||||
|                 .padding([10, 5]) | ||||
| @@ -316,3 +331,4 @@ fn parse(input: &str) -> String { | ||||
|  | ||||
|     modified | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -78,7 +78,7 @@ pub fn search_for_word(word: &str, from_files: &Bible) -> Vec<String> { | ||||
|         for book in &test.books { | ||||
|             for chapter in &book.chapters { | ||||
|                 for verse in &chapter.verses { | ||||
|                     if verse.text.contains(word) { | ||||
|                     if verse.text.to_lowercase().contains(&word.to_lowercase()) { | ||||
|                         found.push(format!("{} {}:{}", BOOKS_IN_ORDER[book.number-1], chapter.number, verse.number)); | ||||
|                     } | ||||
|                 } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user