feat: redesign login panel
This commit is contained in:
@@ -5,7 +5,7 @@ mod sign_in;
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
AppContext as _, Context, Entity, InteractiveElement as _, IntoElement, ParentElement as _,
|
||||
Render, Styled as _, Subscription, Window, div,
|
||||
Render, Styled as _, Subscription, Window, div, px,
|
||||
};
|
||||
use helpers::apply_appearance;
|
||||
use settings::SettingsStore;
|
||||
@@ -34,6 +34,7 @@ pub struct AppRoot {
|
||||
titlebar: Entity<TitlebarView>,
|
||||
toasts: Entity<Toasts>,
|
||||
sign_in: Entity<SignedOutView>,
|
||||
explore: Entity<ExploreView>,
|
||||
empty: Entity<PlaceholderView>,
|
||||
passphrase: Option<Entity<PassphraseDialog>>,
|
||||
_subscriptions: Vec<Subscription>,
|
||||
@@ -48,6 +49,7 @@ impl AppRoot {
|
||||
|
||||
let toasts = cx.new(|_| Toasts::default());
|
||||
let sign_in = cx.new(|_| SignedOutView::new());
|
||||
let explore = cx.new(|cx| ExploreView::new(workspace.downgrade(), cx));
|
||||
let empty = cx.new(|_| PlaceholderView::new("Select a repository"));
|
||||
|
||||
let backend = Backend::global(cx);
|
||||
@@ -95,6 +97,7 @@ impl AppRoot {
|
||||
titlebar,
|
||||
toasts,
|
||||
sign_in,
|
||||
explore,
|
||||
empty,
|
||||
passphrase: None,
|
||||
_subscriptions: subscriptions,
|
||||
@@ -166,6 +169,7 @@ impl Render for AppRoot {
|
||||
})
|
||||
.when(!main.is_some() && !signed_in, |row| {
|
||||
row.main(self.sign_in.clone())
|
||||
.split_at(self.explore.clone(), px(300.))
|
||||
}),
|
||||
)
|
||||
.toasts(self.toasts.clone()),
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use gpui::prelude::FluentBuilder as _;
|
||||
use gpui::{
|
||||
App, Context, Entity, IntoElement, ParentElement as _, Render, SharedString, Styled as _,
|
||||
Window, div,
|
||||
App, Context, Entity, IntoElement, ObjectFit, ParentElement as _, Render, SharedString,
|
||||
Styled as _, StyledImage as _, Window, div, img,
|
||||
};
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
use ui::common::{StyledExt as _, v_flex};
|
||||
use ui::common::v_flex;
|
||||
use ui::layout::panel::Panel;
|
||||
use ui::theme::ActiveTheme as _;
|
||||
|
||||
use crate::identity::import::ImportDialog;
|
||||
use crate::identity::onboarding::OnboardingDialog;
|
||||
|
||||
pub struct SignedOutView {
|
||||
banner: SharedString,
|
||||
onboarding: Option<Entity<OnboardingDialog>>,
|
||||
import: Option<Entity<ImportDialog>>,
|
||||
}
|
||||
@@ -18,6 +22,7 @@ pub struct SignedOutView {
|
||||
impl SignedOutView {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
banner: pick_banner(),
|
||||
onboarding: None,
|
||||
import: None,
|
||||
}
|
||||
@@ -40,28 +45,65 @@ impl Panel for SignedOutView {
|
||||
}
|
||||
}
|
||||
|
||||
/// One of the three banner photos, picked per process launch.
|
||||
fn pick_banner() -> SharedString {
|
||||
let nanos = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.map(|now| now.subsec_nanos())
|
||||
.unwrap_or(0);
|
||||
format!("backgrounds/banner{}.jpg", nanos % 3 + 1).into()
|
||||
}
|
||||
|
||||
impl Render for SignedOutView {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let theme = cx.theme();
|
||||
let colors = theme.colors;
|
||||
|
||||
v_flex()
|
||||
.size_full()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.gap_4()
|
||||
.child(div().text_2xl().font_semibold().child("Signed"))
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.w_48()
|
||||
.size_full()
|
||||
.relative()
|
||||
.bg(colors.background)
|
||||
.rounded(theme.radius.overlay)
|
||||
.overflow_hidden()
|
||||
.child(
|
||||
Button::new("onboarding")
|
||||
.label("Join now")
|
||||
.on_click(cx.listener(|this, _, _, cx| this.open_onboarding(cx))),
|
||||
div().absolute().inset_0().child(
|
||||
img(self.banner.clone())
|
||||
.size_full()
|
||||
.object_fit(ObjectFit::Cover)
|
||||
.rounded(theme.radius.overlay),
|
||||
),
|
||||
)
|
||||
.child(
|
||||
Button::new("import")
|
||||
.label("Import identity")
|
||||
.variant(ButtonVariant::Secondary)
|
||||
.on_click(cx.listener(|this, _, _, cx| this.open_import(cx))),
|
||||
v_flex()
|
||||
.size_full()
|
||||
.justify_end()
|
||||
.p_4()
|
||||
.gap_6()
|
||||
.child(img("backgrounds/headline.png").max_w_48())
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_2()
|
||||
.w_full()
|
||||
.child(
|
||||
Button::new("join")
|
||||
.label("Join now")
|
||||
.variant(ButtonVariant::Primary)
|
||||
.on_click(cx.listener(|this, _, _, cx| {
|
||||
this.open_onboarding(cx)
|
||||
})),
|
||||
)
|
||||
.child(
|
||||
Button::new("import")
|
||||
.label("Import identity")
|
||||
.variant(ButtonVariant::Secondary)
|
||||
.on_click(
|
||||
cx.listener(|this, _, _, cx| this.open_import(cx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
.when_some(self.onboarding.clone(), |el, view| el.child(view))
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use gpui::{
|
||||
AnyElement, App, AppContext as _, Context, Entity, IntoElement, ParentElement as _, Render,
|
||||
Styled as _, Window, div,
|
||||
Styled as _, Window, div, px,
|
||||
};
|
||||
use signed_state::Backend;
|
||||
use ui::button::{Button, ButtonVariant};
|
||||
@@ -22,20 +22,22 @@ impl ExitDialog {
|
||||
|
||||
impl Render for ExitDialog {
|
||||
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
|
||||
const WARNING: &str = "You will be signed out on this device and will need to sign in again on the next session.";
|
||||
|
||||
let cancel_close = self.handle.clone();
|
||||
let confirm_close = self.handle.clone();
|
||||
|
||||
Dialog::new("exit-dialog")
|
||||
.handle(self.handle.clone())
|
||||
.width(px(420.))
|
||||
.title("Exit Signed?")
|
||||
.content(|_, cx| {
|
||||
v_flex()
|
||||
.child(
|
||||
div().text_base()
|
||||
div()
|
||||
.text_sm()
|
||||
.text_color(cx.theme().colors.muted_foreground)
|
||||
.child(
|
||||
"You will be signed out on this device and will need to sign in again on the next session.",
|
||||
),
|
||||
.child(WARNING),
|
||||
)
|
||||
.into_any_element()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user