use crate::{assets, view::settings::SettingsWindow};
use bezel::{
gpui::{AnyElement, Context, div, img, prelude::*, px},
theme::{TextStyle, Theme, Typeset},
ui::widgets::{Content, Scaffolding},
};
const VERSION: &str = env!("CARGO_PKG_VERSION");
const COMMIT: &str = env!("CYDONIA_COMMIT");
const COMMUNITY: &str = "https://discord.gg/yGZDYnwbx6";
const MARK: f32 = 72.;
impl SettingsWindow {
pub(super) fn general_body(&self, cx: &Context<Self>) -> AnyElement {
let theme = Theme::of(cx).clone();
div()
.flex()
.flex_col()
.gap(px(super::GROUP_GAP))
.children(assets::mark().map(|path| {
div()
.flex()
.justify_center()
.child(img(path).size(px(MARK)))
}))
.child(
theme
.group_box()
.child(
theme
.card_row(true)
.child(div().flex_1().min_w_0().child(theme.row_title("Version")))
.child(theme.badge(VERSION)),
)
.child(
theme
.card_row(false)
.child(div().flex_1().min_w_0().child(theme.row_title("Commit")))
.child(match commit_url() {
Some(url) => div()
.id("commit")
.cursor_pointer()
.hover(|el| el.text_color(theme.accent))
.child(theme.badge(COMMIT))
.on_click(move |_, _, cx| cx.open_url(&url))
.into_any_element(),
None => theme.badge(COMMIT).into_any_element(),
}),
),
)
.child(
div().flex().justify_center().child(
div()
.id("community")
.cursor_pointer()
.text_style(TextStyle::Callout)
.text_color(theme.text_muted)
.hover(|el| el.text_color(theme.accent))
.child("Community")
.on_click(|_, _, cx| cx.open_url(COMMUNITY)),
),
)
.into_any_element()
}
}
fn commit_url() -> Option<String> {
let sha = COMMIT.split('-').next()?;
(sha != "unknown").then(|| format!("{}/commit/{sha}", env!("CARGO_PKG_REPOSITORY")))
}