Created
February 14, 2021 13:52
-
-
Save kivimango/d1dbda66c8eecf69038802891bec1308 to your computer and use it in GitHub Desktop.
dialog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| widget!(FineDialog { | |
| background: Brush, | |
| body_background: Brush, | |
| body_foreground: Brush, | |
| body_font: String, | |
| body_font_size: f64, | |
| body_padding: Thickness, | |
| border_brush: Brush, | |
| border_radius: f64, | |
| border_width: Thickness, | |
| header_align: Alignment, | |
| header_background: Brush, | |
| header_foreground: Brush, | |
| header_font_size: f64, | |
| header_font: String, | |
| header_padding: Thickness, | |
| icon: String, | |
| icon_brush: Brush, | |
| icon_size: f64, | |
| icon_font: String, | |
| message: String, | |
| title: String, | |
| parent: u32 | |
| }); | |
| impl FineDialog { | |
| pub fn on_ok() { | |
| } | |
| } | |
| impl Template for FineDialog { | |
| fn template(self, id: Entity, ctx: &mut BuildContext) -> Self { | |
| self.name("Dialog") | |
| .background("transparent") | |
| .body_foreground("#000000") | |
| .body_padding(2.0) | |
| .body_font("Roboto-Regular") | |
| .body_font_size(16.0) | |
| .border_brush("#000000") | |
| .border_radius(2.0) | |
| .border_width(6.0) | |
| // TODO: fix Container child width bug if its set to anything else than Stretch | |
| .header_align(Alignment::Stretch) | |
| .header_background("transparent") | |
| .header_foreground("#FFFFFF") | |
| .header_font_size(20.0) | |
| .header_font("Roboto-Regular") | |
| .header_padding(2.0) | |
| .icon("") | |
| .icon_brush(colors::LINK_WATER_COLOR) | |
| .icon_size(fonts::ICON_FONT_SIZE_12) | |
| .icon_font("MaterialIcons-Regular") | |
| .message("") | |
| .title("") | |
| .child( | |
| Container::new() | |
| .child( | |
| Grid::new() | |
| .rows(Rows::create().push("auto").push("auto").push("auto").build()) | |
| .columns(Columns::create().push("auto").push("auto").build()) | |
| .child( | |
| Container::new() | |
| .attach(Grid::column(0)) | |
| .attach(Grid::column_span(2)) | |
| .attach(Grid::row(0)) | |
| .background(("header_background", id)) | |
| .h_align(("header_align", id)) | |
| .padding(("header_padding", id)) | |
| .style("dialog_header_container") | |
| .v_align("center") | |
| .child( | |
| TextBlock::new() | |
| .foreground(("header_foreground", id)) | |
| .font(("header_font", id)) | |
| .font_size(("header_font_size", id)) | |
| .style("dialog_header_text") | |
| .text(("title", id)) | |
| .build(ctx) | |
| ) | |
| .build(ctx) | |
| ) | |
| .child( | |
| Container::new() | |
| .attach(Grid::column(0)) | |
| .attach(Grid::row(1)) | |
| .background(("background", id)) | |
| .style("dialog_body_container") | |
| .child( | |
| FontIconBlock::new() | |
| .icon(material_icons_font::MD_INFO) | |
| .icon_brush(id) | |
| .icon_font(id) | |
| .icon_size(id) | |
| .size(64.0, 64.0) | |
| .style("dialog_icon") | |
| .h_align("center") | |
| .v_align("center") | |
| .build(ctx) | |
| ).build(ctx) | |
| ) | |
| .child( | |
| Container::new() | |
| .attach(Grid::column(1)) | |
| .attach(Grid::row(1)) | |
| .background(id) | |
| .padding(("body_padding", id)) | |
| .style("dialog_body_container") | |
| .child( | |
| TextBlock::new() | |
| .font(("body_font", id)) | |
| .font_size(("body_font_size", id)) | |
| .foreground(("body_foreground", id)) | |
| .style("dialog_text") | |
| .text(("message", id)) | |
| .h_align("end") | |
| .v_align("center") | |
| .build(ctx) | |
| ) | |
| .build(ctx) | |
| ) | |
| .child( | |
| Container::new() | |
| .attach(Grid::column(0)) | |
| .attach(Grid::column_span(2)) | |
| .attach(Grid::row(2)) | |
| .background(id) | |
| .padding(("body_padding", id)) | |
| .style("dialog_body_container") | |
| .child( | |
| Button::new() | |
| .h_align("center") | |
| .v_align("center") | |
| .text("OK") | |
| .build(ctx) | |
| ) | |
| .build(ctx) | |
| ) | |
| .build(ctx) | |
| ) .build(ctx) | |
| ) | |
| } | |
| } | |
| fn main() { | |
| Application::new() | |
| .window(|ctx| { | |
| Window::new() | |
| .title("Dialogs example") | |
| .child( | |
| FineDialog::new() | |
| .header_background("#DC5E5E") | |
| .header_foreground("#FFFFFF") | |
| .background("#FFFFFF") | |
| .icon_brush("#000000") | |
| .icon_size(20.0) | |
| .message("A feedback message that informs you about \nsomething which you can only accept") | |
| .title("Confirm") | |
| //.on_ok({print!("on_ok()");}) | |
| .build(ctx) | |
| ) | |
| .size(500, 500) | |
| .build(ctx) | |
| }) | |
| .run(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment