added delete button in the settings window which deletes a server from the list

This commit is contained in:
Martin 2022-01-25 19:48:58 +02:00
parent a86ed49293
commit 700f709664
2 changed files with 27 additions and 5 deletions

View File

@ -38,6 +38,7 @@
"common.random": "Random",
"common.empty": "Empty",
"common.confirm": "Confirm",
"common.delete_server": "Delete Server",
// Settings Window title
"common.interface_settings": "Interface Settings",

View File

@ -10,6 +10,7 @@ use iced::{
pub struct Screen {
back_button: button::State,
delete_button: button::State,
server_buttons: Vec<button::State>,
servers_list: scrollable::State,
}
@ -18,6 +19,7 @@ impl Screen {
pub fn new() -> Self {
Self {
back_button: Default::default(),
delete_button: Default::default(),
server_buttons: vec![],
servers_list: Default::default(),
}
@ -50,6 +52,19 @@ impl Screen {
.width(Length::Fill)
.align_x(Align::Center);
let delete_button = Container::new(
Container::new(neat_button(
&mut self.delete_button,
i18n.get("common.delete_server"),
FILL_FRAC_ONE,
button_style,
Some(Message::DeleteServer),
))
.max_width(200),
)
.width(Length::Fill)
.align_x(Align::Center);
let mut list = Scrollable::new(&mut self.servers_list)
.spacing(8)
.align_items(Align::Start)
@ -104,11 +119,17 @@ impl Screen {
Container::new(
Container::new(
Column::with_children(vec![title.into(), list.into(), back_button.into()])
.width(Length::Fill)
.height(Length::Fill)
.spacing(10)
.padding(20),
Column::with_children(vec![
title.into(),
list.into(),
Row::with_children(vec![delete_button.into(), back_button.into()])
.width(Length::Fill)
.into(),
])
.width(Length::Fill)
.height(Length::Fill)
.spacing(10)
.padding(20),
)
.style(
style::container::Style::color_with_double_cornerless_border(