Skip to content

Commit

Permalink
welcome and help screens
Browse files Browse the repository at this point in the history
  • Loading branch information
casperstorm committed Jun 26, 2023
1 parent 8d99a5a commit 85f7dc7
Show file tree
Hide file tree
Showing 20 changed files with 698 additions and 146 deletions.
275 changes: 275 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data = { version = "0.1.0", path = "data" }

chrono = { version = "0.4", features = ['serde'] }
fern = "0.6.1"
iced = { version = "0.9", features = ["tokio", "lazy", "advanced"] }
iced = { version = "0.9", features = ["tokio", "lazy", "advanced", "image"] }
log = "0.4.16"
palette = "=0.7.2"
thiserror = "1.0.30"
Expand Down
Binary file modified assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion data/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ pub enum Error {
DirectoryCreation,
#[error("config could not be read: {0}")]
Read(String),
#[error("config could not be parsed: {0}")]
#[error("{0}")]
Parse(String),
}
1 change: 1 addition & 0 deletions data/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub(crate) fn data_dir() -> Option<PathBuf> {
}
}

#[allow(dead_code)]
fn is_absolute(path: &Path) -> bool {
path.is_absolute()
}
3 changes: 1 addition & 2 deletions data/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,8 @@ pub(crate) mod broadcast {
//! Generate messages that can be broadcast into every buffer
use chrono::Utc;

use crate::user::Nick;

use super::{Direction, Message, Sender, Source};
use crate::user::Nick;

fn expand(
channels: impl IntoIterator<Item = String>,
Expand Down
3 changes: 1 addition & 2 deletions data/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::time::Duration;

use futures::channel::mpsc;
use futures::never::Never;
use futures::stream;
use futures::{SinkExt, StreamExt};
use futures::{stream, SinkExt, StreamExt};
use irc::proto::Capability;
use tokio::time::{self, Instant, Interval};

Expand Down
7 changes: 2 additions & 5 deletions src/buffer.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use data::{buffer, config, history};
use data::{buffer, history};
use iced::Command;

use self::channel::Channel;
Expand Down Expand Up @@ -89,12 +89,9 @@ impl Buffer {
history: &'a history::Manager,
settings: &'a buffer::Settings,
is_focused: bool,
load_config_error: &'a Option<config::Error>,
) -> Element<'a, Message> {
match self {
Buffer::Empty(state) => {
empty::view(state, clients, load_config_error).map(Message::Empty)
}
Buffer::Empty(state) => empty::view(state).map(Message::Empty),
Buffer::Channel(state) => {
let status = clients.status(&state.server);

Expand Down
58 changes: 7 additions & 51 deletions src/buffer/empty.rs
Original file line number Diff line number Diff line change
@@ -1,55 +1,21 @@
use core::fmt;

use data::{config, Config};
use iced::widget::{button, column, container, text, vertical_space};
use iced::widget::{column, container, text};
use iced::{alignment, Length};

use crate::theme;
use crate::widget::{Collection, Element};
use crate::widget::Element;

#[derive(Debug, Clone)]
pub enum Message {
ConfigurationDirectoryPressed,
}
pub enum Message {}

#[derive(Debug, Clone)]
pub enum Event {}

pub fn view<'a>(
_state: &Empty,
clients: &data::client::Map,
// TODO: Make error a separate screen so we don't
// have to pass this all the way down
load_config_error: &'a Option<config::Error>,
) -> Element<'a, Message> {
let is_empty = clients.get_channels().is_empty();
let config_dir = is_empty
.then(|| {
Config::config_dir()
.map(|path| String::from(path.to_string_lossy()))
.ok()
})
.flatten();

let error = load_config_error
.as_ref()
.map(|error| text(error.to_string()).style(theme::Text::Error));
let title = if is_empty {
text("please create or edit config.yaml in the directory below")
} else {
text("you had me at halloy")
};
pub fn view<'a>(_state: &Empty) -> Element<'a, Message> {
// TODO: Consider if we can completetly remove this buffer.

let action = config_dir.map(|path| {
button(text(path))
.on_press(Message::ConfigurationDirectoryPressed)
.style(theme::Button::Default)
});
let content = column![]
.push_maybe(error)
.push(title)
.push(vertical_space(14))
.push_maybe(action)
.push(text("⟵ select buffer"))
.align_items(iced::Alignment::Center);

container(content)
Expand All @@ -64,17 +30,7 @@ pub fn view<'a>(
pub struct Empty {}

impl Empty {
pub fn update(&mut self, message: Message) -> Option<Event> {
match message {
Message::ConfigurationDirectoryPressed => {
let Ok(config) = Config::config_dir() else {
return None
};

let _ = open::that(config);
}
}

pub fn update(&mut self, _message: Message) -> Option<Event> {
None
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub const MONO: Font = Font {
..Font::with_name("Iosevka Term")
};

pub const _MONO_BOLD: Font = Font {
pub const MONO_BOLD: Font = Font {
monospaced: true,
weight: font::Weight::Bold,
..Font::with_name("Iosevka Term")
Expand Down
5 changes: 5 additions & 0 deletions src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ use crate::{font, theme};

// Based off https://github.com/iced-rs/iced_aw/blob/main/src/graphics/icons/bootstrap.rs

pub fn error<'a>() -> Text<'a> {
to_text('\u{f33a}')
}

pub fn globe<'a>() -> Text<'a> {
to_text('\u{f3ef}')
}
Expand Down Expand Up @@ -40,6 +44,7 @@ pub fn people<'a>() -> Text<'a> {

fn to_text<'a>(unicode: char) -> Text<'a> {
text(unicode.to_string())
.style(theme::Text::Primary)
.line_height(LineHeight::Relative(1.1))
.size(theme::ICON_SIZE)
.font(font::ICON)
Expand Down
Loading

0 comments on commit 85f7dc7

Please sign in to comment.