Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
AgustinBonilla committed Dec 6, 2023
2 parents ed192fe + 1c0dcbf commit a4defc1
Show file tree
Hide file tree
Showing 30 changed files with 1,065 additions and 119 deletions.
112 changes: 112 additions & 0 deletions MaterialBottomSheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# MaterialBottomSheet
MaterialBottomSheet shows secondary content anchored to the bottom of the screen.
<br/>
[View Material Design documentation](https://m3.material.io/components/bottom-sheets/overview)

## Screenshot
<img src="screenshots/bottomsheet.gif" width="300">

## Example
```XML
<material3:MaterialBottomSheet
x:Name="materialBottomSheet">
<material3:MaterialBottomSheet.Content>
<StackLayout>
<material3:MaterialLabel
Text="Secondary content anchored to the bottom of the screen" />
</StackLayout>
</material3:MaterialBottomSheet.Content>
</material3:MaterialBottomSheet>
```

## Documentation

### Method Open:
Method used to open/show the bottom sheet.
```C#
await materialBottomSheet.Open();
```
<br/>

### Method Close:
Method used to close/hide the bottom sheet.
```C#
await materialBottomSheet.Close();
```
<br/>

### Property BackgroundColor:
Gets or sets the container background color.
<br/>

### Property CornerRadius:
Gets or sets the container corner radius.
<br/>

### Property Content:
Gets or sets the content that will be displayed inside the container.
<br/>

### Property ContentVerticalOptions:
Gets or sets the vertical options to the container's content. By default it has the **Start** value.
<br/>

### Property ContainerHeight:
Gets or sets the container height. By default it has a **-1** and the height of the container adjusts to the container's content. This property should only be used if a fixed height is needed for the container.
<br/>

### Property MaximumContainerHeightRequest:
Gets or sets the maximum height to which the container can expand. It only works when the ContainerHeight property is not set and the container height is dynamic.
<br/>

### Property IsOpened:
Gets a boolean that indicates whether the container is open or not. It is a read-only binding property.
<br/>

### Property ScrimColor:
Gets or sets the scrim color.
<br/>

### Property ScrimOpacity:
Gets or sets the scrim opacity/transparency.
<br/>

### Property DragHandleColor:
Gets or sets the drag handle color.
<br/>

### Property DragHandleWidth:
Gets or sets the drag handle width.
<br/>

### Property DragHandleHeight:
Gets or sets the drag handle height.
<br/>

### Property DragHandleIsVisible:
Gets or sets if the the drag handle is visible.
<br/>

### Property AnimationDuration:
Gets or sets the amount of time in milliseconds that will be used to animate the container when it is opening or closing.
<br/>

### Property DismissThreshold:
Gets or sets the threshold point where the container will be dismissed if the user is swiping to hide it. This property accepts values between 0 and 1. By default it has a **0.4**.
<br/>

### Property IsSwipeEnabled:
Gets or sets if the user will be able to swipe the container to dismiss/hide it.
<br/>

### Property DismissWhenScrimIsTapped:
Gets or sets if the user will be able to tap over the scrim to dismiss/hide the container.
<br/>

## Best Practices and Considerations

> ⚠️ Avoid utilizing the **Margin** property within the root element of the MaterialBottomSheet's content, as its usage may result in errors or unexpected behaviors.
> ⚠️ If the MaterialBottomSheet will be used within a tabbed view (TabbedPage), setting a BackgroundColor for the TabBar is advisable, as it may cause unexpected behaviors on iOS.
Example of how to set the BackgroundColor of the TabBar:
UITabBar.Appearance.BackgroundColor = UIColor.White;
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.0.5</version>
<version>3.1.0</version>
<title>MaterialDesignControls Plugin for Xamarin Forms</title>
<authors>Horus</authors>
<owners>AgustinBonillaHorus</owners>
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ We're developing the next version of the plugin for .NET MAUI, bringing you exci
- [MaterialSnackBar](#materialsnackbar)
- [MaterialDialog](#materialdialog)
- [MaterialCard](#materialcard)
- [MaterialBottomSheet](#materialbottomsheet)
- [Effects](#effects)
- [TouchAndPressEffect](#touchandpresseffect)
- [Sample app](#sample-app)
Expand Down Expand Up @@ -373,6 +374,15 @@ MaterialCard display content and actions about a single subject.

---

### MaterialBottomSheet
MaterialBottomSheet shows secondary content anchored to the bottom of the screen.
<br/>
<img src="screenshots/bottomsheet_preview.png" width="300">
<br/>
[View documentation](MaterialBottomSheet.md)

---

<br/>

## Effects
Expand Down
3 changes: 3 additions & 0 deletions example/ExampleMaterialDesignControls.iOS/AppDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public override bool FinishedLaunching(UIApplication app, NSDictionary options)

Plugin.MaterialDesignControls.iOS.Renderer.Init();

// MaterialBottomSheet requires the use of a background color in the TabBar
UITabBar.Appearance.BackgroundColor = UIColor.White;

LoadApplication(new App());

CachedImageRenderer.Init();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ExampleMaterialDesignControls.Pages.MaterialBottomSheetPage"
xmlns:ffimageloadingsvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
xmlns:contentViews="clr-namespace:ExampleMaterialDesignControls.ContentViews"
xmlns:ios="clr-namespace:Xamarin.Forms.PlatformConfiguration.iOSSpecific;assembly=Xamarin.Forms.Core"
xmlns:material3="clr-namespace:Plugin.MaterialDesignControls.Material3;assembly=Plugin.MaterialDesignControls"
ios:Page.UseSafeArea="True"
BackgroundColor="White"
NavigationPage.HasNavigationBar="false">
<ContentPage.Content>
<Grid
RowDefinitions="Auto,*"
RowSpacing="0">
<material3:MaterialTopAppBar
Headline="MaterialBottomSheet"
LeadingIconCommand="{Binding BackCommand}">
<material3:MaterialTopAppBar.CustomLeadingIcon>
<ffimageloadingsvg:SvgCachedImage
Source="resource://ExampleMaterialDesignControls.Resources.Svg.ic_back_b.svg" />
</material3:MaterialTopAppBar.CustomLeadingIcon>
</material3:MaterialTopAppBar>

<ScrollView
Grid.Row="1"
VerticalScrollBarVisibility="Never">
<StackLayout
Padding="20,0,20,20"
Spacing="10">

<contentViews:InfoIndicatorView
Message="MaterialBottomSheet follows the latest guidelines of Material Design 3" />

<material3:MaterialDivider />

<material3:MaterialLabel
Text="MaterialBottomSheet samples:"
HorizontalTextAlignment="Center" />

<material3:MaterialButton
ButtonType="Text"
Command="{Binding OpenBottomSheetCommand}"
CommandParameter="materialBottomSheet1"
Text="Dynamic size" />

<material3:MaterialButton
ButtonType="Text"
Command="{Binding OpenBottomSheetCommand}"
CommandParameter="materialBottomSheet2"
Text="Fixed size" />

<material3:MaterialButton
ButtonType="Text"
Command="{Binding OpenBottomSheetCommand}"
CommandParameter="materialBottomSheet3"
Text="Dynamic size and MaximumContainerHeightRequest" />

<material3:MaterialDivider />

<material3:MaterialButton
ButtonType="Text"
Command="{Binding OpenInModalPageCommand}"
Text="Open in modal page" />

</StackLayout>
</ScrollView>

<!--Dynamic size-->
<material3:MaterialBottomSheet
x:Name="materialBottomSheet1"
Grid.Row="1">
<material3:MaterialBottomSheet.Content>
<StackLayout
Spacing="10"
Padding="22,44,22,12">
<material3:MaterialLabel
FontFamily="{StaticResource BoldFont}"
FontSize="{StaticResource H4FontSize}"
Text="Material Design"
TextColor="{StaticResource GradientColor1}" />
<material3:MaterialLabel
FontAttributes="Bold"
FontFamily="{StaticResource SemiBoldFont}"
FontSize="{StaticResource H5FontSize}"
Text="Plugin for Xamarin Forms"
TextColor="{StaticResource BlackColor}" />
<material3:MaterialLabel
FontSize="{StaticResource Body2FontSize}"
Text="Material Design is an adaptable system of guidelines, components, and tools that support the best practices of user interface design. Backed by open-source code, Material Design streamlines collaboration between designers and developers, and helps teams quickly build beautiful products."
TextColor="{StaticResource DarkGrayColor}" />
</StackLayout>
</material3:MaterialBottomSheet.Content>
</material3:MaterialBottomSheet>

<!--Fixed size-->
<material3:MaterialBottomSheet
x:Name="materialBottomSheet2"
Grid.Row="1"
ContainerHeight="400"
ContentVerticalOptions="Center">
<material3:MaterialBottomSheet.Content>
<StackLayout
Spacing="10"
Padding="22,44,22,12">
<material3:MaterialLabel
FontFamily="{StaticResource BoldFont}"
FontSize="{StaticResource H4FontSize}"
Text="Material Design"
TextColor="{StaticResource GradientColor1}" />
<material3:MaterialLabel
FontAttributes="Bold"
FontFamily="{StaticResource SemiBoldFont}"
FontSize="{StaticResource H5FontSize}"
Text="Plugin for Xamarin Forms"
TextColor="{StaticResource BlackColor}" />
<material3:MaterialLabel
FontSize="{StaticResource Body2FontSize}"
Text="Material Design is an adaptable system of guidelines, components, and tools that support the best practices of user interface design. Backed by open-source code, Material Design streamlines collaboration between designers and developers, and helps teams quickly build beautiful products."
TextColor="{StaticResource DarkGrayColor}" />
</StackLayout>
</material3:MaterialBottomSheet.Content>
</material3:MaterialBottomSheet>

<!--Dynamic size with MaximumContainerHeightRequest-->
<material3:MaterialBottomSheet
x:Name="materialBottomSheet3"
Grid.Row="1"
MaximumContainerHeightRequest="300">
<material3:MaterialBottomSheet.Content>
<StackLayout
Padding="22,44,22,0">
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="MaterialBottomSheet sample" />
<ScrollView>
<StackLayout>
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="1" />
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="2" />
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="3" />
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="4" />
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="5" />
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="6" />
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="7" />
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="8" />
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="9" />
<material3:MaterialLabel
HorizontalTextAlignment="Center"
Text="10" />
</StackLayout>
</ScrollView>
<material3:MaterialButton
ButtonType="Text"
Command="{Binding CloseBottomSheetCommand}"
CommandParameter="materialBottomSheet3"
Text="Close" />
</StackLayout>
</material3:MaterialBottomSheet.Content>
</material3:MaterialBottomSheet>

</Grid>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using ExampleMaterialDesignControls.ViewModels;
using Plugin.MaterialDesignControls.Material3;
using Xamarin.Forms;

namespace ExampleMaterialDesignControls.Pages
{
public partial class MaterialBottomSheetPage : ContentPage
{
public MaterialBottomSheetPage(bool isModalPage = false)
{
InitializeComponent();

BindingContext = new MaterialBottomSheetViewModel
{
IsModalPage = isModalPage,
DisplayAlert = DisplayAlert,
Navigation = Navigation,
OpenBottomSheetControl = async (controlName) => await this.FindByName<MaterialBottomSheet>(controlName).Open(),
CloseBottomSheetControl = async (controlName) => await this.FindByName<MaterialBottomSheet>(controlName).Close()
};
}
}
}
Loading

0 comments on commit a4defc1

Please sign in to comment.