grey out search results once it's visted
This commit is contained in:
parent
6d24b304ce
commit
789c593f7e
33
src/main.rs
33
src/main.rs
@ -82,7 +82,7 @@ enum Message {
|
||||
Clear(usize),
|
||||
WordSearchInput(usize, String),
|
||||
SubmitWordSearch(usize),
|
||||
QuickSearch(usize, String),
|
||||
QuickSearch(usize, String, usize),
|
||||
AddColRight,
|
||||
DeleteColumn(usize),
|
||||
}
|
||||
@ -95,7 +95,7 @@ struct ColState {
|
||||
scripture_body: Option<String>,
|
||||
|
||||
word_search: String,
|
||||
word_search_results: Option<Vec<String>>,
|
||||
word_search_results: Option<Vec<(String, bool)>>,
|
||||
}
|
||||
|
||||
impl Default for ColState {
|
||||
@ -176,8 +176,12 @@ impl State {
|
||||
}
|
||||
}
|
||||
}
|
||||
Message::QuickSearch(i, s) => {
|
||||
Message::QuickSearch(i, s, result_index) => {
|
||||
self.states[i].bible_search = s;
|
||||
if let Some(wsr) = &mut self.states[i].word_search_results {
|
||||
// set "visited" for this link
|
||||
wsr[result_index].1 = true;
|
||||
}
|
||||
return self.update(Message::BibleSearchSubmit(i));
|
||||
}
|
||||
Message::BibleSearchInput(i, query) => self.states[i].bible_search = query,
|
||||
@ -196,7 +200,12 @@ impl State {
|
||||
Message::SubmitWordSearch(i) => {
|
||||
if let Some(bible) = &self.states[i].bible_selected {
|
||||
let res = bible::search_for_word(&self.states[i].word_search, bible);
|
||||
self.states[i].word_search_results = Some(res);
|
||||
self.states[i].word_search_results = Some(
|
||||
res
|
||||
.into_iter()
|
||||
.map(|f| (f, false))
|
||||
.collect()
|
||||
);
|
||||
}
|
||||
}
|
||||
Message::CopyText(i) => {
|
||||
@ -258,12 +267,22 @@ impl State {
|
||||
.clone()
|
||||
.unwrap_or(Vec::new())
|
||||
.into_iter()
|
||||
.map(|i| button(text(i.clone()))
|
||||
.enumerate()
|
||||
.map(|(idx,i)| {
|
||||
let style = if i.1 {
|
||||
button::secondary
|
||||
} else {
|
||||
button::primary
|
||||
};
|
||||
button(text(i.0.clone()))
|
||||
.style(style)
|
||||
.on_press_with(move || Message::QuickSearch(
|
||||
col_index,
|
||||
i.to_owned()
|
||||
i.0.to_owned(),
|
||||
idx
|
||||
))
|
||||
.into())
|
||||
.into()
|
||||
})
|
||||
)
|
||||
.padding([5, 5])
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user