Add welcome info box next to room list
This commit is contained in:
parent
a522b09f79
commit
2deecc2084
4 changed files with 34 additions and 24 deletions
|
|
@ -17,9 +17,9 @@ Procedure when bumping the version number:
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Support for multiple euph server domains
|
- Support for multiple euph server domains
|
||||||
- Room domains are visible in the UI
|
|
||||||
- Domain field to "connect to new room" popup
|
- Domain field to "connect to new room" popup
|
||||||
- `--domain` option to `cove export` command
|
- `--domain` option to `cove export` command
|
||||||
|
- Welcome info box next to room list
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- The default euph domain is now https://euphoria.leet.nu/ everywhere
|
- The default euph domain is now https://euphoria.leet.nu/ everywhere
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ mod store;
|
||||||
mod ui;
|
mod ui;
|
||||||
mod util;
|
mod util;
|
||||||
mod vault;
|
mod vault;
|
||||||
|
mod version;
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
|
@ -36,6 +37,7 @@ use toss::Terminal;
|
||||||
use crate::logger::Logger;
|
use crate::logger::Logger;
|
||||||
use crate::ui::Ui;
|
use crate::ui::Ui;
|
||||||
use crate::vault::Vault;
|
use crate::vault::Vault;
|
||||||
|
use crate::version::{NAME, VERSION};
|
||||||
|
|
||||||
#[derive(Debug, clap::Parser)]
|
#[derive(Debug, clap::Parser)]
|
||||||
enum Command {
|
enum Command {
|
||||||
|
|
@ -176,11 +178,7 @@ async fn run(
|
||||||
config: &'static Config,
|
config: &'static Config,
|
||||||
dirs: &ProjectDirs,
|
dirs: &ProjectDirs,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
info!(
|
info!("Welcome to {NAME} {VERSION}",);
|
||||||
"Welcome to {} {}",
|
|
||||||
env!("CARGO_PKG_NAME"),
|
|
||||||
env!("CARGO_PKG_VERSION")
|
|
||||||
);
|
|
||||||
|
|
||||||
let vault = open_vault(config, dirs)?;
|
let vault = open_vault(config, dirs)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,13 @@ use euphoxide::api::SessionType;
|
||||||
use euphoxide::bot::instance::{Event, ServerConfig};
|
use euphoxide::bot::instance::{Event, ServerConfig};
|
||||||
use euphoxide::conn::{self, Joined};
|
use euphoxide::conn::{self, Joined};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
use toss::widgets::{BoxedAsync, Join2, Text};
|
use toss::widgets::{BoxedAsync, Empty, Join2, Text};
|
||||||
use toss::{Style, Styled, Widget, WidgetExt};
|
use toss::{Style, Styled, Widget, WidgetExt};
|
||||||
|
|
||||||
use crate::euph;
|
use crate::euph;
|
||||||
use crate::macros::logging_unwrap;
|
use crate::macros::logging_unwrap;
|
||||||
use crate::vault::{EuphVault, RoomIdentifier, Vault};
|
use crate::vault::{EuphVault, RoomIdentifier, Vault};
|
||||||
|
use crate::version::{NAME, VERSION};
|
||||||
|
|
||||||
use self::connect::{ConnectResult, ConnectState};
|
use self::connect::{ConnectResult, ConnectState};
|
||||||
use self::delete::{DeleteResult, DeleteState};
|
use self::delete::{DeleteResult, DeleteState};
|
||||||
|
|
@ -360,20 +361,10 @@ impl Rooms {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn render_rows(
|
async fn render_rows(
|
||||||
config: &Config,
|
|
||||||
list_builder: &mut ListBuilder<'_, RoomIdentifier, Text>,
|
list_builder: &mut ListBuilder<'_, RoomIdentifier, Text>,
|
||||||
order: Order,
|
order: Order,
|
||||||
euph_rooms: &HashMap<RoomIdentifier, EuphRoom>,
|
euph_rooms: &HashMap<RoomIdentifier, EuphRoom>,
|
||||||
) {
|
) {
|
||||||
if euph_rooms.is_empty() {
|
|
||||||
let style = Style::new().grey().italic();
|
|
||||||
list_builder.add_unsel(Text::new(
|
|
||||||
Styled::new("Press ", style)
|
|
||||||
.and_then(key_bindings::format_binding(&config.keys.general.help))
|
|
||||||
.then(" for key bindings", style),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut rooms = vec![];
|
let mut rooms = vec![];
|
||||||
for (id, room) in euph_rooms {
|
for (id, room) in euph_rooms {
|
||||||
let state = room.room_state();
|
let state = room.room_state();
|
||||||
|
|
@ -406,16 +397,35 @@ impl Rooms {
|
||||||
order: Order,
|
order: Order,
|
||||||
euph_rooms: &HashMap<RoomIdentifier, EuphRoom>,
|
euph_rooms: &HashMap<RoomIdentifier, EuphRoom>,
|
||||||
) -> impl Widget<UiError> + 'a {
|
) -> impl Widget<UiError> + 'a {
|
||||||
let heading_style = Style::new().bold();
|
let version_info = Styled::new_plain("Welcome to ")
|
||||||
let heading_text =
|
.then(format!("{NAME} {VERSION}"), Style::new().yellow().bold())
|
||||||
Styled::new("Rooms", heading_style).then_plain(format!(" ({})", euph_rooms.len()));
|
.then_plain("!");
|
||||||
|
let help_info = Styled::new("Press ", Style::new().grey())
|
||||||
|
.and_then(key_bindings::format_binding(&config.keys.general.help))
|
||||||
|
.then(" for key bindings.", Style::new().grey());
|
||||||
|
let info = Join2::vertical(
|
||||||
|
Text::new(version_info).float().with_center_h().segment(),
|
||||||
|
Text::new(help_info).segment(),
|
||||||
|
)
|
||||||
|
.padding()
|
||||||
|
.with_horizontal(1)
|
||||||
|
.border();
|
||||||
|
|
||||||
|
let heading = Styled::new("Rooms", Style::new().bold())
|
||||||
|
.then_plain(format!(" ({})", euph_rooms.len()));
|
||||||
|
|
||||||
let mut list_builder = ListBuilder::new();
|
let mut list_builder = ListBuilder::new();
|
||||||
Self::render_rows(config, &mut list_builder, order, euph_rooms).await;
|
Self::render_rows(&mut list_builder, order, euph_rooms).await;
|
||||||
|
|
||||||
Join2::vertical(
|
Join2::horizontal(
|
||||||
Text::new(heading_text).segment().with_fixed(true),
|
Join2::vertical(
|
||||||
list_builder.build(list).segment(),
|
Text::new(heading).segment().with_fixed(true),
|
||||||
|
list_builder.build(list).segment(),
|
||||||
|
)
|
||||||
|
.segment(),
|
||||||
|
Join2::vertical(info.segment().with_growing(false), Empty::new().segment())
|
||||||
|
.segment()
|
||||||
|
.with_growing(false),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
cove/src/version.rs
Normal file
2
cove/src/version.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
pub const NAME: &str = env!("CARGO_PKG_NAME");
|
||||||
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
Loading…
Add table
Add a link
Reference in a new issue