story: Add unique notification to story. (#1575)
This commit is contained in:
parent
3500e5d5bc
commit
8c2d4de435
1 changed files with 50 additions and 5 deletions
|
|
@ -6,6 +6,7 @@ use gpui::{
|
||||||
use gpui_component::{
|
use gpui_component::{
|
||||||
WindowExt as _,
|
WindowExt as _,
|
||||||
button::{Button, ButtonVariants},
|
button::{Button, ButtonVariants},
|
||||||
|
h_flex,
|
||||||
notification::{Notification, NotificationType},
|
notification::{Notification, NotificationType},
|
||||||
text::TextView,
|
text::TextView,
|
||||||
v_flex,
|
v_flex,
|
||||||
|
|
@ -91,7 +92,7 @@ impl Render for NotificationStory {
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new("show-notify-error")
|
Button::new("show-notify-error")
|
||||||
.outline()
|
.danger()
|
||||||
.label("Error")
|
.label("Error")
|
||||||
.on_click(cx.listener(|_, _, window, cx| {
|
.on_click(cx.listener(|_, _, window, cx| {
|
||||||
window.push_notification(
|
window.push_notification(
|
||||||
|
|
@ -122,17 +123,61 @@ impl Render for NotificationStory {
|
||||||
.warning()
|
.warning()
|
||||||
.label("Warning")
|
.label("Warning")
|
||||||
.on_click(cx.listener(|_, _, window, cx| {
|
.on_click(cx.listener(|_, _, window, cx| {
|
||||||
struct WarningNotification;
|
|
||||||
window.push_notification(
|
window.push_notification(
|
||||||
Notification::warning(
|
(
|
||||||
|
NotificationType::Warning,
|
||||||
"The network is not stable, please check your connection.",
|
"The network is not stable, please check your connection.",
|
||||||
)
|
),
|
||||||
.id1::<WarningNotification>("test"),
|
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.child(
|
||||||
|
section("Unique Notification").child(
|
||||||
|
Button::new("show-notify-unique")
|
||||||
|
.outline()
|
||||||
|
.label("Unique Notification")
|
||||||
|
.on_click(cx.listener(|_, _, window, cx| {
|
||||||
|
window.push_notification(
|
||||||
|
Notification::info("This is a unique notification.")
|
||||||
|
.id::<NotificationStory>()
|
||||||
|
.message("This is a unique notification."),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
section("Unique with Key").child(
|
||||||
|
h_flex()
|
||||||
|
.gap_3()
|
||||||
|
.child(
|
||||||
|
Button::new("show-notify-unique-key0")
|
||||||
|
.outline()
|
||||||
|
.label("A Notification")
|
||||||
|
.on_click(cx.listener(|_, _, window, cx| {
|
||||||
|
window.push_notification(
|
||||||
|
Notification::info("This is A unique notification.")
|
||||||
|
.id1::<NotificationStory>(1),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
Button::new("show-notify-unique-key1")
|
||||||
|
.outline()
|
||||||
|
.label("B Notification")
|
||||||
|
.on_click(cx.listener(|_, _, window, cx| {
|
||||||
|
window.push_notification(
|
||||||
|
Notification::info("This is B unique notification.")
|
||||||
|
.id1::<NotificationStory>(2),
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
})),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
.child(
|
.child(
|
||||||
section("With title and action").child(
|
section("With title and action").child(
|
||||||
Button::new("show-notify-with-title")
|
Button::new("show-notify-with-title")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue