Wire up livestream debug toggle

This commit is contained in:
Marshall Bowers 2023-10-19 14:06:31 -04:00
parent a869de3b1f
commit e657e4d1d1
2 changed files with 20 additions and 26 deletions

View file

@ -6,7 +6,7 @@ use gpui3::{view, Context, View};
use crate::prelude::*; use crate::prelude::*;
use crate::settings::user_settings; use crate::settings::user_settings;
use crate::{ use crate::{
random_players_with_call_status, theme, Avatar, Button, Icon, IconButton, IconColor, MicStatus, theme, Avatar, Button, Icon, IconButton, IconColor, MicStatus, PlayerStack,
PlayerWithCallStatus, ScreenShareStatus, ToolDivider, TrafficLights, PlayerWithCallStatus, ScreenShareStatus, ToolDivider, TrafficLights,
}; };
@ -80,14 +80,9 @@ impl TitleBar {
cx.notify(); cx.notify();
} }
pub fn view(cx: &mut WindowContext) -> View<Self> { pub fn view(cx: &mut WindowContext, livestream: Option<Livestream>) -> View<Self> {
view( view(
cx.entity(|cx| { cx.entity(|cx| Self::new(cx).set_livestream(livestream)),
Self::new(cx).set_livestream(Some(Livestream {
players: random_players_with_call_status(7),
channel: Some("gpui2-ui".to_string()),
}))
}),
Self::render, Self::render,
) )
} }
@ -133,7 +128,7 @@ impl TitleBar {
.child(Button::new("zed")) .child(Button::new("zed"))
.child(Button::new("nate/gpui2-ui-components")), .child(Button::new("nate/gpui2-ui-components")),
) )
// .children(player_list.map(|p| PlayerStack::new(p))) .children(player_list.map(|p| PlayerStack::new(p)))
.child(IconButton::new(Icon::Plus)), .child(IconButton::new(Icon::Plus)),
) )
.child( .child(
@ -204,7 +199,7 @@ mod stories {
pub fn view(cx: &mut WindowContext) -> View<Self> { pub fn view(cx: &mut WindowContext) -> View<Self> {
view( view(
cx.entity(|cx| Self { cx.entity(|cx| Self {
title_bar: TitleBar::view(cx), title_bar: TitleBar::view(cx, None),
}), }),
Self::render, Self::render,
) )

View file

@ -3,12 +3,12 @@ use std::sync::Arc;
use chrono::DateTime; use chrono::DateTime;
use gpui3::{px, relative, rems, view, Context, Size, View}; use gpui3::{px, relative, rems, view, Context, Size, View};
use crate::settings::FakeSettings; use crate::prelude::*;
use crate::{prelude::*, user_settings_mut, Button, SettingValue};
use crate::{ use crate::{
theme, v_stack, AssistantPanel, ChatMessage, ChatPanel, CollabPanel, EditorPane, Label, static_livestream, theme, user_settings_mut, v_stack, AssistantPanel, Button, ChatMessage,
LanguageSelector, Pane, PaneGroup, Panel, PanelAllowedSides, PanelSide, ProjectPanel, ChatPanel, CollabPanel, EditorPane, FakeSettings, Label, LanguageSelector, Livestream, Pane,
SplitDirection, StatusBar, Terminal, TitleBar, Toast, ToastOrigin, PaneGroup, Panel, PanelAllowedSides, PanelSide, ProjectPanel, SettingValue, SplitDirection,
StatusBar, Terminal, TitleBar, Toast, ToastOrigin,
}; };
#[derive(Clone)] #[derive(Clone)]
@ -50,7 +50,7 @@ pub struct Workspace {
impl Workspace { impl Workspace {
pub fn new(cx: &mut ViewContext<Self>) -> Self { pub fn new(cx: &mut ViewContext<Self>) -> Self {
Self { Self {
title_bar: TitleBar::view(cx), title_bar: TitleBar::view(cx, None),
editor_1: EditorPane::view(cx), editor_1: EditorPane::view(cx),
show_project_panel: true, show_project_panel: true,
show_collab_panel: false, show_collab_panel: false,
@ -159,20 +159,19 @@ impl Workspace {
} }
pub fn debug_toggle_livestream(&mut self, cx: &mut ViewContext<Self>) { pub fn debug_toggle_livestream(&mut self, cx: &mut ViewContext<Self>) {
if self.debug.in_livestream { self.debug.in_livestream = !self.debug.in_livestream;
self.debug.in_livestream = false;
} else { self.title_bar = TitleBar::view(
self.debug.in_livestream = true; cx,
} Some(static_livestream()).filter(|_| self.debug.in_livestream),
);
cx.notify(); cx.notify();
} }
pub fn debug_toggle_toast(&mut self, cx: &mut ViewContext<Self>) { pub fn debug_toggle_toast(&mut self, cx: &mut ViewContext<Self>) {
if self.debug.show_toast { self.debug.show_toast = !self.debug.show_toast;
self.debug.show_toast = false;
} else {
self.debug.show_toast = true;
}
cx.notify(); cx.notify();
} }