Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinBonilla committed Apr 25, 2024
2 parents 0311f74 + 31bef94 commit ffb05b0
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MaterialDesignControls.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="2.8.1">
<id>Plugin.MaterialDesignControls</id>
<version>3.1.6</version>
<version>3.1.7</version>
<title>MaterialDesignControls Plugin for Xamarin Forms</title>
<authors>Horus</authors>
<owners>AgustinBonillaHorus</owners>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<StackLayout Padding="20,0,20,20"
Spacing="20">

<contentViews:InfoIndicatorView Message="MaterialSnackBar follows the latest guidelines of Material Design 3. Currently, it doesn't provide the popup/alert behavior, you could resolve it with Rg.Plugins.Popup or with a similar implementation." />
<contentViews:InfoIndicatorView Message="MaterialDialog follows the latest guidelines of Material Design 3. Currently, it doesn't provide the popup/alert behavior, you could resolve it with Rg.Plugins.Popup or with a similar implementation." />

<material3:MaterialDialog
HeadlineText="Basic dialog"
Expand All @@ -44,6 +44,30 @@

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

<material3:MaterialDialog
HeadlineText="Basic dialog with CustomContent"
SupportingText="Basic dialog with a CustomContent, an accept button and cancel button."
AcceptText="Accept"
AcceptCommand="{Binding AcceptWithCustomContentCommand}"
CancelText="Cancel"
CancelCommand="{Binding CancelCommand}"
CancelIsTextUnderlined="True"
AcceptCornerRadius="4">
<material3:MaterialDialog.CustomContent>
<material3:MaterialEntry
Text="{Binding InputText}"
Keyboard="Telephone"
LabelText="Phone number"
Placeholder="Enter your phone number"
ReturnType="Done"
HasBorder="True"
CornerRadius="10"
BorderWidth="1" />
</material3:MaterialDialog.CustomContent>
</material3:MaterialDialog>

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

<material3:MaterialDialog
HeadlineText="Quick selection dialog"
SupportingText="Quick selection dialog with a list of items."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
using System.Collections.Generic;
using Microsoft.Toolkit.Mvvm.ComponentModel;
using Plugin.MaterialDesignControls.Material3;
using System.ComponentModel;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.Shapes;
using System.Linq;

namespace ExampleMaterialDesignControls.ViewModels
Expand All @@ -18,6 +15,9 @@ public partial class MaterialDialogViewModel : BaseViewModel
[ObservableProperty]
private ObservableCollection<MaterialDialogItem> _itemsSourceColors;

[ObservableProperty]
private string _inputText;

public MaterialDialogViewModel()
{
ItemsSourceColors = new ObservableCollection<MaterialDialogItem>
Expand Down Expand Up @@ -109,6 +109,12 @@ private async Task AcceptTask()
await this.DisplayAlert(_controlTitle, "Accept button was tapped", "Ok");
}

[ICommand]
private async Task AcceptWithCustomContent()
{
await this.DisplayAlert(_controlTitle, $"Accept button was tapped: {InputText}", "Ok");
}

[ICommand]
private async Task Cancel()
{
Expand Down
37 changes: 37 additions & 0 deletions src/MaterialDesignControls/ControlsMaterial3/MaterialDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class MaterialDialog : ContentView

private StackLayout _optionsContainer;

private ContentView _customContentContainer;

#endregion Attributes

#region Properties
Expand Down Expand Up @@ -126,6 +128,15 @@ public LayoutOptions ButtonsAlignment
set { SetValue(ButtonsAlignmentProperty, value); }
}

public static readonly BindableProperty CustomContentProperty =
BindableProperty.Create(nameof(CustomContent), typeof(View), typeof(MaterialDialog), defaultValue: null, propertyChanged: OnCustomContentChanged);

public View CustomContent
{
get { return (View)GetValue(CustomContentProperty); }
set { SetValue(CustomContentProperty, value); }
}

#endregion Properties

#region Headline
Expand Down Expand Up @@ -340,6 +351,15 @@ public float CancelCornerRadius
set { SetValue(CancelCornerRadiusProperty, value); }
}

public static readonly BindableProperty CancelIsTextUnderlinedProperty =
BindableProperty.Create(nameof(CancelIsTextUnderlined), typeof(bool), typeof(MaterialDialog), defaultValue: false);

public bool CancelIsTextUnderlined
{
get { return (bool)GetValue(CancelIsTextUnderlinedProperty); }
set { SetValue(CancelIsTextUnderlinedProperty, value); }
}

#endregion CancelButton

#region AcceptButton
Expand Down Expand Up @@ -753,6 +773,10 @@ protected override void OnPropertyChanged([CallerMemberName] string propertyName
_cancelBtn.CornerRadius = CancelCornerRadius;
break;

case nameof(CancelIsTextUnderlined):
_cancelBtn.IsTextUnderlined = CancelIsTextUnderlined;
break;

case nameof(AcceptText):
_acceptBtn.Text = AcceptText;
break;
Expand Down Expand Up @@ -892,6 +916,12 @@ private void Initialize()
};
container.Children.Add(_supportingLbl);

_customContentContainer = new ContentView
{
IsVisible = false
};
container.Children.Add(_customContentContainer);

var stackLayoutOptions = new StackLayout
{
Spacing = 0,
Expand Down Expand Up @@ -1102,6 +1132,13 @@ private void OnSearchCommand()
});
}

private static void OnCustomContentChanged(BindableObject bindable, object oldValue, object newValue)
{
var control = (MaterialDialog)bindable;
control._customContentContainer.Content = (View)newValue;
control._customContentContainer.IsVisible = true;
}

#endregion Methods
}
}

0 comments on commit ffb05b0

Please sign in to comment.