Implement all but the UI
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
use super::base_keymap_setting::BaseKeymap;
|
||||
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
||||
use gpui::{
|
||||
actions,
|
||||
elements::{Element as _, Label},
|
||||
AppContext, Task, ViewContext,
|
||||
actions, AppContext, DismissEvent, EventEmitter, FocusableView, IntoElement, Render, Task,
|
||||
View, ViewContext, VisualContext, WeakView,
|
||||
};
|
||||
use picker::{Picker, PickerDelegate, PickerEvent};
|
||||
use picker::{simple_picker_match, Picker, PickerDelegate};
|
||||
use project::Fs;
|
||||
use settings::update_settings_file;
|
||||
use settings::{update_settings_file, Settings};
|
||||
use std::sync::Arc;
|
||||
use util::ResultExt;
|
||||
use workspace::Workspace;
|
||||
use workspace::{ui::HighlightedLabel, Workspace};
|
||||
|
||||
actions!(welcome, [ToggleBaseKeymapSelector]);
|
||||
actions!(ToggleBaseKeymapSelector);
|
||||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(toggle);
|
||||
BaseKeymapSelector::init(cx);
|
||||
cx.observe_new_views(|workspace: &mut Workspace, _cx| {
|
||||
workspace.register_action(toggle);
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
||||
pub fn toggle(
|
||||
@@ -24,28 +25,70 @@ pub fn toggle(
|
||||
_: &ToggleBaseKeymapSelector,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) {
|
||||
workspace.toggle_modal(cx, |workspace, cx| {
|
||||
let fs = workspace.app_state().fs.clone();
|
||||
cx.add_view(|cx| BaseKeymapSelector::new(BaseKeymapSelectorDelegate::new(fs, cx), cx))
|
||||
let fs = workspace.app_state().fs.clone();
|
||||
workspace.toggle_modal(cx, |cx| {
|
||||
BaseKeymapSelector::new(
|
||||
BaseKeymapSelectorDelegate::new(cx.view().downgrade(), fs, cx),
|
||||
cx,
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
pub type BaseKeymapSelector = Picker<BaseKeymapSelectorDelegate>;
|
||||
pub struct BaseKeymapSelector {
|
||||
focus_handle: gpui::FocusHandle,
|
||||
picker: View<Picker<BaseKeymapSelectorDelegate>>,
|
||||
}
|
||||
|
||||
impl FocusableView for BaseKeymapSelector {
|
||||
fn focus_handle(&self, _cx: &AppContext) -> gpui::FocusHandle {
|
||||
self.focus_handle.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl EventEmitter<DismissEvent> for BaseKeymapSelector {}
|
||||
|
||||
impl BaseKeymapSelector {
|
||||
pub fn new(
|
||||
delegate: BaseKeymapSelectorDelegate,
|
||||
cx: &mut ViewContext<BaseKeymapSelector>,
|
||||
) -> Self {
|
||||
let picker = cx.build_view(|cx| Picker::new(delegate, cx));
|
||||
let focus_handle = cx.focus_handle();
|
||||
Self {
|
||||
focus_handle,
|
||||
picker,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for BaseKeymapSelector {
|
||||
type Element = View<Picker<BaseKeymapSelectorDelegate>>;
|
||||
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
self.picker.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BaseKeymapSelectorDelegate {
|
||||
view: WeakView<BaseKeymapSelector>,
|
||||
matches: Vec<StringMatch>,
|
||||
selected_index: usize,
|
||||
fs: Arc<dyn Fs>,
|
||||
}
|
||||
|
||||
impl BaseKeymapSelectorDelegate {
|
||||
fn new(fs: Arc<dyn Fs>, cx: &mut ViewContext<BaseKeymapSelector>) -> Self {
|
||||
let base = settings::get::<BaseKeymap>(cx);
|
||||
fn new(
|
||||
weak_view: WeakView<BaseKeymapSelector>,
|
||||
fs: Arc<dyn Fs>,
|
||||
cx: &mut ViewContext<BaseKeymapSelector>,
|
||||
) -> Self {
|
||||
let base = BaseKeymap::get(None, cx);
|
||||
let selected_index = BaseKeymap::OPTIONS
|
||||
.iter()
|
||||
.position(|(_, value)| value == base)
|
||||
.unwrap_or(0);
|
||||
Self {
|
||||
view: weak_view,
|
||||
matches: Vec::new(),
|
||||
selected_index,
|
||||
fs,
|
||||
@@ -66,16 +109,20 @@ impl PickerDelegate for BaseKeymapSelectorDelegate {
|
||||
self.selected_index
|
||||
}
|
||||
|
||||
fn set_selected_index(&mut self, ix: usize, _: &mut ViewContext<BaseKeymapSelector>) {
|
||||
fn set_selected_index(
|
||||
&mut self,
|
||||
ix: usize,
|
||||
_: &mut ViewContext<Picker<BaseKeymapSelectorDelegate>>,
|
||||
) {
|
||||
self.selected_index = ix;
|
||||
}
|
||||
|
||||
fn update_matches(
|
||||
&mut self,
|
||||
query: String,
|
||||
cx: &mut ViewContext<BaseKeymapSelector>,
|
||||
cx: &mut ViewContext<Picker<BaseKeymapSelectorDelegate>>,
|
||||
) -> Task<()> {
|
||||
let background = cx.background().clone();
|
||||
let background = cx.background_executor().clone();
|
||||
let candidates = BaseKeymap::names()
|
||||
.enumerate()
|
||||
.map(|(id, name)| StringMatchCandidate {
|
||||
@@ -110,43 +157,44 @@ impl PickerDelegate for BaseKeymapSelectorDelegate {
|
||||
};
|
||||
|
||||
this.update(&mut cx, |this, _| {
|
||||
let delegate = this.delegate_mut();
|
||||
delegate.matches = matches;
|
||||
delegate.selected_index = delegate
|
||||
this.delegate.matches = matches;
|
||||
this.delegate.selected_index = this
|
||||
.delegate
|
||||
.selected_index
|
||||
.min(delegate.matches.len().saturating_sub(1));
|
||||
.min(this.delegate.matches.len().saturating_sub(1));
|
||||
})
|
||||
.log_err();
|
||||
})
|
||||
}
|
||||
|
||||
fn confirm(&mut self, _: bool, cx: &mut ViewContext<BaseKeymapSelector>) {
|
||||
fn confirm(&mut self, _: bool, cx: &mut ViewContext<Picker<BaseKeymapSelectorDelegate>>) {
|
||||
if let Some(selection) = self.matches.get(self.selected_index) {
|
||||
let base_keymap = BaseKeymap::from_names(&selection.string);
|
||||
update_settings_file::<BaseKeymap>(self.fs.clone(), cx, move |setting| {
|
||||
*setting = Some(base_keymap)
|
||||
});
|
||||
}
|
||||
cx.emit(PickerEvent::Dismiss);
|
||||
|
||||
self.view
|
||||
.update(cx, |_, cx| {
|
||||
cx.emit(DismissEvent::Dismiss);
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
||||
fn dismissed(&mut self, _cx: &mut ViewContext<BaseKeymapSelector>) {}
|
||||
fn dismissed(&mut self, _cx: &mut ViewContext<Picker<BaseKeymapSelectorDelegate>>) {}
|
||||
|
||||
fn render_match(
|
||||
&self,
|
||||
ix: usize,
|
||||
mouse_state: &mut gpui::MouseState,
|
||||
selected: bool,
|
||||
cx: &gpui::AppContext,
|
||||
) -> gpui::AnyElement<Picker<Self>> {
|
||||
let theme = &theme::current(cx);
|
||||
cx: &mut gpui::ViewContext<Picker<Self>>,
|
||||
) -> gpui::AnyElement {
|
||||
let keymap_match = &self.matches[ix];
|
||||
let style = theme.picker.item.in_state(selected).style_for(mouse_state);
|
||||
|
||||
Label::new(keymap_match.string.clone(), style.label.clone())
|
||||
.with_highlights(keymap_match.positions.clone())
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.into_any()
|
||||
simple_picker_match(selected, cx, |_cx| {
|
||||
HighlightedLabel::new(keymap_match.string.clone(), keymap_match.positions.clone())
|
||||
.into_any_element()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::Setting;
|
||||
use settings::Settings;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq, Default)]
|
||||
pub enum BaseKeymap {
|
||||
@@ -44,7 +44,7 @@ impl BaseKeymap {
|
||||
}
|
||||
}
|
||||
|
||||
impl Setting for BaseKeymap {
|
||||
impl Settings for BaseKeymap {
|
||||
const KEY: Option<&'static str> = Some("base_keymap");
|
||||
|
||||
type FileContent = Option<Self>;
|
||||
@@ -52,7 +52,7 @@ impl Setting for BaseKeymap {
|
||||
fn load(
|
||||
default_value: &Self::FileContent,
|
||||
user_values: &[&Self::FileContent],
|
||||
_: &gpui::AppContext,
|
||||
_: &mut gpui::AppContext,
|
||||
) -> anyhow::Result<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
||||
+216
-223
@@ -1,19 +1,18 @@
|
||||
mod base_keymap_picker;
|
||||
mod base_keymap_setting;
|
||||
|
||||
use crate::base_keymap_picker::ToggleBaseKeymapSelector;
|
||||
use client::TelemetrySettings;
|
||||
use db::kvp::KEY_VALUE_STORE;
|
||||
use gpui::{
|
||||
elements::{Flex, Label, ParentElement},
|
||||
AnyElement, AppContext, Element, Entity, Subscription, View, ViewContext, WeakViewHandle,
|
||||
div, red, AnyElement, AppContext, Div, Element, EventEmitter, FocusHandle, Focusable,
|
||||
FocusableView, InteractiveElement, ParentElement, Render, Styled, Subscription, View,
|
||||
ViewContext, VisualContext, WeakView, WindowContext,
|
||||
};
|
||||
use settings::{update_settings_file, SettingsStore};
|
||||
use std::{borrow::Cow, sync::Arc};
|
||||
use vim::VimModeSetting;
|
||||
use settings::{Settings, SettingsStore};
|
||||
use std::sync::Arc;
|
||||
use workspace::{
|
||||
dock::DockPosition, item::Item, open_new, AppState, PaneBackdrop, Welcome, Workspace,
|
||||
WorkspaceId,
|
||||
dock::DockPosition,
|
||||
item::{Item, ItemEvent},
|
||||
open_new, AppState, Welcome, Workspace, WorkspaceId,
|
||||
};
|
||||
|
||||
pub use base_keymap_setting::BaseKeymap;
|
||||
@@ -21,12 +20,15 @@ pub use base_keymap_setting::BaseKeymap;
|
||||
pub const FIRST_OPEN: &str = "first_open";
|
||||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
settings::register::<BaseKeymap>(cx);
|
||||
BaseKeymap::register(cx);
|
||||
|
||||
cx.add_action(|workspace: &mut Workspace, _: &Welcome, cx| {
|
||||
let welcome_page = cx.add_view(|cx| WelcomePage::new(workspace, cx));
|
||||
workspace.add_item(Box::new(welcome_page), cx)
|
||||
});
|
||||
cx.observe_new_views(|workspace: &mut Workspace, _cx| {
|
||||
workspace.register_action(|workspace, _: &Welcome, cx| {
|
||||
let welcome_page = cx.build_view(|cx| WelcomePage::new(workspace, cx));
|
||||
workspace.add_item(Box::new(welcome_page), cx)
|
||||
});
|
||||
})
|
||||
.detach();
|
||||
|
||||
base_keymap_picker::init(cx);
|
||||
}
|
||||
@@ -34,9 +36,9 @@ pub fn init(cx: &mut AppContext) {
|
||||
pub fn show_welcome_experience(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
||||
open_new(&app_state, cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Left, cx);
|
||||
let welcome_page = cx.add_view(|cx| WelcomePage::new(workspace, cx));
|
||||
let welcome_page = cx.build_view(|cx| WelcomePage::new(workspace, cx));
|
||||
workspace.add_item_to_center(Box::new(welcome_page.clone()), cx);
|
||||
cx.focus(&welcome_page);
|
||||
cx.focus_view(&welcome_page);
|
||||
cx.notify();
|
||||
})
|
||||
.detach();
|
||||
@@ -47,227 +49,217 @@ pub fn show_welcome_experience(app_state: &Arc<AppState>, cx: &mut AppContext) {
|
||||
}
|
||||
|
||||
pub struct WelcomePage {
|
||||
workspace: WeakViewHandle<Workspace>,
|
||||
workspace: WeakView<Workspace>,
|
||||
focus_handle: FocusHandle,
|
||||
_settings_subscription: Subscription,
|
||||
}
|
||||
|
||||
impl Entity for WelcomePage {
|
||||
type Event = ();
|
||||
}
|
||||
impl Render for WelcomePage {
|
||||
type Element = Focusable<Div>;
|
||||
|
||||
impl View for WelcomePage {
|
||||
fn ui_name() -> &'static str {
|
||||
"WelcomePage"
|
||||
}
|
||||
fn render(&mut self, _cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
||||
// let self_handle = cx.handle();
|
||||
// let theme = cx.theme();
|
||||
// let width = theme.welcome.page_width;
|
||||
|
||||
fn render(&mut self, cx: &mut gpui::ViewContext<Self>) -> AnyElement<Self> {
|
||||
let self_handle = cx.handle();
|
||||
let theme = theme::current(cx);
|
||||
let width = theme.welcome.page_width;
|
||||
// let telemetry_settings = TelemetrySettings::get(None, cx);
|
||||
// let vim_mode_setting = VimModeSettings::get(cx);
|
||||
|
||||
let telemetry_settings = *settings::get::<TelemetrySettings>(cx);
|
||||
let vim_mode_setting = settings::get::<VimModeSetting>(cx).0;
|
||||
|
||||
enum Metrics {}
|
||||
enum Diagnostics {}
|
||||
|
||||
PaneBackdrop::new(
|
||||
self_handle.id(),
|
||||
Flex::column()
|
||||
.with_child(
|
||||
Flex::column()
|
||||
.with_child(
|
||||
theme::ui::svg(&theme.welcome.logo)
|
||||
.aligned()
|
||||
.contained()
|
||||
.aligned(),
|
||||
)
|
||||
.with_child(
|
||||
Label::new(
|
||||
"Code at the speed of thought",
|
||||
theme.welcome.logo_subheading.text.clone(),
|
||||
)
|
||||
.aligned()
|
||||
.contained()
|
||||
.with_style(theme.welcome.logo_subheading.container),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.welcome.heading_group)
|
||||
.constrained()
|
||||
.with_width(width),
|
||||
)
|
||||
.with_child(
|
||||
Flex::column()
|
||||
.with_child(theme::ui::cta_button::<theme_selector::Toggle, _, _, _>(
|
||||
"Choose a theme",
|
||||
width,
|
||||
&theme.welcome.button,
|
||||
cx,
|
||||
|_, this, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
theme_selector::toggle(workspace, &Default::default(), cx)
|
||||
})
|
||||
}
|
||||
},
|
||||
))
|
||||
.with_child(theme::ui::cta_button::<ToggleBaseKeymapSelector, _, _, _>(
|
||||
"Choose a keymap",
|
||||
width,
|
||||
&theme.welcome.button,
|
||||
cx,
|
||||
|_, this, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
base_keymap_picker::toggle(
|
||||
workspace,
|
||||
&Default::default(),
|
||||
cx,
|
||||
)
|
||||
})
|
||||
}
|
||||
},
|
||||
))
|
||||
.with_child(theme::ui::cta_button::<install_cli::Install, _, _, _>(
|
||||
"Install the CLI",
|
||||
width,
|
||||
&theme.welcome.button,
|
||||
cx,
|
||||
|_, _, cx| {
|
||||
cx.app_context()
|
||||
.spawn(|cx| async move { install_cli::install_cli(&cx).await })
|
||||
.detach_and_log_err(cx);
|
||||
},
|
||||
))
|
||||
.contained()
|
||||
.with_style(theme.welcome.button_group)
|
||||
.constrained()
|
||||
.with_width(width),
|
||||
)
|
||||
.with_child(
|
||||
Flex::column()
|
||||
.with_child(
|
||||
theme::ui::checkbox::<Diagnostics, Self, _>(
|
||||
"Enable vim mode",
|
||||
&theme.welcome.checkbox,
|
||||
vim_mode_setting,
|
||||
0,
|
||||
cx,
|
||||
|this, checked, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
let fs = workspace.read(cx).app_state().fs.clone();
|
||||
update_settings_file::<VimModeSetting>(
|
||||
fs,
|
||||
cx,
|
||||
move |setting| *setting = Some(checked),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.welcome.checkbox_container),
|
||||
)
|
||||
.with_child(
|
||||
theme::ui::checkbox_with_label::<Metrics, _, Self, _>(
|
||||
Flex::column()
|
||||
.with_child(
|
||||
Label::new(
|
||||
"Send anonymous usage data",
|
||||
theme.welcome.checkbox.label.text.clone(),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.welcome.checkbox.label.container),
|
||||
)
|
||||
.with_child(
|
||||
Label::new(
|
||||
"Help > View Telemetry",
|
||||
theme.welcome.usage_note.text.clone(),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.welcome.usage_note.container),
|
||||
),
|
||||
&theme.welcome.checkbox,
|
||||
telemetry_settings.metrics,
|
||||
0,
|
||||
cx,
|
||||
|this, checked, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
let fs = workspace.read(cx).app_state().fs.clone();
|
||||
update_settings_file::<TelemetrySettings>(
|
||||
fs,
|
||||
cx,
|
||||
move |setting| setting.metrics = Some(checked),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.welcome.checkbox_container),
|
||||
)
|
||||
.with_child(
|
||||
theme::ui::checkbox::<Diagnostics, Self, _>(
|
||||
"Send crash reports",
|
||||
&theme.welcome.checkbox,
|
||||
telemetry_settings.diagnostics,
|
||||
1,
|
||||
cx,
|
||||
|this, checked, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
let fs = workspace.read(cx).app_state().fs.clone();
|
||||
update_settings_file::<TelemetrySettings>(
|
||||
fs,
|
||||
cx,
|
||||
move |setting| setting.diagnostics = Some(checked),
|
||||
)
|
||||
}
|
||||
},
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.welcome.checkbox_container),
|
||||
)
|
||||
.contained()
|
||||
.with_style(theme.welcome.checkbox_group)
|
||||
.constrained()
|
||||
.with_width(width),
|
||||
)
|
||||
.constrained()
|
||||
.with_max_width(width)
|
||||
.contained()
|
||||
.with_uniform_padding(10.)
|
||||
.aligned()
|
||||
.into_any(),
|
||||
)
|
||||
.into_any_named("welcome page")
|
||||
div()
|
||||
.track_focus(&self.focus_handle)
|
||||
.child(div().size_full().bg(red()).child("Welcome!"))
|
||||
//todo!()
|
||||
// PaneBackdrop::new(
|
||||
// self_handle.id(),
|
||||
// Flex::column()
|
||||
// .with_child(
|
||||
// Flex::column()
|
||||
// .with_child(
|
||||
// theme::ui::svg(&theme.welcome.logo)
|
||||
// .aligned()
|
||||
// .contained()
|
||||
// .aligned(),
|
||||
// )
|
||||
// .with_child(
|
||||
// Label::new(
|
||||
// "Code at the speed of thought",
|
||||
// theme.welcome.logo_subheading.text.clone(),
|
||||
// )
|
||||
// .aligned()
|
||||
// .contained()
|
||||
// .with_style(theme.welcome.logo_subheading.container),
|
||||
// )
|
||||
// .contained()
|
||||
// .with_style(theme.welcome.heading_group)
|
||||
// .constrained()
|
||||
// .with_width(width),
|
||||
// )
|
||||
// .with_child(
|
||||
// Flex::column()
|
||||
// .with_child(theme::ui::cta_button::<theme_selector::Toggle, _, _, _>(
|
||||
// "Choose a theme",
|
||||
// width,
|
||||
// &theme.welcome.button,
|
||||
// cx,
|
||||
// |_, this, cx| {
|
||||
// if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// theme_selector::toggle(workspace, &Default::default(), cx)
|
||||
// })
|
||||
// }
|
||||
// },
|
||||
// ))
|
||||
// .with_child(theme::ui::cta_button::<ToggleBaseKeymapSelector, _, _, _>(
|
||||
// "Choose a keymap",
|
||||
// width,
|
||||
// &theme.welcome.button,
|
||||
// cx,
|
||||
// |_, this, cx| {
|
||||
// if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// base_keymap_picker::toggle(
|
||||
// workspace,
|
||||
// &Default::default(),
|
||||
// cx,
|
||||
// )
|
||||
// })
|
||||
// }
|
||||
// },
|
||||
// ))
|
||||
// .with_child(theme::ui::cta_button::<install_cli::Install, _, _, _>(
|
||||
// "Install the CLI",
|
||||
// width,
|
||||
// &theme.welcome.button,
|
||||
// cx,
|
||||
// |_, _, cx| {
|
||||
// cx.app_context()
|
||||
// .spawn(|cx| async move { install_cli::install_cli(&cx).await })
|
||||
// .detach_and_log_err(cx);
|
||||
// },
|
||||
// ))
|
||||
// .contained()
|
||||
// .with_style(theme.welcome.button_group)
|
||||
// .constrained()
|
||||
// .with_width(width),
|
||||
// )
|
||||
// .with_child(
|
||||
// Flex::column()
|
||||
// .with_child(
|
||||
// theme::ui::checkbox::<Diagnostics, Self, _>(
|
||||
// "Enable vim mode",
|
||||
// &theme.welcome.checkbox,
|
||||
// vim_mode_setting,
|
||||
// 0,
|
||||
// cx,
|
||||
// |this, checked, cx| {
|
||||
// if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
// let fs = workspace.read(cx).app_state().fs.clone();
|
||||
// update_settings_file::<VimModeSetting>(
|
||||
// fs,
|
||||
// cx,
|
||||
// move |setting| *setting = Some(checked),
|
||||
// )
|
||||
// }
|
||||
// },
|
||||
// )
|
||||
// .contained()
|
||||
// .with_style(theme.welcome.checkbox_container),
|
||||
// )
|
||||
// .with_child(
|
||||
// theme::ui::checkbox_with_label::<Metrics, _, Self, _>(
|
||||
// Flex::column()
|
||||
// .with_child(
|
||||
// Label::new(
|
||||
// "Send anonymous usage data",
|
||||
// theme.welcome.checkbox.label.text.clone(),
|
||||
// )
|
||||
// .contained()
|
||||
// .with_style(theme.welcome.checkbox.label.container),
|
||||
// )
|
||||
// .with_child(
|
||||
// Label::new(
|
||||
// "Help > View Telemetry",
|
||||
// theme.welcome.usage_note.text.clone(),
|
||||
// )
|
||||
// .contained()
|
||||
// .with_style(theme.welcome.usage_note.container),
|
||||
// ),
|
||||
// &theme.welcome.checkbox,
|
||||
// telemetry_settings.metrics,
|
||||
// 0,
|
||||
// cx,
|
||||
// |this, checked, cx| {
|
||||
// if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
// let fs = workspace.read(cx).app_state().fs.clone();
|
||||
// update_settings_file::<TelemetrySettings>(
|
||||
// fs,
|
||||
// cx,
|
||||
// move |setting| setting.metrics = Some(checked),
|
||||
// )
|
||||
// }
|
||||
// },
|
||||
// )
|
||||
// .contained()
|
||||
// .with_style(theme.welcome.checkbox_container),
|
||||
// )
|
||||
// .with_child(
|
||||
// theme::ui::checkbox::<Diagnostics, Self, _>(
|
||||
// "Send crash reports",
|
||||
// &theme.welcome.checkbox,
|
||||
// telemetry_settings.diagnostics,
|
||||
// 1,
|
||||
// cx,
|
||||
// |this, checked, cx| {
|
||||
// if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
// let fs = workspace.read(cx).app_state().fs.clone();
|
||||
// update_settings_file::<TelemetrySettings>(
|
||||
// fs,
|
||||
// cx,
|
||||
// move |setting| setting.diagnostics = Some(checked),
|
||||
// )
|
||||
// }
|
||||
// },
|
||||
// )
|
||||
// .contained()
|
||||
// .with_style(theme.welcome.checkbox_container),
|
||||
// )
|
||||
// .contained()
|
||||
// .with_style(theme.welcome.checkbox_group)
|
||||
// .constrained()
|
||||
// .with_width(width),
|
||||
// )
|
||||
// .constrained()
|
||||
// .with_max_width(width)
|
||||
// .contained()
|
||||
// .with_uniform_padding(10.)
|
||||
// .aligned()
|
||||
// .into_any(),
|
||||
// )
|
||||
// .into_any_named("welcome page")
|
||||
}
|
||||
}
|
||||
|
||||
impl WelcomePage {
|
||||
pub fn new(workspace: &Workspace, cx: &mut ViewContext<Self>) -> Self {
|
||||
WelcomePage {
|
||||
focus_handle: cx.focus_handle(),
|
||||
workspace: workspace.weak_handle(),
|
||||
_settings_subscription: cx.observe_global::<SettingsStore, _>(move |_, cx| cx.notify()),
|
||||
_settings_subscription: cx.observe_global::<SettingsStore>(move |_, cx| cx.notify()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Item for WelcomePage {
|
||||
fn tab_tooltip_text(&self, _: &AppContext) -> Option<Cow<str>> {
|
||||
Some("Welcome to Zed!".into())
|
||||
}
|
||||
impl EventEmitter<ItemEvent> for WelcomePage {}
|
||||
|
||||
fn tab_content<T: 'static>(
|
||||
&self,
|
||||
_detail: Option<usize>,
|
||||
style: &theme::Tab,
|
||||
_cx: &gpui::AppContext,
|
||||
) -> AnyElement<T> {
|
||||
Flex::row()
|
||||
.with_child(
|
||||
Label::new("Welcome to Zed!", style.label.clone())
|
||||
.aligned()
|
||||
.contained(),
|
||||
)
|
||||
.into_any()
|
||||
impl FocusableView for WelcomePage {
|
||||
fn focus_handle(&self, _: &AppContext) -> gpui::FocusHandle {
|
||||
self.focus_handle.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl Item for WelcomePage {
|
||||
fn tab_content(&self, _: Option<usize>, _: &WindowContext) -> AnyElement {
|
||||
"Welcome to Zed!".into_any()
|
||||
}
|
||||
|
||||
fn show_toolbar(&self) -> bool {
|
||||
@@ -278,10 +270,11 @@ impl Item for WelcomePage {
|
||||
&self,
|
||||
_workspace_id: WorkspaceId,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Option<Self> {
|
||||
Some(WelcomePage {
|
||||
) -> Option<View<Self>> {
|
||||
Some(cx.build_view(|cx| WelcomePage {
|
||||
focus_handle: cx.focus_handle(),
|
||||
workspace: self.workspace.clone(),
|
||||
_settings_subscription: cx.observe_global::<SettingsStore, _>(move |_, cx| cx.notify()),
|
||||
})
|
||||
_settings_subscription: cx.observe_global::<SettingsStore>(move |_, cx| cx.notify()),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user