Skip to main content

gitkraft_gui/widgets/
about.rs

1//! About dialog — app name, version, author and project info.
2
3use iced::widget::{button, column, container, mouse_area, row, text, Space};
4use iced::{Alignment, Element, Length};
5
6use crate::message::Message;
7use crate::state::GitKraft;
8use crate::theme;
9
10/// Render the About dialog as a centred modal over a dimmed backdrop.
11pub fn view(state: &GitKraft) -> Element<'_, Message> {
12    use gitkraft_core::about;
13
14    let c = state.colors();
15
16    let link = |label: &'static str, url: &'static str| {
17        button(text(label).size(13).color(c.accent))
18            .padding([2, 0])
19            .style(theme::ghost_button_flat)
20            .on_press(Message::OpenUrl(url.to_string()))
21    };
22
23    let info_row = |key: &'static str, value: Element<'static, Message>| {
24        row![
25            container(text(key).size(13).color(c.muted)).width(90),
26            value,
27        ]
28        .align_y(Alignment::Center)
29    };
30
31    let close_btn = button(text("Close").size(12).color(c.text_primary))
32        .padding([4, 16])
33        .style(theme::toolbar_button)
34        .on_press(Message::ToggleAbout);
35
36    let content = column![
37        text(about::APP_NAME).size(28).color(c.accent),
38        text(about::version_label())
39            .size(14)
40            .color(c.text_secondary),
41        Space::new().height(10),
42        text(about::DESCRIPTION).size(13).color(c.text_primary),
43        Space::new().height(14),
44        info_row(
45            "Author",
46            text(about::AUTHOR_NAME)
47                .size(13)
48                .color(c.text_primary)
49                .into()
50        ),
51        info_row("GitHub", link("@sorinirimies", about::AUTHOR_URL).into()),
52        info_row("Project", link(about::REPO_URL, about::REPO_URL).into()),
53        info_row(
54            "Version",
55            text(about::VERSION).size(13).color(c.text_primary).into()
56        ),
57        info_row(
58            "License",
59            text(about::LICENSE).size(13).color(c.text_primary).into()
60        ),
61        Space::new().height(16),
62        container(close_btn)
63            .width(Length::Fill)
64            .align_right(Length::Fill),
65    ]
66    .spacing(4)
67    .width(Length::Fill);
68
69    let panel = container(content)
70        .width(460)
71        .padding(20)
72        .style(theme::context_menu_style);
73
74    let backdrop = mouse_area(
75        container(Space::new().width(Length::Fill).height(Length::Fill))
76            .style(theme::backdrop_style),
77    )
78    .on_press(Message::ToggleAbout);
79
80    // Swallow clicks on the panel so they don't dismiss the dialog.
81    let panel = mouse_area(panel).on_press(Message::Noop);
82
83    let centered = container(panel)
84        .width(Length::Fill)
85        .height(Length::Fill)
86        .center_x(Length::Fill)
87        .center_y(Length::Fill);
88
89    iced::widget::stack![backdrop, centered].into()
90}