some more bs
This commit is contained in:
@@ -1,16 +1,27 @@
|
||||
use gpui::{ParentElement, Styled, div, AppContext};
|
||||
use gpui::prelude::FluentBuilder;
|
||||
use gpui::{ParentElement, Styled, div};
|
||||
|
||||
use crate::{api, app, component::{
|
||||
font_icon::{FontIcon, font_icon},
|
||||
text::text,
|
||||
}, query};
|
||||
use crate::app::query_store;
|
||||
use crate::query::use_query;
|
||||
use crate::component::button::button;
|
||||
use crate::query::{QueryStatus, read_query, use_query};
|
||||
use crate::{
|
||||
api, app,
|
||||
component::{
|
||||
font_icon::{FontIcon, font_icon},
|
||||
text::text,
|
||||
},
|
||||
};
|
||||
|
||||
pub struct TitleBar {}
|
||||
|
||||
pub struct RepoSelector {}
|
||||
|
||||
impl TitleBar {
|
||||
pub fn new(cx: &mut gpui::Context<Self>) -> Self {
|
||||
use_query(api::user::Fetch, cx);
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
impl gpui::Render for TitleBar {
|
||||
fn render(
|
||||
&mut self,
|
||||
@@ -18,35 +29,44 @@ impl gpui::Render for TitleBar {
|
||||
cx: &mut gpui::Context<Self>,
|
||||
) -> impl gpui::IntoElement {
|
||||
let g = cx.global::<app::Global>();
|
||||
let user = read_query(api::user::Fetch, cx);
|
||||
|
||||
let user_avatar = match user {
|
||||
QueryStatus::Err(api::Error::Unauthenticated) => div()
|
||||
.absolute()
|
||||
.right_2p5()
|
||||
.child(button("login-btn", cx).label("Login")),
|
||||
|
||||
_ => div(),
|
||||
};
|
||||
|
||||
div()
|
||||
.w_full()
|
||||
.h_8()
|
||||
.flex()
|
||||
.px(g.safe_area.size.width)
|
||||
.py_2()
|
||||
.flex_row()
|
||||
.justify_center()
|
||||
.items_center()
|
||||
.border_b_1()
|
||||
.border_color(g.current_theme.colors.border)
|
||||
.bg(g.current_theme.colors.surface)
|
||||
.w_full()
|
||||
.h_10()
|
||||
.flex()
|
||||
.px(g.safe_area.size.width)
|
||||
.py_2()
|
||||
.bg(g.current_theme.colors.background)
|
||||
.text_color(g.current_theme.colors.text)
|
||||
.relative()
|
||||
.child(repo_selector(cx))
|
||||
.child(user_avatar)
|
||||
}
|
||||
}
|
||||
|
||||
impl RepoSelector {
|
||||
pub fn new(cx: &mut gpui::Context<Self>) -> Self {
|
||||
use_query(api::repo::List, cx);
|
||||
use_query(api::user::Fetch, cx);
|
||||
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
fn repo_selector<T>(cx: &gpui::Context<T>) -> gpui::Div {
|
||||
let store = app::query_store(cx);
|
||||
let repo = store.read_query(api::repo::List, cx);
|
||||
|
||||
fn repo_selector<T: 'static>(cx: &gpui::Context<T>) -> gpui::Div {
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
|
||||
Reference in New Issue
Block a user