gitkraft_gui/widgets/
about.rs1use 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
10pub 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(Length::Fill)
71 .max_width(460)
72 .padding(20)
73 .style(theme::context_menu_style);
74
75 let backdrop = mouse_area(
76 container(Space::new().width(Length::Fill).height(Length::Fill))
77 .style(theme::backdrop_style),
78 )
79 .on_press(Message::ToggleAbout);
80
81 let panel = mouse_area(panel).on_press(Message::Noop);
83
84 let centered = container(panel)
85 .width(Length::Fill)
86 .height(Length::Fill)
87 .center_x(Length::Fill)
88 .center_y(Length::Fill);
89
90 iced::widget::stack![backdrop, centered].into()
91}