material_ui_rs/
application.rs1use iced::{Size, window as iced_window};
4use iced_winit::program;
5
6use crate::{Theme, fonts};
7
8pub fn application<State, Message, Renderer>(
13 boot: impl iced::application::BootFn<State, Message>,
14 update: impl iced::application::UpdateFn<State, Message>,
15 view: impl for<'a> iced::application::ViewFn<'a, State, Message, Theme, Renderer>,
16) -> iced::Application<impl iced::Program<State = State, Message = Message, Theme = Theme>>
17where
18 State: 'static,
19 Message: Send + 'static,
20 Renderer: program::Renderer,
21{
22 with_material_fonts(iced::application(boot, update, view))
23}
24
25pub fn with_material_fonts<P>(application: iced::Application<P>) -> iced::Application<P>
27where
28 P: iced::Program,
29{
30 fonts::all()
31 .into_iter()
32 .fold(application, iced::Application::font)
33 .default_font(fonts::ROBOTO)
34}
35
36pub fn window(size: Size) -> iced_window::Settings {
38 window_settings(size, None)
39}
40
41pub fn window_with_min_size(size: Size, min_size: Size) -> iced_window::Settings {
43 window_settings(size, Some(min_size))
44}
45
46pub fn window_settings(size: Size, min_size: Option<Size>) -> iced_window::Settings {
48 iced_window::Settings {
49 size,
50 min_size,
51 position: iced_window::Position::Centered,
52 ..iced_window::Settings::default()
53 }
54}
55
56#[cfg(test)]
57#[path = "../tests/application.rs"]
58mod tests;