enisn / UraniumUI

Uranium is a Free & Open-Source UI Kit for MAUI.
Apache License 2.0
985 stars 110 forks source link

Inner Control Validations #608

Open aliEsmaelFard opened 2 months ago

aliEsmaelFard commented 2 months ago

validations in child inner Control seems not working

<FormView>
<StackLayout> 
  <material:CheckBox Text="I Accept Terms &amp; Conditions"
                        IsChecked="{Binding IsTermsAndConditionsAccepted}">
        <validation:RequiredValidation />
    </material:CheckBox>
</StackLayout> 
</FormView> 

Is there a way to make CheckBox Validations work?

enisn commented 2 months ago

It's triggered when form is submitted: checkbox-validation-trigger

aliEsmaelFard commented 2 months ago

thats just a example, this is not working, real example:

  //label
     Label label = new Label()
     {
         Text = model.Text,

     };

     //radio
     model.ListProp = new List<string> { "Yes", "No", "N/A" };
     RadioButtonGroupView radioGroup = new RadioButtonGroupView();
     radioGroup = MyUtils.DefineViewVals<RadioButtonGroupView>(radioGroup, model);
     for (int i = 0; i < model.ListProp.Count; i++)
     {
         UraniumUI.Material.Controls.RadioButton radioButton = new UraniumUI.Material.Controls.RadioButton()
         {
             Text = model.ListProp[i],
         };
         radioGroup.Add(radioButton);
     }
     radioGroup.Orientation = StackOrientation.Horizontal;

     //remark
     TextField textField = new TextField()
     {
         Title = "Remarks"
     };

     textField.Validations.AddRange(MyUtils.DefineViewVals<TextField>(textField, model).Validations);

     VerticalStackLayout vLayout = new VerticalStackLayout()
     {
         Spacing = 16,
         Padding = 8,

         Children = { label, radioGroup, textField }
     };

     Frame frame = new Frame()
     {
         CornerRadius = 4,
         BackgroundColor = Colors.LightCyan,
         ClassId = model.Id
     };
     frame.Content = vLayout;
     formView.Add(frame);
enisn commented 2 months ago

For now, I can just add new properties to validations to handle these operations. I'll need to create a new validation logic and drop the InputKit dependency in near future.