summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-01-03 12:09:07 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2022-01-03 12:09:07 +0700
commitecd0997576378caab549cfe537639355e4a75376 (patch)
tree541c7979912a64f332c48dd50d1c03213308ceae /examples
parent8a70d10401eb1277718a19f47ff1e2a5c4c7564b (diff)
downloadiced-ecd0997576378caab549cfe537639355e4a75376.tar.gz
iced-ecd0997576378caab549cfe537639355e4a75376.tar.bz2
iced-ecd0997576378caab549cfe537639355e4a75376.zip
Center contents with `Container` in `exit` example
... also add some `padding` to buttons!
Diffstat (limited to 'examples')
-rw-r--r--examples/exit/src/main.rs23
1 files changed, 16 insertions, 7 deletions
diff --git a/examples/exit/src/main.rs b/examples/exit/src/main.rs
index c3a190d8..c45a8205 100644
--- a/examples/exit/src/main.rs
+++ b/examples/exit/src/main.rs
@@ -1,5 +1,6 @@
use iced::{
- button, Alignment, Button, Column, Element, Sandbox, Settings, Text,
+ button, Alignment, Button, Column, Container, Element, Length, Sandbox,
+ Settings, Text,
};
pub fn main() -> iced::Result {
@@ -47,9 +48,9 @@ impl Sandbox for Exit {
}
fn view(&mut self) -> Element<Message> {
- if self.show_confirm {
+ let content = if self.show_confirm {
Column::new()
- .padding(20)
+ .spacing(10)
.align_items(Alignment::Center)
.push(Text::new("Are you sure you want to exit?"))
.push(
@@ -57,19 +58,27 @@ impl Sandbox for Exit {
&mut self.confirm_button,
Text::new("Yes, exit now"),
)
+ .padding([10, 20])
.on_press(Message::Confirm),
)
- .into()
} else {
Column::new()
- .padding(20)
+ .spacing(10)
.align_items(Alignment::Center)
.push(Text::new("Click the button to exit"))
.push(
Button::new(&mut self.exit_button, Text::new("Exit"))
+ .padding([10, 20])
.on_press(Message::Exit),
)
- .into()
- }
+ };
+
+ Container::new(content)
+ .width(Length::Fill)
+ .height(Length::Fill)
+ .padding(20)
+ .center_x()
+ .center_y()
+ .into()
}
}