Remove iced client
going to Godot
This commit is contained in:
@@ -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
|
|
||||||
Binary file not shown.
@@ -1,4 +0,0 @@
|
|||||||
[Desktop Entry]
|
|
||||||
Name=Todos - Iced
|
|
||||||
Exec=iced-todos
|
|
||||||
Type=Application
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8" content="text/html; charset=utf-8" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
||||||
<title>Todos - Iced</title>
|
|
||||||
<base data-trunk-public-url />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<link data-trunk rel="rust" href="Cargo.toml" data-wasm-opt="z" data-bin="todos" />
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -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<text_input::Id> = Lazy::new(text_input::Id::unique);
|
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
|
||||||
pub struct RealmApp {
|
|
||||||
input_value: String,
|
|
||||||
messages: Vec<Message>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub enum Events {
|
|
||||||
// Loaded(Result<SavedState, LoadError>),
|
|
||||||
// Saved(Result<(), SaveError>),
|
|
||||||
InputChanged(String),
|
|
||||||
SendMessage,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RealmApp {
|
|
||||||
pub fn load() -> Command<Events> {
|
|
||||||
//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<Events> {
|
|
||||||
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<Events> {
|
|
||||||
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<Events> {
|
|
||||||
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}')
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
mod app;
|
|
||||||
mod components;
|
|
||||||
pub use app::RealmApp;
|
|
||||||
@@ -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()
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user