cargo: fmt

This commit is contained in:
Muhammad Nauman Raza 2025-02-19 15:45:18 +00:00
parent a529c91261
commit 7bb06ff501
Signed by: devraza
GPG key ID: 91EAD6081011574B

View file

@ -1,21 +1,18 @@
use color_eyre::Result; use color_eyre::Result;
use ratatui::{ use ratatui::{
DefaultTerminal,
buffer::Buffer, buffer::Buffer,
crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind}, crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind},
layout::{Constraint, Layout, Rect, Flex}, layout::{Constraint, Flex, Layout, Rect},
style::{ style::{Modifier, Style, palette::tailwind::*},
palette::tailwind::*,
Modifier, Style
},
text::Line, text::Line,
widgets::{ widgets::{Block, Borders, HighlightSpacing, List, ListState, StatefulWidget, Widget},
Block, Borders, HighlightSpacing, List, ListState,
StatefulWidget, Widget,
},
DefaultTerminal
}; };
const MENU_HEADER_STYLE: Style = Style::new().fg(ZINC.c100).bg(BLUE.c600).add_modifier(Modifier::BOLD); const MENU_HEADER_STYLE: Style = Style::new()
.fg(ZINC.c100)
.bg(BLUE.c600)
.add_modifier(Modifier::BOLD);
const HEADER_STYLE: Style = Style::new().fg(ROSE.c400).add_modifier(Modifier::BOLD); const HEADER_STYLE: Style = Style::new().fg(ROSE.c400).add_modifier(Modifier::BOLD);
const SELECTED_STYLE: Style = Style::new().bg(ZINC.c700).add_modifier(Modifier::BOLD); const SELECTED_STYLE: Style = Style::new().bg(ZINC.c700).add_modifier(Modifier::BOLD);
@ -39,9 +36,7 @@ struct MenuList {
impl FromIterator<&'static str> for MenuList { impl FromIterator<&'static str> for MenuList {
fn from_iter<I: IntoIterator<Item = &'static str>>(iter: I) -> Self { fn from_iter<I: IntoIterator<Item = &'static str>>(iter: I) -> Self {
let items = iter let items = iter.into_iter().collect();
.into_iter()
.collect();
let state = ListState::default(); let state = ListState::default();
Self { items, state } Self { items, state }
} }
@ -51,11 +46,7 @@ impl Default for App {
fn default() -> Self { fn default() -> Self {
Self { Self {
should_exit: false, should_exit: false,
menu: MenuList::from_iter([ menu: MenuList::from_iter(["40L", "Blitz", "TxLeague"]),
"40L",
"Blitz",
"TxLeague",
]),
} }
} }
} }
@ -106,11 +97,8 @@ fn center(area: Rect, horizontal: Constraint, vertical: Constraint) -> Rect {
impl Widget for &mut App { impl Widget for &mut App {
fn render(self, area: Rect, buf: &mut Buffer) { fn render(self, area: Rect, buf: &mut Buffer) {
let [header_area, main_area] = Layout::vertical([ let [header_area, main_area] =
Constraint::Length(2), Layout::vertical([Constraint::Length(2), Constraint::Fill(1)]).areas(area);
Constraint::Fill(1),
])
.areas(area);
let list_area = center(main_area, Constraint::Length(30), Constraint::Length(5)); let list_area = center(main_area, Constraint::Length(30), Constraint::Length(5));
@ -132,10 +120,7 @@ impl App {
.title(Line::raw(" Menu ").centered().style(MENU_HEADER_STYLE)) .title(Line::raw(" Menu ").centered().style(MENU_HEADER_STYLE))
.borders(Borders::ALL); .borders(Borders::ALL);
let items: Vec<&'static str> = self let items: Vec<&'static str> = self.menu.items.clone();
.menu
.items
.clone();
let list = List::new(items) let list = List::new(items)
.block(block) .block(block)