// Copyright (c) 2022 Marceline Cramer // SPDX-License-Identifier: AGPL-3.0-or-later use super::prelude::*; use button::{RoundButton, RoundButtonStyle}; use serde::Deserialize; use shell::Offset; use text::{HorizontalAlignment, Label, LabelText}; #[derive(Copy, Clone, Debug, Deserialize)] pub enum DialogResponse { Yes, No, } impl DialogResponse { pub fn get_text(&self) -> &'static str { match self { DialogResponse::Yes => "", DialogResponse::No => "", } } pub fn get_color(&self) -> Color { match self { DialogResponse::Yes => THEME.palette.blue, DialogResponse::No => THEME.palette.red, } } } #[derive(Clone)] pub struct DialogStyle { pub rounding: f32, pub header: DialogHeaderStyle, pub body: DialogBodyStyle, pub footer: DialogFooterStyle, } impl Default for DialogStyle { fn default() -> Self { Self { rounding: THEME.metrics.surface_rounding, header: Default::default(), body: Default::default(), footer: Default::default(), } } } #[derive(Clone)] pub struct DialogHeaderStyle { pub color: Color, pub height: f32, pub text_font: Font, pub text_color: Color, pub text_scale_factor: f32, pub text_baseline: f32, } impl Default for DialogHeaderStyle { fn default() -> Self { Self { color: THEME.palette.surface, height: 20.0, text_font: Font::new(crate::DISPLAY_FONT), text_color: THEME.palette.text, text_scale_factor: 0.65, text_baseline: 0.25, } } } #[derive(Clone)] pub struct DialogBodyStyle { pub color: Color, pub text_font: Font, pub text_color: Color, pub text_size: f32, } impl Default for DialogBodyStyle { fn default() -> Self { Self { color: THEME.palette.base, text_font: Font::new(crate::CONTENT_FONT), text_color: THEME.palette.text, text_size: 5.0, } } } #[derive(Clone)] pub struct DialogFooterStyle { pub icon_font: Font, pub button_radius: f32, pub color: Color, pub button_fg: Color, pub height: f32, } impl Default for DialogFooterStyle { fn default() -> Self { Self { icon_font: Font::new(crate::ICON_FONT), button_radius: 7.5, color: THEME.palette.surface, button_fg: THEME.palette.white, height: 15.0, } } } #[derive(Deserialize)] pub struct DialogInfo { pub title: String, pub content: String, pub responses: Vec, } pub struct Dialog { style: DialogStyle, title: Offset