Implement font::load command in iced_native
This commit is contained in:
parent
b29de28d1f
commit
238154af4a
14 changed files with 384 additions and 241 deletions
|
|
@ -1,5 +1,6 @@
|
|||
use iced::alignment::{self, Alignment};
|
||||
use iced::event::{self, Event};
|
||||
use iced::font::{self, Font};
|
||||
use iced::keyboard;
|
||||
use iced::subscription;
|
||||
use iced::theme::{self, Theme};
|
||||
|
|
@ -9,7 +10,7 @@ use iced::widget::{
|
|||
};
|
||||
use iced::window;
|
||||
use iced::{Application, Element};
|
||||
use iced::{Color, Command, Font, Length, Settings, Subscription};
|
||||
use iced::{Color, Command, Length, Settings, Subscription};
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -44,6 +45,7 @@ struct State {
|
|||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
Loaded(Result<SavedState, LoadError>),
|
||||
FontLoaded(Result<(), font::Error>),
|
||||
Saved(Result<(), SaveError>),
|
||||
InputChanged(String),
|
||||
CreateTask,
|
||||
|
|
@ -61,7 +63,11 @@ impl Application for Todos {
|
|||
fn new(_flags: ()) -> (Todos, Command<Message>) {
|
||||
(
|
||||
Todos::Loading,
|
||||
Command::perform(SavedState::load(), Message::Loaded),
|
||||
Command::batch(vec![
|
||||
font::load(include_bytes!("../fonts/icons.ttf").as_slice())
|
||||
.map(Message::FontLoaded),
|
||||
Command::perform(SavedState::load(), Message::Loaded),
|
||||
]),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -384,7 +390,7 @@ fn view_controls(tasks: &[Task], current_filter: Filter) -> Element<Message> {
|
|||
let tasks_left = tasks.iter().filter(|task| !task.completed).count();
|
||||
|
||||
let filter_button = |label, filter, current_filter| {
|
||||
let label = text(label).size(16);
|
||||
let label = text(label);
|
||||
|
||||
let button = button(label).style(if filter == current_filter {
|
||||
theme::Button::Primary
|
||||
|
|
@ -401,8 +407,7 @@ fn view_controls(tasks: &[Task], current_filter: Filter) -> Element<Message> {
|
|||
tasks_left,
|
||||
if tasks_left == 1 { "task" } else { "tasks" }
|
||||
))
|
||||
.width(Length::Fill)
|
||||
.size(16),
|
||||
.width(Length::Fill),
|
||||
row![
|
||||
filter_button("All", Filter::All, current_filter),
|
||||
filter_button("Active", Filter::Active, current_filter),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue