chore: Upgrade to GPUI3 (#6)
* wip: gpui3 * wip: gpui3 * chore: fix clippy
This commit is contained in:
@@ -1,34 +1,44 @@
|
||||
use common::constants::KEYRING_SERVICE;
|
||||
use gpui::{div, IntoElement, ParentElement, Render, Styled, View, ViewContext, VisualContext};
|
||||
use gpui::{
|
||||
div, App, AppContext, Context, Entity, IntoElement, ParentElement, Render, Styled, Window,
|
||||
};
|
||||
use nostr_sdk::prelude::*;
|
||||
use registry::{app::AppRegistry, contact::Contact};
|
||||
use state::get_client;
|
||||
use ui::input::{InputEvent, TextInput};
|
||||
|
||||
pub struct Onboarding {
|
||||
input: View<TextInput>,
|
||||
input: Entity<TextInput>,
|
||||
}
|
||||
|
||||
impl Onboarding {
|
||||
pub fn new(cx: &mut ViewContext<'_, Self>) -> Self {
|
||||
let input = cx.new_view(|cx| {
|
||||
let mut input = TextInput::new(cx);
|
||||
input.set_size(ui::Size::Medium, cx);
|
||||
pub fn new(window: &mut Window, cx: &mut Context<'_, Self>) -> Self {
|
||||
let input = cx.new(|cx| {
|
||||
let mut input = TextInput::new(window, cx);
|
||||
input.set_size(ui::Size::Medium, window, cx);
|
||||
input
|
||||
});
|
||||
|
||||
cx.subscribe(&input, move |_, text_input, input_event, cx| {
|
||||
if let InputEvent::PressEnter = input_event {
|
||||
let content = text_input.read(cx).text().to_string();
|
||||
_ = Self::save_keys(&content, cx);
|
||||
}
|
||||
})
|
||||
cx.subscribe_in(
|
||||
&input,
|
||||
window,
|
||||
move |_, text_input, input_event, window, cx| {
|
||||
if let InputEvent::PressEnter = input_event {
|
||||
let content = text_input.read(cx).text().to_string();
|
||||
_ = Self::save_keys(&content, window, cx);
|
||||
}
|
||||
},
|
||||
)
|
||||
.detach();
|
||||
|
||||
Self { input }
|
||||
}
|
||||
|
||||
fn save_keys(content: &str, cx: &mut ViewContext<Self>) -> anyhow::Result<(), anyhow::Error> {
|
||||
fn save_keys(
|
||||
content: &str,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> anyhow::Result<(), anyhow::Error> {
|
||||
let keys = Keys::parse(content)?;
|
||||
let public_key = keys.public_key();
|
||||
let bech32 = public_key.to_bech32()?;
|
||||
@@ -75,7 +85,7 @@ impl Onboarding {
|
||||
}
|
||||
|
||||
impl Render for Onboarding {
|
||||
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||
fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
div()
|
||||
.size_full()
|
||||
.flex()
|
||||
|
||||
Reference in New Issue
Block a user