Separate theme rendering from client subscriptions and materials
This commit is contained in:
1 parent
ccf7497b6f
commit
cc0bddbec1
32 files changed
+428
-143
No files matched your search
@@ -14,6 +14,7 @@ name = "ferese-record"
|
||||
path = "src/record_main.rs"
|
||||
|
||||
[dependencies]
|
||||
ferese-theme-client = { path = "../crates/ferese-theme-client" }
|
||||
reis = { version = "0.7.1", features = ["calloop"] }
|
||||
calloop.workspace = true
|
||||
ferese-protocols = { path = "../crates/ferese-protocols", default-features = false, features = ["client"] }
|
||||
|
||||
@@ -5,8 +5,8 @@ use cosmic::Element;
|
||||
use cosmic::app::{Core, Settings, Task};
|
||||
use cosmic::iced::{Alignment, Length};
|
||||
use cosmic::widget::{button, column, container, image, row, scrollable, text_input};
|
||||
use ferese_theme::material::ModalMaterial;
|
||||
use ferese_theme::{Palette, accent_button, controls, text};
|
||||
use ferese_theme_client::material::ModalMaterial;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
@@ -101,7 +101,7 @@ impl cosmic::Application for Consent {
|
||||
prompt,
|
||||
material: None,
|
||||
parent: None,
|
||||
palette: Palette::from_resolved(&ferese_theme::service::current().presented),
|
||||
palette: Palette::from_resolved(&ferese_theme_client::service::current().presented),
|
||||
font,
|
||||
background,
|
||||
};
|
||||
@@ -110,7 +110,7 @@ impl cosmic::Application for Consent {
|
||||
|
||||
fn subscription(&self) -> cosmic::iced::Subscription<Message> {
|
||||
cosmic::iced::Subscription::batch([
|
||||
ferese_theme::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
|
||||
ferese_theme_client::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
|
||||
cosmic::iced::event::listen_with(|event, _, id| match event {
|
||||
cosmic::iced::Event::Window(cosmic::iced::window::Event::Opened { .. }) => Some(Message::Opened(id)),
|
||||
cosmic::iced::Event::Keyboard(cosmic::iced::keyboard::Event::KeyPressed {
|
||||
@@ -128,7 +128,7 @@ impl cosmic::Application for Consent {
|
||||
self.palette = Palette::from_resolved(&snapshot.presented).flat();
|
||||
self.font = ferese_theme::font(Some(&snapshot.presented.tokens.typography.font_family));
|
||||
self.background = cosmic::iced::Color {
|
||||
a: ferese_theme::service::opacity(&snapshot.presented),
|
||||
a: ferese_theme::material_opacity(&snapshot.presented),
|
||||
..self.palette.sidebar
|
||||
};
|
||||
return cosmic::command::set_theme(self.palette.native_theme());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
pub(crate) type Attachment = Result<
|
||||
(
|
||||
Option<std::sync::Arc<Parent>>,
|
||||
Result<ferese_theme::material::ModalMaterial, String>,
|
||||
Result<ferese_theme_client::material::ModalMaterial, String>,
|
||||
),
|
||||
String,
|
||||
>;
|
||||
|
||||
@@ -63,7 +63,7 @@ enum Message {
|
||||
|
||||
struct Picker {
|
||||
core: Core,
|
||||
material: Option<ferese_theme::material::ModalMaterial>,
|
||||
material: Option<ferese_theme_client::material::ModalMaterial>,
|
||||
parent: Option<std::sync::Arc<crate::parent::Parent>>,
|
||||
prompt: Prompt,
|
||||
selected: Vec<usize>,
|
||||
@@ -153,7 +153,7 @@ impl cosmic::Application for Picker {
|
||||
|
||||
fn subscription(&self) -> cosmic::iced::Subscription<Message> {
|
||||
cosmic::iced::Subscription::batch([
|
||||
ferese_theme::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
|
||||
ferese_theme_client::service::subscription().map(|snapshot| Message::ThemeChanged(Box::new(snapshot))),
|
||||
cosmic::iced::event::listen_with(|event, _, id| match event {
|
||||
cosmic::iced::Event::Window(cosmic::iced::window::Event::Opened { .. }) => {
|
||||
Some(Message::WindowOpened(id))
|
||||
@@ -169,7 +169,7 @@ impl cosmic::Application for Picker {
|
||||
self.palette = ferese_theme::Palette::from_resolved(&snapshot.presented).flat();
|
||||
self.font = ferese_theme::font(Some(&snapshot.presented.tokens.typography.font_family));
|
||||
self.background = cosmic::iced::Color {
|
||||
a: ferese_theme::service::opacity(&snapshot.presented),
|
||||
a: ferese_theme::material_opacity(&snapshot.presented),
|
||||
..self.palette.sidebar
|
||||
};
|
||||
return cosmic::command::set_theme(self.palette.native_theme());
|
||||
@@ -178,7 +178,7 @@ impl cosmic::Application for Picker {
|
||||
let parent = self.prompt.parent.clone();
|
||||
return cosmic::iced::window::run(id, move |window| {
|
||||
let parent = crate::parent::Parent::attach(window, &parent)?.map(std::sync::Arc::new);
|
||||
Ok((parent, ferese_theme::material::ModalMaterial::attach(window)))
|
||||
Ok((parent, ferese_theme_client::material::ModalMaterial::attach(window)))
|
||||
})
|
||||
.map(|result| cosmic::Action::App(Message::Attached(result)));
|
||||
}
|
||||
@@ -387,14 +387,14 @@ pub(crate) fn appearance() -> (
|
||||
cosmic::iced::Color,
|
||||
ferese_theme::Palette,
|
||||
) {
|
||||
let snapshot = ferese_theme::service::current();
|
||||
let snapshot = ferese_theme_client::service::current();
|
||||
let palette = ferese_theme::Palette::from_resolved(&snapshot.presented).flat();
|
||||
let family = &snapshot.presented.tokens.typography.font_family;
|
||||
(
|
||||
palette.native_theme(),
|
||||
ferese_theme::font(Some(family)),
|
||||
cosmic::iced::Color {
|
||||
a: ferese_theme::service::opacity(&snapshot.presented),
|
||||
a: ferese_theme::material_opacity(&snapshot.presented),
|
||||
..palette.sidebar
|
||||
},
|
||||
palette,
|
||||
|
||||
Reference in new issue
Block a user