From da83426f1fedc6266aaee0323cb227be13d7642a Mon Sep 17 00:00:00 2001 From: lunar-mining Date: Sun, 16 Jan 2022 18:54:04 +0100 Subject: [PATCH] map: fixed more import errors and cleaned warnings --- bin/map/src/app.rs | 17 ++++++++--------- bin/map/src/list.rs | 3 +-- bin/map/src/main.rs | 17 +++-------------- bin/map/src/node_info.rs | 11 +---------- bin/map/src/ui.rs | 6 +++--- 5 files changed, 16 insertions(+), 38 deletions(-) diff --git a/bin/map/src/app.rs b/bin/map/src/app.rs index 9964bef43..31a1ae55a 100644 --- a/bin/map/src/app.rs +++ b/bin/map/src/app.rs @@ -1,10 +1,9 @@ use crate::{ list::NodeIdList, - node::{NodeInfo, NodeInfoView}, + node_info::{NodeInfo, NodeInfoView}, }; -use rand::Rng; -use smol::Timer; -use std::{collections::HashMap, time::Duration}; +//use smol::Timer; +//use std::{collections::HashMap, time::Duration}; #[derive(Clone)] pub struct App { @@ -16,31 +15,31 @@ impl App { pub fn new() -> App { let infos = vec![ NodeInfo { - id: "sodisofjhosd".to_string(), + id: "0385048034sodisofjhosd1111q3434".to_string(), connections: 10, is_active: true, last_message: "hey how are you?".to_string(), }, NodeInfo { - id: "snfksdfkdjflsjkdfj".to_string(), + id: "09w30we9wsnfksdfkdjflsjkdfjdfsd".to_string(), connections: 5, is_active: false, last_message: "lmao".to_string(), }, NodeInfo { - id: "alsdlasjfrsdfsdfsd".to_string(), + id: "038043325alsdlasjfrsdfsdfsdjsdf".to_string(), connections: 5, is_active: true, last_message: "gm".to_string(), }, NodeInfo { - id: "ldflsdjflsdjflsdjfii".to_string(), + id: "04985034953ldflsdjflsdjflsdjfii".to_string(), connections: 2, is_active: true, last_message: "hihi".to_string(), }, NodeInfo { - id: "asdjapsdika;lsk;asdkas".to_string(), + id: "09850249352asdjapsdikalskasdkas".to_string(), connections: 10, is_active: true, last_message: "wtf".to_string(), diff --git a/bin/map/src/list.rs b/bin/map/src/list.rs index 0ac503a9e..17850005a 100644 --- a/bin/map/src/list.rs +++ b/bin/map/src/list.rs @@ -1,5 +1,4 @@ -use crate::node::{NodeInfo, NodeInfoView}; -use std::collections::HashMap; +//use std::collections::HashMap; use tui::widgets::ListState; #[derive(Clone)] diff --git a/bin/map/src/main.rs b/bin/map/src/main.rs index ad9aab597..837669558 100644 --- a/bin/map/src/main.rs +++ b/bin/map/src/main.rs @@ -1,15 +1,4 @@ -// next/ prev: -// select_node(i) -// NodeInfo -// set-content(node_info) -// clear current text -// let text = ... - -use std::{ - io, - io::Read, - time::{Duration, Instant}, -}; +use std::{io, io::Read, time::Duration}; use termion::{async_stdin, event::Key, input::TermRead, raw::IntoRawMode}; use tui::{ backend::{Backend, TermionBackend}, @@ -48,7 +37,7 @@ fn main() -> Result<(), io::Error> { fn run_app( terminal: &mut Terminal, mut app: App, - tick_rate: Duration, + _tick_rate: Duration, ) -> io::Result<()> { let mut asi = async_stdin(); @@ -56,7 +45,7 @@ fn run_app( app.node_list.state.select(Some(0)); - let mut last_tick = Instant::now(); + //let mut last_tick = Instant::now(); loop { terminal.draw(|f| ui::ui(f, &mut app))?; diff --git a/bin/map/src/node_info.rs b/bin/map/src/node_info.rs index 1e51f1775..e41413f38 100644 --- a/bin/map/src/node_info.rs +++ b/bin/map/src/node_info.rs @@ -1,19 +1,10 @@ -use rand::Rng; - -// TODO: make Node data structure -// hashmap of node_id and node_info -// make NodeInfoView that implements scrolling -// -// NodeInfoView -// next and previous updates index -// and updates info content #[derive(Clone)] pub struct NodeInfoView { pub index: usize, } impl NodeInfoView { - pub fn new(infos: Vec) -> NodeInfoView { + pub fn new(_infos: Vec) -> NodeInfoView { let index = 0; NodeInfoView { index } } diff --git a/bin/map/src/ui.rs b/bin/map/src/ui.rs index 2ee00cec2..c433cd89e 100644 --- a/bin/map/src/ui.rs +++ b/bin/map/src/ui.rs @@ -1,13 +1,13 @@ use crate::{ app::App, - node::{NodeInfo, NodeInfoView}, + //node_info::{NodeInfo, NodeInfoView}, }; use tui::{ backend::Backend, layout::{Constraint, Direction, Layout}, style::{Color, Modifier, Style}, text::Spans, - widgets::{Block, Borders, List, ListItem, Paragraph}, + widgets::{Block, Borders, List, ListItem}, Frame, }; @@ -22,7 +22,7 @@ pub fn ui(f: &mut Frame, app: &mut App) { .node_list .node_id .iter() - .map(|(id)| { + .map(|id| { let line1 = Spans::from(id.to_string()); ListItem::new(vec![line1]).style(Style::default()) })