This PR renames the `h_stack` and `v_stack` to `h_flex` and `v_flex`, respectively. We were previously using `h_stack` and `v_stack` to match SwiftUI, but `h_flex` and `v_flex` fit better with the web/flexbox terminology that the rest of GPUI uses. Additionally, we were already calling the utility functions used to implement `h_stack` and `v_stack` by the new names. Release Notes: - N/A
53 lines
1.3 KiB
Rust
53 lines
1.3 KiB
Rust
use gpui::{img, prelude::*, AnyElement, SharedUrl};
|
|
use smallvec::SmallVec;
|
|
use ui::prelude::*;
|
|
|
|
#[derive(IntoElement)]
|
|
pub struct CollabNotification {
|
|
avatar_uri: SharedUrl,
|
|
accept_button: Button,
|
|
dismiss_button: Button,
|
|
children: SmallVec<[AnyElement; 2]>,
|
|
}
|
|
|
|
impl CollabNotification {
|
|
pub fn new(
|
|
avatar_uri: impl Into<SharedUrl>,
|
|
accept_button: Button,
|
|
dismiss_button: Button,
|
|
) -> Self {
|
|
Self {
|
|
avatar_uri: avatar_uri.into(),
|
|
accept_button,
|
|
dismiss_button,
|
|
children: SmallVec::new(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ParentElement for CollabNotification {
|
|
fn children_mut(&mut self) -> &mut SmallVec<[AnyElement; 2]> {
|
|
&mut self.children
|
|
}
|
|
}
|
|
|
|
impl RenderOnce for CollabNotification {
|
|
fn render(self, cx: &mut WindowContext) -> impl IntoElement {
|
|
h_flex()
|
|
.text_ui()
|
|
.justify_between()
|
|
.size_full()
|
|
.overflow_hidden()
|
|
.elevation_3(cx)
|
|
.p_2()
|
|
.gap_2()
|
|
.child(img(self.avatar_uri).w_12().h_12().rounded_full())
|
|
.child(v_flex().overflow_hidden().children(self.children))
|
|
.child(
|
|
v_flex()
|
|
.child(self.accept_button)
|
|
.child(self.dismiss_button),
|
|
)
|
|
}
|
|
}
|