Add disclosable components into channels

Rename components to more closely match their purpose
This commit is contained in:
Mikayla 2023-08-19 05:18:53 -07:00
parent 2d37128693
commit bd3ab82dac
No known key found for this signature in database
10 changed files with 359 additions and 194 deletions

View file

@ -2,7 +2,7 @@ use button_component::Button;
use gpui::{
color::Color,
elements::{Component, ContainerStyle, Flex, Label, ParentElement},
elements::{ContainerStyle, Flex, Label, ParentElement, StatefulComponent},
fonts::{self, TextStyle},
platform::WindowOptions,
AnyElement, App, Element, Entity, View, ViewContext,
@ -72,7 +72,7 @@ impl View for TestView {
TextStyle::for_color(Color::blue()),
)
.with_style(ButtonStyle::fill(Color::yellow()))
.c_element(),
.stateful_element(),
)
.with_child(
ToggleableButton::new(self.is_doubling, move |_, v: &mut Self, cx| {
@ -84,7 +84,7 @@ impl View for TestView {
inactive: ButtonStyle::fill(Color::red()),
active: ButtonStyle::fill(Color::green()),
})
.c_element(),
.stateful_element(),
)
.expanded()
.contained()
@ -114,7 +114,7 @@ mod theme {
// Component creation:
mod toggleable_button {
use gpui::{
elements::{Component, ContainerStyle, LabelStyle},
elements::{ContainerStyle, LabelStyle, StatefulComponent},
scene::MouseClick,
EventContext, View,
};
@ -156,7 +156,7 @@ mod toggleable_button {
}
}
impl<V: View> Component<V> for ToggleableButton<V> {
impl<V: View> StatefulComponent<V> for ToggleableButton<V> {
fn render(self, v: &mut V, cx: &mut gpui::ViewContext<V>) -> gpui::AnyElement<V> {
let button = if let Some(style) = self.style {
self.button.with_style(*style.style_for(self.active))
@ -171,7 +171,7 @@ mod toggleable_button {
mod button_component {
use gpui::{
elements::{Component, ContainerStyle, Label, LabelStyle, MouseEventHandler},
elements::{ContainerStyle, Label, LabelStyle, MouseEventHandler, StatefulComponent},
platform::MouseButton,
scene::MouseClick,
AnyElement, Element, EventContext, TypeTag, View, ViewContext,
@ -212,7 +212,7 @@ mod button_component {
}
}
impl<V: View> Component<V> for Button<V> {
impl<V: View> StatefulComponent<V> for Button<V> {
fn render(self, _: &mut V, cx: &mut ViewContext<V>) -> AnyElement<V> {
let click_handler = self.click_handler;