Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
TBS1996 committed Nov 6, 2022
1 parent fe226ac commit 17d775f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "speki"
version = "0.4.3"
version = "0.4.4"
edition = "2021"
authors = ["Tor Berge torberge@outlook.com"]
license = "GPL-2.0-only"
Expand Down
48 changes: 25 additions & 23 deletions src/popups/wikiselect.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
use tui::layout::Rect;
use tui::layout::{Constraint, Rect};
use tui::Frame;

use crate::app::{AppData, PopUpState, Tab, TabData, Widget};
use crate::utils::aliases::*;
use crate::utils::misc::{split_updown_by_percent, View};
use crate::utils::misc::split_updown;
use crate::utils::sql::insert::new_incread;
use crate::widgets::infobox::InfoBox;
use crate::widgets::textinput::Field;
use crate::{MyKey, MyType};

pub struct WikiSelect {
pub struct WikiSelect<'a> {
pub searchbar: Field,
prompt: String,
prompt: InfoBox<'a>,
topic: TopicID,
tabdata: TabData,
}

impl WikiSelect {
impl<'a> WikiSelect<'a> {
pub fn new(id: TopicID) -> Self {
WikiSelect {
searchbar: Field::default(),
prompt: "Search for a wikipedia page".to_string(),
prompt: InfoBox::new("Search for a wikipedia page".to_string()),
topic: id,
tabdata: TabData::default(),
}
}
}
impl Tab for WikiSelect {
impl<'a> Tab for WikiSelect<'a> {
fn get_tabdata(&mut self) -> &mut TabData {
&mut self.tabdata
}
Expand All @@ -34,10 +35,6 @@ impl Tab for WikiSelect {
"Wikipedia selection".to_string()
}

fn get_view(&mut self) -> &mut View {
todo!()
}

fn navigate(&mut self, _dir: crate::NavDir) {}

fn keyhandler(&mut self, appdata: &AppData, key: MyKey, _cursor: &(u16, u16)) {
Expand All @@ -50,24 +47,29 @@ impl Tab for WikiSelect {
new_incread(&appdata.conn, 0, self.topic, content, true).unwrap();
self.tabdata.state = PopUpState::Exit;
} else {
self.prompt = "Invalid search result".to_string();
self.prompt = InfoBox::new("Invalid search result".to_string());
}
}
key => self.searchbar.keyhandler(appdata, key),
}
}
fn set_selection(&mut self, area: Rect) {
let chunks = split_updown(
[
Constraint::Percentage(20),
Constraint::Percentage(20),
Constraint::Length(3),
Constraint::Percentage(20),
],
area,
);
self.prompt.set_area(chunks[1]);
self.searchbar.set_area(chunks[2]);
self.tabdata.view.areas.push(chunks[2]);
}

fn set_selection(&mut self, _area: Rect) {}

fn render(&mut self, f: &mut Frame<MyType>, appdata: &AppData, _cursor: &(u16, u16)) {
let cursor = &(0, 0);
let chunks = split_updown_by_percent([50, 50], f.size());
let (mut msg, mut search) = (chunks[0], chunks[1]);
msg.y = search.y - 5;
msg.height = 5;
search.height = 3;
self.searchbar.set_area(chunks[1]);
//draw_message(f, msg, &self.prompt);
fn render(&mut self, f: &mut Frame<MyType>, appdata: &AppData, cursor: &(u16, u16)) {
self.prompt.render(f, appdata, cursor);
self.searchbar.render(f, appdata, cursor);
}
}
2 changes: 1 addition & 1 deletion src/utils/incread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ pub struct IncRead {
pub id: IncID,
pub parent: IncID,
pub topic: TopicID,
pub isactive: bool,
pub source: Field,
pub extracts: StatefulList<IncListItem>,
pub clozes: StatefulList<CardItem>,
pub isactive: bool,
}

impl IncRead {
Expand Down

0 comments on commit 17d775f

Please sign in to comment.