Просмотр исходного кода

map: fixed more import errors and cleaned warnings

lunar-mining 4 лет назад
Родитель
Сommit
da83426f1f
5 измененных файлов с 16 добавлено и 38 удалено
  1. 8 9
      bin/map/src/app.rs
  2. 1 2
      bin/map/src/list.rs
  3. 3 14
      bin/map/src/main.rs
  4. 1 10
      bin/map/src/node_info.rs
  5. 3 3
      bin/map/src/ui.rs

+ 8 - 9
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(),

+ 1 - 2
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)]

+ 3 - 14
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<B: Backend>(
     terminal: &mut Terminal<B>,
     mut app: App,
-    tick_rate: Duration,
+    _tick_rate: Duration,
 ) -> io::Result<()> {
     let mut asi = async_stdin();
 
@@ -56,7 +45,7 @@ fn run_app<B: Backend>(
 
     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))?;

+ 1 - 10
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<NodeInfo>) -> NodeInfoView {
+    pub fn new(_infos: Vec<NodeInfo>) -> NodeInfoView {
         let index = 0;
         NodeInfoView { index }
     }

+ 3 - 3
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<B: Backend>(f: &mut Frame<B>, 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())
         })