diff --git a/client/Cargo.toml b/client/Cargo.toml deleted file mode 100644 index ad90271..0000000 --- a/client/Cargo.toml +++ /dev/null @@ -1,33 +0,0 @@ -[package] -name = "realm_client" -version = "0.1.0" -edition = "2021" - -[package.metadata.docs.rs] -all-features = true -targets = ["x86_64-unknown-linux-gnu", "wasm32-unknown-unknown"] - -[dependencies] -realm_server = { version = "0.1", path = "../server" } - -log = "0.4" -tarpc = { version = "0.34.0", features = ["full"] } -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -uuid = { version = "1.8", features = ["v4", "fast-rng", "serde"] } -directories-next = "2.0" -tracing-subscriber = "0.3" -async-std = "1.12.0" -once_cell = "1.19.0" -env_logger = "0.11.3" - -[dependencies.iced] -git = "https://github.com/iced-rs/iced.git" -rev = "e6d0b3bda5042a1017a5944a5227c97e0ed6caf9" - -[profile.release] -opt-level = 2 # fast and small wasm - -# Optimize all dependencies even in debug builds: -[profile.dev.package."*"] -opt-level = 2 diff --git a/client/assets/icons.ttf b/client/assets/icons.ttf deleted file mode 100644 index 7b65fd3..0000000 Binary files a/client/assets/icons.ttf and /dev/null differ diff --git a/client/iced-todos.desktop b/client/iced-todos.desktop deleted file mode 100644 index dd7ce53..0000000 --- a/client/iced-todos.desktop +++ /dev/null @@ -1,4 +0,0 @@ -[Desktop Entry] -Name=Todos - Iced -Exec=iced-todos -Type=Application diff --git a/client/index.html b/client/index.html deleted file mode 100644 index ee5570f..0000000 --- a/client/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - Todos - Iced - - - - - - diff --git a/client/src/app.rs b/client/src/app.rs deleted file mode 100644 index 0fa1b83..0000000 --- a/client/src/app.rs +++ /dev/null @@ -1,161 +0,0 @@ -use iced::alignment::{self, Alignment}; -use iced::{keyboard, Renderer, Theme}; -use iced::widget::{ - self, button, center, checkbox, column, container, keyed_column, row, - scrollable, text, text_input, Text, -}; -use iced::window; -use iced::{Command, Element, Font, Length, Subscription}; -use iced::futures::StreamExt; - -use once_cell::sync::Lazy; -use serde::{Deserialize, Serialize}; -use uuid::Uuid; -use realm_server::types::Message; - -static INPUT_ID: Lazy = Lazy::new(text_input::Id::unique); - -#[derive(Default, Debug)] -pub struct RealmApp { - input_value: String, - messages: Vec, -} - -#[derive(Debug, Clone)] -pub enum Events { - // Loaded(Result), - // Saved(Result<(), SaveError>), - InputChanged(String), - SendMessage, -} - -impl RealmApp { - pub fn load() -> Command { - //Command::perform(SavedState::load(), Events::Loaded) - Command::none() - } - - pub fn title(&self) -> String { - "Realm Chat".to_string() - } - - pub fn update(&mut self, event: Events) -> Command { - let command = match event { - Events::InputChanged(value) => { - self.input_value = value; - - Command::none() - } - Events::SendMessage => { - self.messages.push(Message { - guid: "".to_string(), - text: Some(self.input_value.clone()), - attachments: None, - reply_to_guid: None, - reaction_emoji: None, - redact: false, - }); - - //TODO - self.input_value.clear(); - Command::none() - } - }; - - Command::batch(vec![command]) - } - - pub fn view(&self) -> Element { - let input = text_input("New Message", &*self.input_value) - .id(INPUT_ID.clone()) - .on_input(Events::InputChanged) - .on_submit(Events::SendMessage) - //.padding(15) - .size(12); - - let mut all_messages: String = String::new(); - for message in self.messages.iter() { - match message.clone().text { - None => {} - Some(text) => { - all_messages = format!("{}{}\n", all_messages, text) - } - } - } - - let messages = text(all_messages) - .size(12) - .width(Length::Fill) - .height(600) - .horizontal_alignment(alignment::Horizontal::Left); - - // let content = column![title, input] - // .spacing(20); - //.max_width(800); - - column!(scrollable( - container(messages).center_x(Length::Fill).padding(40)), input).into() - } - - pub fn subscription(&self) -> Subscription { - use keyboard::key; - - keyboard::on_key_press(|key, modifiers| { - let keyboard::Key::Named(key) = key else { - return None; - }; - - match (key, modifiers) { - // (key::Named::Tab, _) => Some(Events::TabPressed { - // shift: modifiers.shift(), - // }), - // (key::Named::ArrowUp, keyboard::Modifiers::SHIFT) => { - // Some(Events::ToggleFullscreen(window::Mode::Fullscreen)) - // } - // (key::Named::ArrowDown, keyboard::Modifiers::SHIFT) => { - // Some(Events::ToggleFullscreen(window::Mode::Windowed)) - // } - _ => None, - } - }) - } -} - -fn loading_message<'a>() -> Element<'a, Events> { - center( - text("Loading...") - .horizontal_alignment(alignment::Horizontal::Center) - .size(50), - ) - .into() -} - -fn empty_message(message: &str) -> Element<'_, Events> { - center( - text(message) - .width(Length::Fill) - .size(25) - .horizontal_alignment(alignment::Horizontal::Center) - .color([0.7, 0.7, 0.7]), - ) - .height(200) - .into() -} - -// Fonts -const ICONS: Font = Font::with_name("Iced-Todos-Icons"); - -fn icon(unicode: char) -> Text<'static> { - text(unicode.to_string()) - .font(ICONS) - .width(20) - .horizontal_alignment(alignment::Horizontal::Center) -} - -fn edit_icon() -> Text<'static> { - icon('\u{F303}') -} - -fn delete_icon() -> Text<'static> { - icon('\u{F1F8}') -} \ No newline at end of file diff --git a/client/src/components.rs b/client/src/components.rs deleted file mode 100644 index e69de29..0000000 diff --git a/client/src/lib.rs b/client/src/lib.rs deleted file mode 100644 index 62cc189..0000000 --- a/client/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod app; -mod components; -pub use app::RealmApp; \ No newline at end of file diff --git a/client/src/main.rs b/client/src/main.rs deleted file mode 100644 index b2b3beb..0000000 --- a/client/src/main.rs +++ /dev/null @@ -1,11 +0,0 @@ -use realm_client::RealmApp; - -pub fn main() -> iced::Result { - tracing_subscriber::fmt::init(); - iced::program(RealmApp::title, RealmApp::update, RealmApp::view) - .load(RealmApp::load) - .subscription(RealmApp::subscription) - .font(include_bytes!("../assets/icons.ttf").as_slice()) - .window_size((1280.0, 720.0)) - .run() -} \ No newline at end of file