reverted the idea of getting a lobby list from the server
This commit is contained in:
parent
b37ab4a37d
commit
789e3912d3
4 changed files with 101 additions and 111 deletions
|
@ -1,13 +1,12 @@
|
|||
use anyhow::Result;
|
||||
use ratatui::DefaultTerminal;
|
||||
use ratatui::{widgets::ListState, DefaultTerminal};
|
||||
|
||||
use crate::{message::{Message, MessageKind}, player::Player, ui::{ui, CurrentScreen}};
|
||||
use crate::{lobby::Lobby, message::{Message, MessageKind}, player::Player, ui::{ui, CurrentScreen}};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct Client {
|
||||
pub addr: String,
|
||||
pub client: reqwest::Client,
|
||||
pub current_screen: CurrentScreen,
|
||||
pub user: Option<String>,
|
||||
pub user_name: String,
|
||||
pub exit: bool,
|
||||
|
|
|
@ -19,6 +19,7 @@ pub enum MessageKind {
|
|||
DeleteLobby,
|
||||
JoinLobby,
|
||||
QuitLobby,
|
||||
GetLobbies,
|
||||
}
|
||||
|
||||
impl Message {
|
||||
|
|
|
@ -133,4 +133,5 @@ impl App {
|
|||
) -> Result<axum::response::Json<Message>, StatusCode> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
15
src/ui.rs
15
src/ui.rs
|
@ -8,7 +8,7 @@ use ratatui::{
|
|||
},
|
||||
style::{Color, Style, Stylize},
|
||||
text::{Line, Span, Text},
|
||||
widgets::{Block, Borders, Clear, List, ListItem, Paragraph, Widget, Wrap},
|
||||
widgets::{Block, Borders, Clear, List, ListItem, ListState, Paragraph, Widget, Wrap},
|
||||
Frame,
|
||||
};
|
||||
use ratatui::crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind};
|
||||
|
@ -57,14 +57,12 @@ impl Widget for Popup<'_> {
|
|||
#[derive(Debug, Default)]
|
||||
pub enum CurrentScreen {
|
||||
#[default] Menu,
|
||||
LobbyList,
|
||||
Lobbies,
|
||||
}
|
||||
|
||||
async fn handle_key_event(mut client: &mut Client, key_event: KeyEvent) {
|
||||
match &client.popup {
|
||||
false => {
|
||||
match client.current_screen {
|
||||
CurrentScreen::Menu => {
|
||||
match key_event.code {
|
||||
KeyCode::Char('q') => Client::exit(client),
|
||||
KeyCode::Char('h') => {
|
||||
|
@ -111,9 +109,6 @@ async fn handle_key_event(mut client: &mut Client, key_event: KeyEvent) {
|
|||
_ => (),
|
||||
}
|
||||
}
|
||||
CurrentScreen::LobbyList => todo!(),
|
||||
}
|
||||
}
|
||||
true => {
|
||||
match key_event.code {
|
||||
_ => client.popup = false,
|
||||
|
@ -134,9 +129,6 @@ pub async fn handle_events(client: &mut Client) -> anyhow::Result<()> {
|
|||
}
|
||||
|
||||
pub fn ui(frame: &mut Frame, app: &Client) {
|
||||
match app.current_screen {
|
||||
CurrentScreen::Menu => {
|
||||
|
||||
let chunks = Layout::default()
|
||||
.direction(Direction::Vertical)
|
||||
.constraints([
|
||||
|
@ -195,9 +187,6 @@ pub fn ui(frame: &mut Frame, app: &Client) {
|
|||
.block(btm_block),
|
||||
chunks[1],
|
||||
);
|
||||
}
|
||||
CurrentScreen::LobbyList => todo!(),
|
||||
}
|
||||
|
||||
let popup_area = Rect {
|
||||
x: frame.area().width / 4,
|
||||
|
|
Loading…
Add table
Reference in a new issue