Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: display network for console wallet #3611

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions applications/tari_console_wallet/src/ui/components/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use tari_app_utilities::consts;
use tui::{
backend::Backend,
layout::{Constraint, Direction, Layout, Rect},
style::{Color, Modifier, Style},
style::{Color, Style},
text::{Span, Spans},
widgets::{Block, Paragraph},
Frame,
Expand All @@ -18,14 +18,15 @@ impl Menu {
}

impl<B: Backend> Component<B> for Menu {
fn draw(&mut self, f: &mut Frame<B>, area: Rect, _app_state: &AppState)
fn draw(&mut self, f: &mut Frame<B>, area: Rect, app_state: &AppState)
where B: Backend {
let columns = Layout::default()
.direction(Direction::Horizontal)
.constraints(
[
Constraint::Ratio(1, 5),
Constraint::Ratio(3, 5),
Constraint::Ratio(1, 5),
Constraint::Ratio(2, 5),
Constraint::Ratio(1, 5),
]
.as_ref(),
Expand All @@ -36,31 +37,46 @@ impl<B: Backend> Component<B> for Menu {
Span::styled(" Version: ", Style::default().fg(Color::White)),
Span::styled(consts::APP_VERSION_NUMBER, Style::default().fg(Color::Magenta)),
Span::raw(" "),
match cfg!(feature = "avx2") {
true => Span::styled("Avx2", Style::default().fg(Color::LightGreen)),
false => Span::styled(
"Avx2",
Style::default().fg(Color::LightRed).add_modifier(Modifier::CROSSED_OUT),
),
},
/* In the event this is needed in future, should be put into its' own span
* match cfg!(feature = "avx2") {
* true => Span::styled("Avx2", Style::default().fg(Color::LightGreen)),
* false => Span::styled(
* "Avx2",
* Style::default().fg(Color::LightRed).add_modifier(Modifier::CROSSED_OUT),
* ),
* },
*/
]);

let network = Spans::from(vec![
Span::styled(" Network: ", Style::default().fg(Color::White)),
Span::styled(
app_state.get_network().to_string(),
Style::default().fg(Color::LightGreen),
),
Span::raw(" "),
]);

let tabs = Spans::from(vec![
Span::styled("LeftArrow: ", Style::default().fg(Color::White)),
Span::styled("Previous Tab ", Style::default().fg(Color::Magenta)),
Span::raw(" "),
Span::styled("Tab/RightArrow: ", Style::default().fg(Color::White)),
Span::styled("Next Tab ", Style::default().fg(Color::Magenta)),
]);

let quit = Spans::from(vec![
Span::styled(" F10/Ctrl-Q: ", Style::default().fg(Color::White)),
Span::styled("Quit ", Style::default().fg(Color::Magenta)),
]);

let paragraph = Paragraph::new(version).block(Block::default());
let paragraph = Paragraph::new(network).block(Block::default());
f.render_widget(paragraph, columns[0]);
let paragraph = Paragraph::new(tabs).block(Block::default());
let paragraph = Paragraph::new(version).block(Block::default());
f.render_widget(paragraph, columns[1]);
let paragraph = Paragraph::new(quit).block(Block::default());
let paragraph = Paragraph::new(tabs).block(Block::default());
f.render_widget(paragraph, columns[2]);
let paragraph = Paragraph::new(quit).block(Block::default());
f.render_widget(paragraph, columns[3]);
}
}
4 changes: 4 additions & 0 deletions applications/tari_console_wallet/src/ui/state/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,10 @@ impl AppState {
Igor => MicroTari(5),
}
}

pub fn get_network(&self) -> Network {
self.node_config.network
}
}
pub struct AppStateInner {
updated: bool,
Expand Down