generated from mitchell/rust_template
ControlRenderData no long has boxed data
This commit is contained in:
parent
64d2631140
commit
1e2709dc8c
@ -27,7 +27,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
let control = builder(button_builder);
|
let control = builder(button_builder);
|
||||||
|
|
||||||
let render_data = ControlRenderData {
|
let render_data = ControlRenderData {
|
||||||
data: Box::new(control.data),
|
data: control.data,
|
||||||
styles: control.styles,
|
styles: control.styles,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
.unzip();
|
.unzip();
|
||||||
|
|
||||||
let view = fs.group(super::ControlRenderData {
|
let view = fs.group(super::ControlRenderData {
|
||||||
data: Box::new(views.collect_view()),
|
data: views.collect_view(),
|
||||||
styles: group_builder.styles,
|
styles: group_builder.styles,
|
||||||
});
|
});
|
||||||
let validation_cb = move || {
|
let validation_cb = move || {
|
||||||
|
|||||||
@ -16,7 +16,6 @@ impl VanityControlData for HeadingData {
|
|||||||
fs.heading(control)
|
fs.heading(control)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: impl GetterVanityControl
|
|
||||||
|
|
||||||
impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
||||||
pub fn heading(
|
pub fn heading(
|
||||||
|
|||||||
@ -70,9 +70,8 @@ pub trait ValidatedControlData: ControlData {}
|
|||||||
|
|
||||||
/// The data needed to render a interactive control of type `C`.
|
/// The data needed to render a interactive control of type `C`.
|
||||||
pub struct ControlRenderData<FS: FormStyle + ?Sized, C: ?Sized> {
|
pub struct ControlRenderData<FS: FormStyle + ?Sized, C: ?Sized> {
|
||||||
// TODO: Does this need to be boxed? This isn't trait objected any more
|
|
||||||
pub data: Box<C>,
|
|
||||||
pub styles: Vec<FS::StylingAttributes>,
|
pub styles: Vec<FS::StylingAttributes>,
|
||||||
|
pub data: C,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The data needed to render a read-only control of type `C`.
|
/// The data needed to render a read-only control of type `C`.
|
||||||
@ -101,7 +100,7 @@ impl<FD: FormToolData, FS: FormStyle, C: VanityControlData> VanityControlBuilder
|
|||||||
pub(crate) fn build(self) -> BuiltVanityControlData<FD, FS, C> {
|
pub(crate) fn build(self) -> BuiltVanityControlData<FD, FS, C> {
|
||||||
BuiltVanityControlData {
|
BuiltVanityControlData {
|
||||||
render_data: ControlRenderData {
|
render_data: ControlRenderData {
|
||||||
data: Box::new(self.data),
|
data: self.data,
|
||||||
styles: self.style_attributes,
|
styles: self.style_attributes,
|
||||||
},
|
},
|
||||||
getter: self.getter,
|
getter: self.getter,
|
||||||
@ -209,7 +208,7 @@ impl<FD: FormToolData, FS: FormStyle, C: ControlData, FDT> ControlBuilder<FD, FS
|
|||||||
|
|
||||||
Ok(BuiltControlData {
|
Ok(BuiltControlData {
|
||||||
render_data: ControlRenderData {
|
render_data: ControlRenderData {
|
||||||
data: Box::new(self.data),
|
data: self.data,
|
||||||
styles: self.style_attributes,
|
styles: self.style_attributes,
|
||||||
},
|
},
|
||||||
getter,
|
getter,
|
||||||
|
|||||||
@ -232,7 +232,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
.unzip();
|
.unzip();
|
||||||
|
|
||||||
let elements = fs.form_frame(ControlRenderData {
|
let elements = fs.form_frame(ControlRenderData {
|
||||||
data: Box::new(views.into_view()),
|
data: views.into_view(),
|
||||||
styles: self.styles,
|
styles: self.styles,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
|||||||
.unzip();
|
.unzip();
|
||||||
|
|
||||||
let elements = fs.form_frame(ControlRenderData {
|
let elements = fs.form_frame(ControlRenderData {
|
||||||
data: Box::new(views.into_view()),
|
data: views.into_view(),
|
||||||
styles: self.styles,
|
styles: self.styles,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
type StylingAttributes = GridFormStylingAttributes;
|
type StylingAttributes = GridFormStylingAttributes;
|
||||||
|
|
||||||
fn form_frame(&self, form: ControlRenderData<Self, View>) -> View {
|
fn form_frame(&self, form: ControlRenderData<Self, View>) -> View {
|
||||||
view! { <div class="form_grid">{*form.data}</div> }.into_view()
|
view! { <div class="form_grid">{form.data}</div> }.into_view()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn heading(&self, control: ControlRenderData<Self, HeadingData>) -> View {
|
fn heading(&self, control: ControlRenderData<Self, HeadingData>) -> View {
|
||||||
@ -392,7 +392,7 @@ impl FormStyle for GridFormStyle {
|
|||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="form_group form_grid" style:grid-column=format!("span {}", width)>
|
<div class="form_group form_grid" style:grid-column=format!("span {}", width)>
|
||||||
{*group.data}
|
{group.data}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
.into_view()
|
.into_view()
|
||||||
|
|||||||
@ -89,7 +89,6 @@ pub trait FormStyle: 'static {
|
|||||||
validation_state: Signal<Result<(), String>>,
|
validation_state: Signal<Result<(), String>>,
|
||||||
) -> View;
|
) -> View;
|
||||||
fn submit(&self, control: ControlRenderData<Self, SubmitData>) -> View;
|
fn submit(&self, control: ControlRenderData<Self, SubmitData>) -> View;
|
||||||
// TODO: test custom component
|
|
||||||
fn custom_component(&self, view: View) -> View;
|
fn custom_component(&self, view: View) -> View;
|
||||||
fn group(&self, group: ControlRenderData<Self, View>) -> View;
|
fn group(&self, group: ControlRenderData<Self, View>) -> View;
|
||||||
fn spacer(&self, control: ControlRenderData<Self, SpacerData>) -> View;
|
fn spacer(&self, control: ControlRenderData<Self, SpacerData>) -> View;
|
||||||
|
|||||||
Reference in New Issue
Block a user