Scaffolding for update notification too
This commit is contained in:
parent
b48b74559c
commit
e31a8f0536
2 changed files with 42 additions and 69 deletions
|
@ -84,8 +84,8 @@ impl Settings for AutoUpdateSetting {
|
||||||
pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut AppContext) {
|
pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut AppContext) {
|
||||||
AutoUpdateSetting::register(cx);
|
AutoUpdateSetting::register(cx);
|
||||||
|
|
||||||
cx.observe_new_views(|wokrspace: &mut Workspace, _cx| {
|
cx.observe_new_views(|workspace: &mut Workspace, _cx| {
|
||||||
wokrspace
|
workspace
|
||||||
.register_action(|_, action: &Check, cx| check(action, cx))
|
.register_action(|_, action: &Check, cx| check(action, cx))
|
||||||
.register_action(|_, _action: &CheckThatAutoUpdaterWorks, cx| {
|
.register_action(|_, _action: &CheckThatAutoUpdaterWorks, cx| {
|
||||||
let prompt = cx.prompt(gpui::PromptLevel::Info, "It does!", &["Ok"]);
|
let prompt = cx.prompt(gpui::PromptLevel::Info, "It does!", &["Ok"]);
|
||||||
|
@ -94,6 +94,11 @@ pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut AppCo
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// @nate - code to trigger update notification on launch
|
||||||
|
// workspace.show_notification(0, _cx, |cx| {
|
||||||
|
// cx.build_view(|_| UpdateNotification::new(SemanticVersion::from_str("1.1.1").unwrap()))
|
||||||
|
// });
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
|
@ -131,7 +136,7 @@ pub fn check(_: &Check, cx: &mut AppContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _view_release_notes(_: &ViewReleaseNotes, cx: &mut AppContext) {
|
pub fn view_release_notes(_: &ViewReleaseNotes, cx: &mut AppContext) {
|
||||||
if let Some(auto_updater) = AutoUpdater::get(cx) {
|
if let Some(auto_updater) = AutoUpdater::get(cx) {
|
||||||
let auto_updater = auto_updater.read(cx);
|
let auto_updater = auto_updater.read(cx);
|
||||||
let server_url = &auto_updater.server_url;
|
let server_url = &auto_updater.server_url;
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, DismissEvent, Div, EventEmitter, ParentElement, Render, SemanticVersion, ViewContext,
|
div, DismissEvent, Div, EventEmitter, InteractiveElement, ParentElement, Render,
|
||||||
|
SemanticVersion, StatefulInteractiveElement, Styled, ViewContext,
|
||||||
};
|
};
|
||||||
use menu::Cancel;
|
use util::channel::ReleaseChannel;
|
||||||
|
use workspace::ui::{h_stack, v_stack, Icon, IconElement, Label, StyledExt};
|
||||||
|
|
||||||
pub struct UpdateNotification {
|
pub struct UpdateNotification {
|
||||||
_version: SemanticVersion,
|
version: SemanticVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventEmitter<DismissEvent> for UpdateNotification {}
|
impl EventEmitter<DismissEvent> for UpdateNotification {}
|
||||||
|
@ -12,77 +14,43 @@ impl EventEmitter<DismissEvent> for UpdateNotification {}
|
||||||
impl Render for UpdateNotification {
|
impl Render for UpdateNotification {
|
||||||
type Element = Div;
|
type Element = Div;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
||||||
div().child("Updated zed!")
|
let app_name = cx.global::<ReleaseChannel>().display_name();
|
||||||
// let theme = theme::current(cx).clone();
|
|
||||||
// let theme = &theme.update_notification;
|
|
||||||
|
|
||||||
// let app_name = cx.global::<ReleaseChannel>().display_name();
|
v_stack()
|
||||||
|
.elevation_3(cx)
|
||||||
// MouseEventHandler::new::<ViewReleaseNotes, _>(0, cx, |state, cx| {
|
.p_4()
|
||||||
// Flex::column()
|
.child(
|
||||||
// .with_child(
|
h_stack()
|
||||||
// Flex::row()
|
.justify_between()
|
||||||
// .with_child(
|
.child(Label::new(format!(
|
||||||
// Text::new(
|
"Updated to {app_name} {}",
|
||||||
// format!("Updated to {app_name} {}", self.version),
|
self.version
|
||||||
// theme.message.text.clone(),
|
)))
|
||||||
// )
|
.child(
|
||||||
// .contained()
|
div()
|
||||||
// .with_style(theme.message.container)
|
.id("cancel")
|
||||||
// .aligned()
|
.child(IconElement::new(Icon::Close))
|
||||||
// .top()
|
.cursor_pointer()
|
||||||
// .left()
|
.on_click(cx.listener(|this, _, cx| this.dismiss(cx))),
|
||||||
// .flex(1., true),
|
),
|
||||||
// )
|
)
|
||||||
// .with_child(
|
.child(
|
||||||
// MouseEventHandler::new::<Cancel, _>(0, cx, |state, _| {
|
div()
|
||||||
// let style = theme.dismiss_button.style_for(state);
|
.id("notes")
|
||||||
// Svg::new("icons/x.svg")
|
.child(Label::new("View the release notes"))
|
||||||
// .with_color(style.color)
|
.cursor_pointer()
|
||||||
// .constrained()
|
.on_click(|_, cx| crate::view_release_notes(&Default::default(), cx)),
|
||||||
// .with_width(style.icon_width)
|
)
|
||||||
// .aligned()
|
|
||||||
// .contained()
|
|
||||||
// .with_style(style.container)
|
|
||||||
// .constrained()
|
|
||||||
// .with_width(style.button_width)
|
|
||||||
// .with_height(style.button_width)
|
|
||||||
// })
|
|
||||||
// .with_padding(Padding::uniform(5.))
|
|
||||||
// .on_click(MouseButton::Left, move |_, this, cx| {
|
|
||||||
// this.dismiss(&Default::default(), cx)
|
|
||||||
// })
|
|
||||||
// .aligned()
|
|
||||||
// .constrained()
|
|
||||||
// .with_height(cx.font_cache().line_height(theme.message.text.font_size))
|
|
||||||
// .aligned()
|
|
||||||
// .top()
|
|
||||||
// .flex_float(),
|
|
||||||
// ),
|
|
||||||
// )
|
|
||||||
// .with_child({
|
|
||||||
// let style = theme.action_message.style_for(state);
|
|
||||||
// Text::new("View the release notes", style.text.clone())
|
|
||||||
// .contained()
|
|
||||||
// .with_style(style.container)
|
|
||||||
// })
|
|
||||||
// .contained()
|
|
||||||
// })
|
|
||||||
// .with_cursor_style(CursorStyle::PointingHand)
|
|
||||||
// .on_click(MouseButton::Left, |_, _, cx| {
|
|
||||||
// crate::view_release_notes(&Default::default(), cx)
|
|
||||||
// })
|
|
||||||
// .into_any_named("update notification")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UpdateNotification {
|
impl UpdateNotification {
|
||||||
pub fn new(version: SemanticVersion) -> Self {
|
pub fn new(version: SemanticVersion) -> Self {
|
||||||
Self { _version: version }
|
Self { version }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn _dismiss(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
|
pub fn dismiss(&mut self, cx: &mut ViewContext<Self>) {
|
||||||
cx.emit(DismissEvent::Dismiss);
|
cx.emit(DismissEvent::Dismiss);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue