freya_devtools_app/tabs/
text_style.rs1use freya::prelude::*;
2use freya_core::integration::NodeId;
3use freya_devtools::NodeStateAttributes;
4
5use crate::{
6 components::attribute::attribute_element,
7 hooks::use_node_info,
8};
9
10#[derive(PartialEq)]
11pub struct NodeInspectorTextStyle {
12 pub node_id: NodeId,
13 pub window_id: u64,
14}
15
16impl Render for NodeInspectorTextStyle {
17 fn render(&self) -> impl IntoElement {
18 let Some(node) = use_node_info(self.node_id, self.window_id) else {
19 return rect().into_element();
20 };
21
22 ScrollView::new()
23 .children_iter(
24 node.state
25 .text_style_attributes()
26 .into_iter()
27 .enumerate()
28 .filter_map(|(i, (name, attribute))| {
29 let background = if i % 2 == 0 {
30 Color::from_af32rgb(0.1, 255, 255, 255)
31 } else {
32 Color::TRANSPARENT
33 };
34
35 let element = attribute_element(name, attribute)?;
36
37 Some(
38 rect()
39 .key(i)
40 .background(background)
41 .padding((5., 16.))
42 .child(element)
43 .into(),
44 )
45 }),
46 )
47 .into()
48 }
49}