45 lines
1.6 KiB
Rust
45 lines
1.6 KiB
Rust
use eframe::egui::{self, Color32, TextEdit};
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
pub struct Login {
|
|
pub homeserver: String,
|
|
pub username: String,
|
|
pub password: String,
|
|
pub error: Option<String>,
|
|
}
|
|
|
|
impl Login {
|
|
pub fn update(&mut self, ctx: &egui::CtxRef) -> bool {
|
|
let mut update = false;
|
|
egui::CentralPanel::default().show(ctx, |ui| {
|
|
ui.add_space(ui.available_height() / 3.0);
|
|
ui.vertical_centered(|ui| {
|
|
//ui.style_mut() .visuals .widgets .noninteractive .bg_stroke .color = egui::Color32::TRANSPARENT;
|
|
ui.group(|ui| {
|
|
//ui.reset_style();
|
|
if let Some(ref error) = self.error {
|
|
ui.colored_label(Color32::from_rgb(255, 0, 0), error);
|
|
}
|
|
ui.set_max_width(300.0);
|
|
ui.vertical(|ui| {
|
|
ui.heading("Log in");
|
|
ui.label("Homeserver:");
|
|
ui.add(
|
|
TextEdit::singleline(&mut self.homeserver)
|
|
.hint_text("https://example.net"),
|
|
);
|
|
ui.label("Username:");
|
|
ui.add(TextEdit::singleline(&mut self.username).hint_text("alice"));
|
|
ui.label("Password:");
|
|
ui.add(TextEdit::singleline(&mut self.password).password(true));
|
|
if ui.button("Log in").clicked() {
|
|
update = true;
|
|
}
|
|
})
|
|
})
|
|
});
|
|
});
|
|
update
|
|
}
|
|
}
|