tawasuyu/llimphi
Sovereign retained-mode GPU UI framework in Rust (wgpu+vello+taffy+parley), Elm loop, 40+ widgets.
chore: refresco desde el monorepo — vello 0.9 / wgpu 29, 120 miembros
1//! Galería de los iconos de marca de todas las apps de tawasuyu.
2//!
3//! Pinta los 29 [`AppIcon`] en una grilla, cada uno en su color de marca
4//! con su nombre debajo. Sirve para eyeballear de un vistazo que el set
5//! es coherente (mismo peso de trazo, mismo aire) y que cada glifo es
6//! reconocible.
7//!
8//! `cargo run -p llimphi-icons --example app_icons_gallery --release`
9
10use llimphi_icons::app_icons::{app_icon_view, AppIcon, ALL};
11use llimphi_ui::llimphi_layout::taffy::prelude::{
12 auto, length, percent, AlignItems, FlexDirection, JustifyContent, Size, Style,
13};
14use llimphi_ui::llimphi_layout::taffy::Rect;
15use llimphi_ui::llimphi_raster::peniko::Color;
16use llimphi_ui::llimphi_text::Alignment;
17use llimphi_ui::{App, Handle, View};
18
19const COLS: usize = 6;
20const BG: Color = Color::from_rgb8(18, 20, 24);
21const CELL: Color = Color::from_rgb8(28, 31, 38);
22const LABEL: Color = Color::from_rgb8(196, 202, 212);
23
24struct Model;
25
26#[derive(Clone)]
27enum Msg {}
28
29fn cell(icon: AppIcon) -> View<Msg> {
30 // Recuadro del glifo (cuadrado, el icono se escala al lado menor).
31 let icon_box = View::new(Style {
32 size: Size {
33 width: length(52.0_f32),
34 height: length(52.0_f32),
35 },
36 flex_shrink: 0.0,
37 ..Default::default()
38 })
39 .children(vec![app_icon_view(icon, 2.0)]);
40
41 let label = View::new(Style {
42 size: Size {
43 width: percent(1.0_f32),
44 height: length(16.0_f32),
45 },
46 ..Default::default()
47 })
48 .text_aligned(icon.name().to_string(), 11.0, LABEL, Alignment::Center);
49
50 View::new(Style {
51 size: Size {
52 width: length(118.0_f32),
53 height: length(96.0_f32),
54 },
55 flex_direction: FlexDirection::Column,
56 align_items: Some(AlignItems::CENTER),
57 justify_content: Some(JustifyContent::CENTER),
58 gap: Size {
59 width: length(0.0_f32),
60 height: length(8.0_f32),
61 },
62 ..Default::default()
63 })
64 .fill(CELL)
65 .radius(12.0)
66 .children(vec![icon_box, label])
67}
68
69fn row(icons: &[AppIcon]) -> View<Msg> {
70 View::new(Style {
71 size: Size {
72 width: auto(),
73 height: auto(),
74 },
75 flex_direction: FlexDirection::Row,
76 gap: Size {
77 width: length(14.0_f32),
78 height: length(0.0_f32),
79 },
80 ..Default::default()
81 })
82 .children(icons.iter().copied().map(cell).collect())
83}
84
85struct Gallery;
86
87impl App for Gallery {
88 type Model = Model;
89 type Msg = Msg;
90
91 fn title() -> &'static str {
92 "llimphi-icons · galería de apps"
93 }
94
95 fn initial_size() -> (u32, u32) {
96 (820, 620)
97 }
98
99 fn init(_: &Handle<Msg>) -> Model {
100 Model
101 }
102
103 fn update(_model: Model, msg: Msg, _: &Handle<Msg>) -> Model {
104 match msg {}
105 }
106
107 fn view(_: &Model) -> View<Msg> {
108 let rows: Vec<View<Msg>> = ALL.chunks(COLS).map(row).collect();
109 View::new(Style {
110 size: Size {
111 width: percent(1.0_f32),
112 height: percent(1.0_f32),
113 },
114 flex_direction: FlexDirection::Column,
115 align_items: Some(AlignItems::CENTER),
116 justify_content: Some(JustifyContent::CENTER),
117 gap: Size {
118 width: length(0.0_f32),
119 height: length(14.0_f32),
120 },
121 padding: Rect {
122 left: length(20.0_f32),
123 right: length(20.0_f32),
124 top: length(20.0_f32),
125 bottom: length(20.0_f32),
126 },
127 ..Default::default()
128 })
129 .fill(BG)
130 .children(rows)
131 }
132}
133
134fn main() {
135 llimphi_ui::run::<Gallery>();
136}