rooms-launcher/src/components/settings.rs
2025-07-13 14:35:11 +02:00

52 lines
No EOL
1.3 KiB
Rust

use iced::{Element, Length};
use iced::widget::{Button, TextInput, Container, Column, Row, text};
#[derive(Debug, Clone)]
pub enum SettingsMessage {
GamePathChanged(String),
Save,
Cancel,
}
#[derive(Debug, Clone, Default)]
pub struct SettingsModal {
pub game_path: String,
pub is_open: bool,
}
impl SettingsModal {
pub fn new(game_path: String) -> Self {
Self {
game_path,
is_open: false,
}
}
pub fn view(&self) -> Element<'_, SettingsMessage> {
if !self.is_open {
return Container::new(text("")).into();
}
let input = TextInput::new(
"Enter game path...",
&self.game_path,
)
.on_input(SettingsMessage::GamePathChanged)
.width(Length::Fill);
let save = Button::new(text("Save")).on_press(SettingsMessage::Save);
let cancel = Button::new(text("Cancel")).on_press(SettingsMessage::Cancel);
let content = Column::new()
.push(text("Settings").size(30))
.push(input)
.push(Row::new().push(save).push(cancel).spacing(10))
.spacing(20);
Container::new(content)
.width(Length::Fixed(400.0))
.height(Length::Fixed(200.0))
.padding(20)
.center(Length::Fill)
.into()
}
}