1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
use dioxus::prelude::*;
use freya_components::*;
use freya_core::prelude::*;
use freya_elements::elements as dioxus_elements;
use crate::{
    property::{
        BorderProperty, ColorProperty, LinearGradientProperty, Property, ShadowProperty,
        TextShadowProperty,
    },
    NodeInspectorBar, TreeNode,
};
#[allow(non_snake_case)]
#[inline_props]
pub fn NodeInspectorStyle<'a>(cx: Scope<'a>, node: &'a TreeNode) -> Element<'a> {
    render!(
        rect {
            overflow: "clip",
            width: "100%",
            height: "50%",
            NodeInspectorBar { }
            ScrollView {
                show_scrollbar: true,
                height: "calc(100% - 35)",
                width: "100%",
                node.state.iter().enumerate().map(|(i, (name, attr))| {
                    match attr {
                        AttributeType::Measure(measure) => {
                            rsx!{
                                Property {
                                    key: "{i}",
                                    name: "{name}",
                                    value: measure.to_string()
                                }
                            }
                        }
                        AttributeType::Measures(measures) => {
                            rsx!{
                                Property {
                                    key: "{i}",
                                    name: "{name}",
                                    value: measures.pretty()
                                }
                            }
                        }
                        AttributeType::CornerRadius(radius) => {
                            rsx!{
                                Property {
                                    key: "{i}",
                                    name: "{name}",
                                    value: radius.pretty()
                                }
                            }
                        }
                        AttributeType::Size(size) => {
                            rsx!{
                                Property {
                                    key: "{i}",
                                    name: "{name}",
                                    value: size.pretty()
                                }
                            }
                        }
                        AttributeType::Color(fill) => {
                            rsx!{
                                ColorProperty {
                                    key: "{i}",
                                    name: "{name}",
                                    fill: fill
                                }
                            }
                        }
                        AttributeType::LinearGradient(fill) => {
                            rsx!{
                                LinearGradientProperty {
                                    key: "{i}",
                                    name: "{name}",
                                    fill: fill
                                }
                            }
                        }
                        AttributeType::Border(border) => {
                            rsx!{
                                BorderProperty {
                                    key: "{i}",
                                    name: "{name}",
                                    border: border
                                }
                            }
                        }
                        AttributeType::Text(text) => {
                            rsx!{
                                Property {
                                    key: "{i}",
                                    name: "{name}",
                                    value: text.to_string()
                                }
                            }
                        }
                        AttributeType::Direction(direction) => {
                            rsx!{
                                Property {
                                    key: "{i}",
                                    name: "{name}",
                                    value: direction.pretty()
                                }
                            }
                        }
                        AttributeType::Display(display) => {
                            rsx!{
                                Property {
                                    key: "{i}",
                                    name: "{name}",
                                    value: display.pretty()
                                }
                            }
                        }
                        AttributeType::Shadow(shadow) => {
                            rsx!{
                                ShadowProperty {
                                    key: "{i}",
                                    name: "{name}",
                                    shadow: shadow
                                }
                            }
                        }
                        AttributeType::TextShadow(text_shadow) => {
                            rsx!{
                                TextShadowProperty {
                                    key: "{i}",
                                    name: "{name}",
                                    text_shadow: text_shadow
                                }
                            }
                        }
                    }
                })
            }
        }
    )
}