Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinBonilla committed Jan 11, 2024
2 parents 4011932 + e670a95 commit 36e33c7
Show file tree
Hide file tree
Showing 12 changed files with 395 additions and 132 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.2</version>
<version>3.1.3</version>
<title>MaterialDesignControls Plugin for Xamarin Forms</title>
<authors>Horus</authors>
<owners>AgustinBonillaHorus</owners>
Expand Down
20 changes: 17 additions & 3 deletions MaterialDialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,18 @@ This property is to set the corner radius of cancel button.
<br/>

### Property CancelCommand:
This property is to the command of the cancel button.
This property is to set the command of the cancel button.
<br/>

### Property CancelIsBusy:
This property is to show a busy indicator in the cancel button when a command is running.
<br/>

### Property AcceptIsEnabled:
### Property CancelIsVisible:
This property is to set if the cancel button is visible or hidden.
<br/>

### Property CancelIsEnabled:
This property is to set if the cancel button is enabled or disabled.
<br/>

Expand Down Expand Up @@ -174,13 +178,18 @@ This property is to set the corner radius of accept button.
<br/>

### Property AcceptCommand:
This property is to the command of the accept button.
This property is to set the command of the accept button.
If the ItemSource property has a bound list, this command will receive as a parameter the selected item if it is a single selection or a list of selected items if it is multiple selection (AllowMultiselect).
<br/>

### Property AcceptIsBusy:
This property is to show a busy indicator in the accept button when a command is running.
<br/>

### Property AcceptIsVisible:
This property is to set if the accept button is visible or hidden.
<br/>

### Property AcceptIsEnabled:
This property is to set if the accept button is enabled or disabled.
<br/>
Expand Down Expand Up @@ -225,6 +234,11 @@ This property is to the font size of the search text.
This property is to the font family of the search text.
<br/>

### Property QuickSelectionCommand:
This property is to set a quick selection command which will be invoked as soon as the user selects any item from the list.
This command will receive as a parameter the selected item.
<br/>

### Property AllowMultiselect:
This property is to set if the control will allow multiple selection of items or not.
<br/>
Expand Down
24 changes: 20 additions & 4 deletions MaterialNavigationDrawerControl.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ This property is to set the section label text font size.
This property is to set the section label text font family.
<br/>

### Property SectionDividerIsVisible:
This property is to set if the section's divider is visible or hidden.
<br/>

### Property ItemDividerIsVisible:
This property is to set if the item's divider is visible or hidden.
<br/>

### Property DividerColor:
This property is to set the divider color.
<br/>
Expand Down Expand Up @@ -98,15 +106,23 @@ Its definition is:
- Text (string) : Text showed
- BadgeText (string) : Text showed in the badge
- Section (string) : This property is to dive the items in sections
- SelectedIcon (string): Icon used when item is selected
- CustomSelectedIcon (view): Custom view used the item is selected
- UnselectedIcon (string): Icon used when item is Unselected
- CustomUnselectedIcon (view): Custom view used when item is Unselected
- SelectedLeadingIcon (string): Leading icon used when item is selected
- CustomSelectedLeadingIcon (view): Custom leading view used the item is selected
- UnselectedLeadingIcon (string): Leading icon used when item is Unselected
- CustomUnselectedLeadingIcon (view): Custom leading view used when item is Unselected
- SelectedTrailingIcon (string): Trailing icon used when item is selected
- CustomSelectedTrailingIcon (view): Custom trailing view used the item is selected
- UnselectedTrailingIcon (string): Trailing icon used when item is Unselected
- CustomUnselectedTrailingIcon (view): Custom trailing view used when item is Unselected
- IsSelected (bool) : by default you can select an item
- ShowActivityIndicator (bool) : show the activity indicator when the item is selected. By default is true.
- IsEnabled (bool) : enable or disabled the item. by default is true.
<br/>

### Property ItemHeightRequest:
This property is to set the height request of each item.
<br/>

### Property Command
This property is to bind on the viewmodel.
<br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@
<material3:MaterialBottomSheet
x:Name="materialBottomSheet4"
Grid.Row="1"
MaximumContainerHeightRequest="300">
MaximumContainerHeightRequest="300"
Opened="materialBottomSheet4_Opened"
Closed="materialBottomSheet4_Closed">
<material3:MaterialBottomSheet.Content>
<StackLayout
Padding="22,44,22,0">
Expand Down Expand Up @@ -205,7 +207,7 @@
<material3:MaterialButton
ButtonType="Text"
Command="{Binding CloseBottomSheetCommand}"
CommandParameter="materialBottomSheet3"
CommandParameter="materialBottomSheet4"
Text="Close" />
</StackLayout>
</material3:MaterialBottomSheet.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,15 @@ public MaterialBottomSheetPage(bool isModalPage = false)
CloseBottomSheetControl = async (controlName) => await this.FindByName<MaterialBottomSheet>(controlName).Close()
};
}

void materialBottomSheet4_Opened(System.Object sender, System.EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Opened!!!!!");
}

void materialBottomSheet4_Closed(System.Object sender, System.EventArgs e)
{
System.Diagnostics.Debug.WriteLine("Closed!!!!!");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
HorizontalTextAlignment="Center"
Text="Sample" />

<material3:MaterialButton
Text="Change ItemsSource"
Command="{Binding ChangeItemsSourceCommand}" />

<material3:MaterialNavigationDrawer
Headline="Mail"
Command="{Binding TestCommand}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using FFImageLoading.Svg.Forms;
using Microsoft.Toolkit.Mvvm.Input;
using Plugin.MaterialDesignControls.Material3;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows.Input;
using Xamarin.Forms;
using System.Threading.Tasks;

namespace ExampleMaterialDesignControls.ViewModels
{
public class MaterialNavigationDrawerViewModel : BaseViewModel
public partial class MaterialNavigationDrawerViewModel : BaseViewModel
{
private bool _includeAllItems = true;

private ObservableCollection<MaterialNavigationDrawerItem> _items;

public ObservableCollection<MaterialNavigationDrawerItem> Items
Expand All @@ -19,76 +20,103 @@ public ObservableCollection<MaterialNavigationDrawerItem> Items

public MaterialNavigationDrawerViewModel()
{
Items = new ObservableCollection<MaterialNavigationDrawerItem>
LoadItems(_includeAllItems);
}

private void LoadItems(bool includeAllItems)
{
var list = new List<MaterialNavigationDrawerItem>
{
new MaterialNavigationDrawerItem
{
SelectedIcon = "email.png",
UnselectedIcon = "email.png",
SelectedLeadingIcon = "email.png",
UnselectedLeadingIcon = "email.png",
SelectedTrailingIcon = "arrow_drop_down.png",
UnselectedTrailingIcon = "arrow_drop_down.png",
Text = "Inbox",
BadgeText = "24"
},
new MaterialNavigationDrawerItem
{
SelectedIcon = "email.png",
UnselectedIcon = "email.png",
SelectedLeadingIcon = "email.png",
UnselectedLeadingIcon = "email.png",
Text = "Outbox",
BadgeText = "100+"
},
new MaterialNavigationDrawerItem
{
Text = "Favorites (Different icons)",
SelectedIcon = "starSelected.png",
UnselectedIcon = "starUnselected.png",
SelectedLeadingIcon = "starSelected.png",
UnselectedLeadingIcon = "starUnselected.png",
},
new MaterialNavigationDrawerItem
{
SelectedIcon = "delete.png",
UnselectedIcon = "delete.png",
SelectedLeadingIcon = "delete.png",
UnselectedLeadingIcon = "delete.png",
Text = "Trash",
},
new MaterialNavigationDrawerItem
{
Section = "Other samples",
SelectedIcon = "Payment.png",
UnselectedIcon = "Payment.png",
SelectedLeadingIcon = "Payment.png",
UnselectedLeadingIcon = "Payment.png",
Text = "Selected by default",
IsSelected = true
},
new MaterialNavigationDrawerItem
{
Section = "Other samples",
SelectedIcon = "Payment.png",
UnselectedIcon = "Payment.png",
Text = "Disabled",
IsEnabled = false
},
new MaterialNavigationDrawerItem
{
Section = "Other samples",
SelectedIcon = "Payment.png",
UnselectedIcon = "Payment.png",
Text = "Don't show active indicator",
ShowActiveIndicator = false
},
new MaterialNavigationDrawerItem
{
Section = "Other samples",
CustomSelectedIcon = new FFImageLoading.Svg.Forms.SvgCachedImage { Source = "resource://ExampleMaterialDesignControls.Resources.Svg.volume_blue.svg" },
CustomUnselectedIcon = new FFImageLoading.Svg.Forms.SvgCachedImage { Source = "resource://ExampleMaterialDesignControls.Resources.Svg.volume.svg" },
Text = "Custom icon",
},
new MaterialNavigationDrawerItem
{
Section = "Other samples",
Text = "Without icon",
}

};

if (includeAllItems)
{
list.AddRange(new List<MaterialNavigationDrawerItem>
{
new MaterialNavigationDrawerItem
{
Section = "Other samples",
SelectedLeadingIcon = "Payment.png",
UnselectedLeadingIcon = "Payment.png",
Text = "Disabled",
IsEnabled = false
},
new MaterialNavigationDrawerItem
{
Section = "Other samples",
SelectedLeadingIcon = "Payment.png",
UnselectedLeadingIcon = "Payment.png",
Text = "Don't show active indicator",
ShowActiveIndicator = false
},
new MaterialNavigationDrawerItem
{
Section = "Other samples",
CustomSelectedLeadingIcon = new FFImageLoading.Svg.Forms.SvgCachedImage { Source = "resource://ExampleMaterialDesignControls.Resources.Svg.volume_blue.svg" },
CustomUnselectedLeadingIcon = new FFImageLoading.Svg.Forms.SvgCachedImage { Source = "resource://ExampleMaterialDesignControls.Resources.Svg.volume.svg" },
CustomSelectedTrailingIcon = new FFImageLoading.Svg.Forms.SvgCachedImage { Source = "resource://ExampleMaterialDesignControls.Resources.Svg.volume_blue.svg" },
CustomUnselectedTrailingIcon = new FFImageLoading.Svg.Forms.SvgCachedImage { Source = "resource://ExampleMaterialDesignControls.Resources.Svg.volume.svg" },
Text = "Custom icon",
},
new MaterialNavigationDrawerItem
{
Section = "Other samples",
Text = "Without icon",
}
});
}

Items = new ObservableCollection<MaterialNavigationDrawerItem>(list);
}

[ICommand]
private async Task Test(MaterialNavigationDrawerItem selectedItem)
{
await this.DisplayAlert.Invoke("Navigation Item", $"{selectedItem}", "Ok");
}

public ICommand TestCommand => new Command(async (obj) =>
[ICommand]
private async Task ChangeItemsSource()
{
await this.DisplayAlert.Invoke("Navigation Item", $"{obj}", "Ok");
});
_includeAllItems = !_includeAllItems;
LoadItems(_includeAllItems);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public bool DismissWhenScrimIsTapped
set { SetValue(DismissWhenScrimIsTappedProperty, value); }
}

public event EventHandler Opened;

public event EventHandler Closed;

#endregion Bindable properties

#region Constructors
Expand Down Expand Up @@ -432,14 +436,22 @@ public async Task Open()
{
try
{
IsVisible = true;
await Task.WhenAll
(
_scrimBoxView.FadeTo(ScrimOpacity, length: (uint)AnimationDuration),
_sheetView.TranslateTo(0, _openPosition, length: (uint)AnimationDuration, easing: Easing.SinIn)
);

var raiseOpened = !IsOpened;

IsOpened = true;

if (raiseOpened)
{
Opened?.Invoke(this, null);
}

InputTransparent = _scrimBoxView.InputTransparent = false;
}
catch (Exception ex)
Expand All @@ -457,9 +469,17 @@ await Task.WhenAll
_scrimBoxView.FadeTo(0, length: (uint)AnimationDuration),
_containerView.Content.TranslateTo(x: 0, y: TranslationYClosed, length: (uint)AnimationDuration, easing: Easing.SinIn)
);
IsVisible = false;

var raiseClosed = IsOpened;

IsOpened = false;

if (raiseClosed)
{
Closed?.Invoke(this, null);
}

InputTransparent = _scrimBoxView.InputTransparent = true;
}
catch (Exception ex)
Expand Down
Loading

0 comments on commit 36e33c7

Please sign in to comment.