Skip to content

Commit

Permalink
Fix issue and add improvements to MaterialDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinBonilla committed Nov 26, 2023
1 parent 9bbd409 commit e1b66cb
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 10 deletions.
12 changes: 12 additions & 0 deletions MaterialDialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ This property is to the font size of the cancel button.
This property is to the font family of the cancel button.
<br/>

### Property CancelCornerRadius:
This property is to set the corner radius of cancel button.
<br/>

### Property CancelCommand:
This property is to the command of the cancel button.
<br/>
Expand Down Expand Up @@ -165,6 +169,10 @@ This property is to the font size of the accept button.
This property is to the font family of the accept button.
<br/>

### Property AcceptCornerRadius:
This property is to set the corner radius of accept button.
<br/>

### Property AcceptCommand:
This property is to the command of the accept button.
<br/>
Expand Down Expand Up @@ -264,4 +272,8 @@ This property is to set the icon when is unchecked. It is a DataTemplate propert

### Property ItemCheckboxSize
This property is to set the size of the checkbox.
<br/>

### Property ItemCheckboxSpacing
This property is to set the spacing of the checkbox.
<br/>
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@

<material3:MaterialDialog
HeadlineText="Quick selection dialog"
SupportingText="Quick selection dialog with a list of items and a Search."
SupportingText="Quick multiple-selection dialog with a list of items and a Search."
AcceptText="Accept"
AcceptCommand="{Binding AcceptSelectionCommand}"
AcceptCommand="{Binding AcceptMultipleSelectionCommand}"
CancelText="Cancel"
CancelCommand="{Binding CancelCommand}"
ShowDivider="True"
ItemsSource="{Binding ItemsSourceColors}"
ShowSearch="True"
SearchPlaceholder="Write text to search"
HeightRequest="500" />
HeightRequest="500"
AllowMultiselect="True" />

<material3:MaterialDivider Margin="0,10" />

Expand Down Expand Up @@ -100,15 +101,18 @@
DividerColor="DarkBlue"
CancelTextColor="DarkBlue"
CancelFontSize="12"
AcceptTextColor="DarkBlue"
AcceptBackgroundColor="Transparent"
CancelCornerRadius="4"
AcceptTextColor="LightSkyBlue"
AcceptBackgroundColor="DarkBlue"
AcceptFontSize="16"
AcceptCornerRadius="4"
SearchTextColor="DarkBlue"
SearchBackgroundColor="LightSkyBlue"
SearchTextAlignment="Center"
ItemTextFontSize="14"
ItemTextColor="DarkBlue"
HeightRequest="500">
HeightRequest="500"
ItemCheckboxSpacing="0">
<material3:MaterialDialog.CustomIcon>
<ffimageloadingsvg:SvgCachedImage Source="resource://ExampleMaterialDesignControls.Resources.Svg.ic_dialog.svg" />
</material3:MaterialDialog.CustomIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ private void Initialize()
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
WidthRequest = 40,
HeightRequest = 40
HeightRequest = 40,
MinimumWidthRequest = 40,
MinimumHeightRequest = 40
};

_chk = new CustomCheckBox()
Expand Down Expand Up @@ -204,6 +206,8 @@ private void Initialize()
HorizontalOptions = LayoutOptions.Center,
WidthRequest = 40,
HeightRequest = 40,
MinimumWidthRequest = 40,
MinimumHeightRequest = 40,
IsVisible = false
};

Expand Down Expand Up @@ -232,6 +236,8 @@ private void Initialize()
HorizontalOptions = LayoutOptions.Center,
WidthRequest = 40,
HeightRequest = 40,
MinimumWidthRequest = 40,
MinimumHeightRequest = 40,
IsVisible = false
};

Expand Down
44 changes: 41 additions & 3 deletions src/MaterialDesignControls/ControlsMaterial3/MaterialDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ public bool CancelIsBusy
set { SetValue(CancelIsBusyProperty, value); }
}

public static readonly BindableProperty CancelCornerRadiusProperty =
BindableProperty.Create(nameof(CancelCornerRadius), typeof(float), typeof(MaterialDialog), defaultValue: 20f);

public float CancelCornerRadius
{
get { return (float)GetValue(CancelCornerRadiusProperty); }
set { SetValue(CancelCornerRadiusProperty, value); }
}

#endregion CancelButton

#region AcceptButton
Expand Down Expand Up @@ -389,6 +398,15 @@ public bool AcceptIsBusy
set { SetValue(AcceptIsBusyProperty, value); }
}

public static readonly BindableProperty AcceptCornerRadiusProperty =
BindableProperty.Create(nameof(AcceptCornerRadius), typeof(float), typeof(MaterialDialog), defaultValue: 20f);

public float AcceptCornerRadius
{
get { return (float)GetValue(AcceptCornerRadiusProperty); }
set { SetValue(AcceptCornerRadiusProperty, value); }
}

#endregion AcceptButton

public static readonly BindableProperty ButtonsAlignmentProperty =
Expand Down Expand Up @@ -568,6 +586,15 @@ public double ItemCheckboxSize
set { SetValue(ItemCheckboxSizeProperty, value); }
}

public static readonly BindableProperty ItemCheckboxSpacingProperty =
BindableProperty.Create(nameof(ItemCheckboxSpacing), typeof(double), typeof(MaterialDialog), defaultValue: 10.0);

public double ItemCheckboxSpacing
{
get { return (double)GetValue(ItemCheckboxSpacingProperty); }
set { SetValue(ItemCheckboxSpacingProperty, value); }
}

#endregion Items

#region Constructor
Expand Down Expand Up @@ -691,6 +718,10 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName
_cancelBtn.IsBusy = CancelIsBusy;
break;

case nameof(CancelCornerRadius):
_cancelBtn.CornerRadius = CancelCornerRadius;
break;

case nameof(AcceptText):
_acceptBtn.Text = AcceptText;
break;
Expand Down Expand Up @@ -719,6 +750,10 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName
_acceptBtn.IsBusy = AcceptIsBusy;
break;

case nameof(AcceptCornerRadius):
_acceptBtn.CornerRadius = AcceptCornerRadius;
break;

case nameof(CancelCommand):
_cancelBtn.Command = CancelCommand;
break;
Expand Down Expand Up @@ -890,7 +925,8 @@ private void Initialize()
BackgroundColor = CancelBackgroundColor,
Command = CancelCommand,
IsVisible = !string.IsNullOrWhiteSpace(CancelText),
MinimumWidthRequest = 80
MinimumWidthRequest = 80,
CornerRadius = CancelCornerRadius
};

_acceptBtn = new MaterialButton
Expand All @@ -903,7 +939,8 @@ private void Initialize()
BackgroundColor = AcceptBackgroundColor,
Margin = new Thickness(0),
Command = AcceptCommand,
MinimumWidthRequest = 80
MinimumWidthRequest = 80,
CornerRadius = AcceptCornerRadius
};

_btnsContainer.Children.Add(_cancelBtn);
Expand All @@ -913,7 +950,6 @@ private void Initialize()

Content = _mainContainer;

//Xamarin.Forms.PlatformConfiguration.AndroidSpecific.VisualElement.SetElevation(this, 0);
initialized = true;
}
}
Expand Down Expand Up @@ -952,6 +988,8 @@ private void RefreshItemList(IEnumerable<MaterialDialogItem> list)
materialCheckbox.CustomSelectedIcon = ItemCheckboxCustomSelectedIcon;
materialCheckbox.CustomUnselectedIcon = ItemCheckboxCustomUnselectedIcon;
materialCheckbox.IsChecked = item.IsSelected;
materialCheckbox.Spacing = ItemCheckboxSpacing;
materialCheckbox.IsRadioButtonStyle = !AllowMultiselect;
_optionsContainer.Children.Add(materialCheckbox);
}

Expand Down

0 comments on commit e1b66cb

Please sign in to comment.