1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! The sponsor dialog: what sponsoring pays for, then a button that opens
//! GitHub Sponsors in the browser. Nothing is sent from the app itself.
use gpui::{AnyElement, Context, div, prelude::*, px};
use crate::app::Rosier;
use crate::assets::Icon;
use crate::i18n::t;
use crate::theme;
use crate::ui::{button, glass, glass_sheen, icon, primary_button};
pub const SPONSOR_URL: &str = "https://github.com/sponsors/nao1215";
/// GitHub Sponsors' heart.
const HEART: u32 = 0xdb61a2;
impl Rosier {
pub(crate) fn open_sponsor_page(&mut self, cx: &mut Context<Self>) {
cx.open_url(SPONSOR_URL);
self.show_sponsor = false;
cx.notify();
}
pub(crate) fn render_sponsor(&mut self, cx: &mut Context<Self>) -> AnyElement {
div()
.id("sponsor")
.absolute()
.top_0()
.left_0()
.size_full()
.flex()
.items_center()
.justify_center()
.bg(gpui::rgba(0x000000a8))
.on_click(cx.listener(|this, _, _, cx| {
this.show_sponsor = false;
cx.notify();
}))
.child(
glass(theme::R_PANEL)
.id("sponsor-dialog")
// Clicks inside the dialog do not close it.
.on_click(|_, _, cx| cx.stop_propagation())
.bg(gpui::rgba(0x18181cf0))
.w(px(432.0))
.p_6()
.flex()
.flex_col()
.gap_4()
.child(glass_sheen(theme::R_PANEL))
.child(
div()
.flex()
.flex_row()
.items_center()
.gap_2()
.child(icon(Icon::HeartFill, 20.0, gpui::rgb(HEART)))
.child(div().text_lg().child(t("sponsor.title"))),
)
.child(div().text_sm().text_color(theme::text_dim()).child(t("sponsor.body")))
.child(
div()
.pt_2()
.flex()
.flex_row()
.justify_end()
.gap_2()
.child(button("sponsor-close").child(t("sponsor.close")).on_click(cx.listener(
|this, _, _, cx| {
this.show_sponsor = false;
cx.notify();
},
)))
.child(
primary_button("sponsor-open", t("sponsor.open"))
.on_click(cx.listener(|this, _, _, cx| this.open_sponsor_page(cx))),
),
),
)
.into_any_element()
}
}