add unlock/exit buttons to home screen

This commit is contained in:
jfmonty2 committed 2026-11-18 20:12:22 -05:00
1 parent b2a7e5759a
commit 3c06f7e536
3 files changed
+112 -6

No files matched your search

+63 -5
View File
@@ -1,13 +1,71 @@
use gpui_kit::{div, Render, Window, Context, IntoElement, Styled, ParentElement};
use gpui_kit::base::Button;
use gpui_kit::{
App, Context, FontWeight, Hsla, InteractiveElement, IntoElement, ParentElement, Render,
StatefulInteractiveElement, Styled, Window, div, rems,
};
use gpui_omarchy::{ActiveTheme, IconName, focus_scope, icon};
use crate::session::AppSession;
pub struct HomeScreen {}
impl Render for HomeScreen {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
div()
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let t = cx.omarchy();
let lock = nav_tile("lock", IconName::ShieldCheck, "Lock", "Lock Creddy.", t.warning, cx)
.on_click(|_, _, cx| cx.set_global(AppSession::Locked));
let exit = nav_tile("exit", IconName::LogOut, "Exit", "Close Creddy.", t.accent, cx)
.on_click(|_, _, cx| cx.quit());
focus_scope("home")
.size_full()
.flex()
.justify_center()
.flex_col()
.items_center()
.child("Creddy is unlocked")
.p(rems(0.5))
.child(
div()
.text_size(rems(1.875))
.font_weight(FontWeight::BOLD)
.child("Creddy"),
)
.child(
// fill the rest of the window so the tiles sit in the middle of it
div()
.flex_1()
.flex()
.items_center()
.gap(rems(1.5))
.child(lock)
.child(exit),
)
}
}
/// A big square-ish button with an icon, a title, and a short description.
fn nav_tile(
id: &'static str,
icon_name: IconName,
title: &'static str,
description: &'static str,
color: Hsla,
cx: &App,
) -> Button {
let t = cx.omarchy();
Button::new(id)
.accessibility_label(title)
.flex_col()
.justify_start()
.gap(rems(1.))
.w(rems(14.))
.p(rems(1.))
.border_1()
.border_color(color)
.hover(|s| s.bg(t.hover_fill()))
.focus_visible(|s| s.bg(t.hover_fill()))
.active(|s| s.bg(t.pressed_fill()))
.child(icon(icon_name).size(rems(3.)).text_color(color))
.child(div().text_size(rems(1.125)).font_weight(FontWeight::BOLD).child(title))
.child(div().text_size(rems(0.875)).text_center().child(description))
}