🏡 index : ~doyle/shalom.git

author Jordan Doyle <jordan@doyle.la> 2024-01-12 23:45:47.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2024-01-12 23:45:47.0 +00:00:00
commit
014ad9a4d709849c95b63e1ff9b6ba2033cdda46 [patch]
tree
2c286013c0b66f052183bde27bd6420fb6fb277c
parent
ca961f85356a96aee9daecf00588519692d51e19
download
014ad9a4d709849c95b63e1ff9b6ba2033cdda46.tar.gz

Add spinner to initial load



Diff

 shalom/src/main.rs | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/shalom/src/main.rs b/shalom/src/main.rs
index 98bb1d4..e7821f2 100644
--- a/shalom/src/main.rs
+++ b/shalom/src/main.rs
@@ -14,11 +14,17 @@ mod widgets;
use std::sync::Arc;

use iced::{
    widget::{column, Column},
    window, Application, Command, Element, Renderer, Settings, Subscription, Theme,
    alignment::{Horizontal, Vertical},
    widget::{container, Column},
    window, Application, Command, Element, Length, Renderer, Settings, Subscription, Theme,
};

use crate::{config::Config, oracle::Oracle, theme::Image, widgets::context_menu::ContextMenu};
use crate::{
    config::Config,
    oracle::Oracle,
    theme::Image,
    widgets::{context_menu::ContextMenu, spinner::CupertinoSpinner},
};

pub struct Shalom {
    page: ActivePage,
@@ -264,7 +270,13 @@ impl Application for Shalom {

    fn view(&self) -> Element<'_, Self::Message, Renderer<Self::Theme>> {
        let page_content = match &self.page {
            ActivePage::Loading => Element::from(column!["Loading...",].spacing(20)),
            ActivePage::Loading => Element::from(
                container(CupertinoSpinner::new().width(40.into()).height(40.into()))
                    .width(Length::Fill)
                    .height(Length::Fill)
                    .align_x(Horizontal::Center)
                    .align_y(Vertical::Center),
            ),
            ActivePage::Room(room) => room.view(&self.theme).map(Message::RoomEvent),
            ActivePage::Omni(omni) => omni.view().map(Message::OmniEvent),
        };