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
use crate::widgets::{AssignPropertyAttr, Properties, PropertyType, Widget, WidgetTemplateAttr};
impl Widget {
pub(crate) fn has_struct_field(&self) -> bool {
match self.template_attr {
WidgetTemplateAttr::None => {
self.name_assigned_by_user || self.properties.are_properties_updated()
}
WidgetTemplateAttr::Template => true,
WidgetTemplateAttr::TemplateChild => false,
}
}
}
impl Properties {
pub(crate) fn are_properties_updated(&self) -> bool {
self.properties.iter().any(|prop| match &prop.ty {
PropertyType::Assign(assign_prop) => matches!(
&assign_prop.attr,
AssignPropertyAttr::Track(_) | AssignPropertyAttr::Watch
),
_ => false,
})
}
}