Simplify toggle, do some reorganization

This commit is contained in:
Nate Butler 2023-11-04 11:24:31 -04:00
parent ac9efaebb7
commit b125cc279f
12 changed files with 224 additions and 499 deletions

View file

@ -1,7 +1,6 @@
use crate::prelude::*;
use crate::{prelude::*, Toggle};
use crate::{
static_collab_panel_channels, static_collab_panel_current_call, v_stack, Icon, List,
ListHeader, ToggleState,
static_collab_panel_channels, static_collab_panel_current_call, v_stack, Icon, List, ListHeader,
};
#[derive(Component)]
@ -34,17 +33,17 @@ impl CollabPanel {
.header(
ListHeader::new("CRDB")
.left_icon(Icon::Hash.into())
.toggle(ToggleState::Toggled),
.toggle(Toggle::Toggled(true)),
)
.toggle(ToggleState::Toggled),
.toggle(Toggle::Toggled(true)),
),
)
.child(
v_stack().id("channels").py_1().child(
List::new(static_collab_panel_channels())
.header(ListHeader::new("CHANNELS").toggle(ToggleState::Toggled))
.header(ListHeader::new("CHANNELS").toggle(Toggle::Toggled(true)))
.empty_message("No channels yet. Add a channel to get started.")
.toggle(ToggleState::Toggled),
.toggle(Toggle::Toggled(true)),
),
)
.child(
@ -52,9 +51,9 @@ impl CollabPanel {
List::new(static_collab_panel_current_call())
.header(
ListHeader::new("CONTACTS ONLINE")
.toggle(ToggleState::Toggled),
.toggle(Toggle::Toggled(true)),
)
.toggle(ToggleState::Toggled),
.toggle(Toggle::Toggled(true)),
),
)
.child(
@ -62,9 +61,9 @@ impl CollabPanel {
List::new(static_collab_panel_current_call())
.header(
ListHeader::new("CONTACTS OFFLINE")
.toggle(ToggleState::NotToggled),
.toggle(Toggle::Toggled(false)),
)
.toggle(ToggleState::NotToggled),
.toggle(Toggle::Toggled(false)),
),
),
)

View file

@ -1,8 +1,8 @@
use crate::utils::naive_format_distance_from_now;
use crate::{
h_stack, prelude::*, static_new_notification_items_2, v_stack, Avatar, Button, Icon,
IconButton, IconElement, Label, LabelColor, LineHeightStyle, ListHeaderMeta, ListSeparator,
UnreadIndicator,
h_stack, prelude::*, static_new_notification_items_2, v_stack, Avatar, ButtonOrIconButton,
Icon, IconElement, Label, LabelColor, LineHeightStyle, ListHeaderMeta, ListSeparator,
PublicPlayer, UnreadIndicator,
};
use crate::{ClickHandler, ListHeader};
@ -57,23 +57,6 @@ impl NotificationsPanel {
}
}
pub enum ButtonOrIconButton<V: 'static> {
Button(Button<V>),
IconButton(IconButton<V>),
}
impl<V: 'static> From<Button<V>> for ButtonOrIconButton<V> {
fn from(value: Button<V>) -> Self {
Self::Button(value)
}
}
impl<V: 'static> From<IconButton<V>> for ButtonOrIconButton<V> {
fn from(value: IconButton<V>) -> Self {
Self::IconButton(value)
}
}
pub struct NotificationAction<V: 'static> {
button: ButtonOrIconButton<V>,
tooltip: SharedString,
@ -102,7 +85,7 @@ impl<V: 'static> NotificationAction<V> {
}
pub enum ActorOrIcon {
Actor(PublicActor),
Actor(PublicPlayer),
Icon(Icon),
}
@ -171,7 +154,7 @@ impl<V> Notification<V> {
id: impl Into<ElementId>,
message: impl Into<SharedString>,
date_received: NaiveDateTime,
actor: PublicActor,
actor: PublicPlayer,
click_action: ClickHandler<V>,
) -> Self {
Self::new(
@ -210,7 +193,7 @@ impl<V> Notification<V> {
id: impl Into<ElementId>,
message: impl Into<SharedString>,
date_received: NaiveDateTime,
actor: PublicActor,
actor: PublicPlayer,
actions: [NotificationAction<V>; 2],
) -> Self {
Self::new(

View file

@ -18,8 +18,7 @@ impl ProjectPanel {
.id(self.id.clone())
.flex()
.flex_col()
.w_full()
.h_full()
.size_full()
.bg(cx.theme().colors().surface)
.child(
div()
@ -30,15 +29,13 @@ impl ProjectPanel {
.overflow_y_scroll()
.child(
List::new(static_project_panel_single_items())
.header(ListHeader::new("FILES").toggle(ToggleState::Toggled))
.empty_message("No files in directory")
.toggle(ToggleState::Toggled),
.header(ListHeader::new("FILES"))
.empty_message("No files in directory"),
)
.child(
List::new(static_project_panel_project_items())
.header(ListHeader::new("PROJECT").toggle(ToggleState::Toggled))
.empty_message("No folders in directory")
.toggle(ToggleState::Toggled),
.header(ListHeader::new("PROJECT"))
.empty_message("No folders in directory"),
),
)
.child(