generated from mitchell/rust_template
Various improvements #26
@ -27,7 +27,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
||||
let control = builder(button_builder);
|
||||
|
||||
let render_data = ControlRenderData {
|
||||
data: Box::new(control.data),
|
||||
data: control.data,
|
||||
styles: control.styles,
|
||||
};
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
||||
.unzip();
|
||||
|
||||
let view = fs.group(super::ControlRenderData {
|
||||
data: Box::new(views.collect_view()),
|
||||
data: views.collect_view(),
|
||||
styles: group_builder.styles,
|
||||
});
|
||||
let validation_cb = move || {
|
||||
|
||||
@ -16,7 +16,6 @@ impl VanityControlData for HeadingData {
|
||||
fs.heading(control)
|
||||
}
|
||||
}
|
||||
// TODO: impl GetterVanityControl
|
||||
|
||||
impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
||||
pub fn heading(
|
||||
|
||||
@ -70,9 +70,8 @@ pub trait ValidatedControlData: ControlData {}
|
||||
|
||||
/// The data needed to render a interactive control of type `C`.
|
||||
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 data: 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> {
|
||||
BuiltVanityControlData {
|
||||
render_data: ControlRenderData {
|
||||
data: Box::new(self.data),
|
||||
data: self.data,
|
||||
styles: self.style_attributes,
|
||||
},
|
||||
getter: self.getter,
|
||||
@ -209,7 +208,7 @@ impl<FD: FormToolData, FS: FormStyle, C: ControlData, FDT> ControlBuilder<FD, FS
|
||||
|
||||
Ok(BuiltControlData {
|
||||
render_data: ControlRenderData {
|
||||
data: Box::new(self.data),
|
||||
data: self.data,
|
||||
styles: self.style_attributes,
|
||||
},
|
||||
getter,
|
||||
|
||||
@ -232,7 +232,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
||||
.unzip();
|
||||
|
||||
let elements = fs.form_frame(ControlRenderData {
|
||||
data: Box::new(views.into_view()),
|
||||
data: views.into_view(),
|
||||
styles: self.styles,
|
||||
});
|
||||
|
||||
@ -271,7 +271,7 @@ impl<FD: FormToolData, FS: FormStyle> FormBuilder<FD, FS> {
|
||||
.unzip();
|
||||
|
||||
let elements = fs.form_frame(ControlRenderData {
|
||||
data: Box::new(views.into_view()),
|
||||
data: views.into_view(),
|
||||
styles: self.styles,
|
||||
});
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ impl FormStyle for GridFormStyle {
|
||||
type StylingAttributes = GridFormStylingAttributes;
|
||||
|
||||
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 {
|
||||
@ -392,7 +392,7 @@ impl FormStyle for GridFormStyle {
|
||||
|
||||
view! {
|
||||
<div class="form_group form_grid" style:grid-column=format!("span {}", width)>
|
||||
{*group.data}
|
||||
{group.data}
|
||||
</div>
|
||||
}
|
||||
.into_view()
|
||||
|
||||
@ -89,7 +89,6 @@ pub trait FormStyle: 'static {
|
||||
validation_state: Signal<Result<(), String>>,
|
||||
) -> View;
|
||||
fn submit(&self, control: ControlRenderData<Self, SubmitData>) -> View;
|
||||
// TODO: test custom component
|
||||
fn custom_component(&self, view: View) -> View;
|
||||
fn group(&self, group: ControlRenderData<Self, View>) -> View;
|
||||
fn spacer(&self, control: ControlRenderData<Self, SpacerData>) -> View;
|
||||
|
||||
Reference in New Issue
Block a user