Skip to content

Commit

Permalink
- Add the49ltd#133
Browse files Browse the repository at this point in the history
- [android] Fix "no sliding away" blocked in hidden mode
- [android] Fix bottom sheet sometime displayed in hidden mode
- [android] Fix handle not appearing
- [android] [Demo app] Fix can't open the same demo item twice in a row
- Breaking: removed DetentsCollection. Use a ResourceDictionary to choose between detents with OnPlatform
  • Loading branch information
softlion committed Nov 7, 2024
1 parent d8ee1b4 commit cbb0476
Show file tree
Hide file tree
Showing 14 changed files with 538 additions and 435 deletions.
7 changes: 3 additions & 4 deletions sample/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
<Shell
x:Class="The49.Maui.BottomSheet.Sample.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:The49.Maui.BottomSheet.Sample"
Shell.FlyoutBehavior="Disabled"
Shell.NavBarIsVisible="False">
Shell.NavBarIsVisible="False"
Shell.TabBarIsVisible="True">

<ShellContent
Title="Home"
Expand Down
10 changes: 9 additions & 1 deletion sample/DemoPages/SimplePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
<the49:BottomSheet xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:the49="https://schemas.the49.com/dotnet/2023/maui"
xmlns:demoPages="clr-namespace:The49.Maui.BottomSheet.Sample.DemoPages"
x:Class="The49.Maui.BottomSheet.Sample.DemoPages.SimplePage"
x:Name="this"
Padding="16, 32">

<the49:BottomSheet.Resources>
<Style TargetType="Button">
<Setter Property="BackgroundColor" Value="Transparent" />
<Setter Property="TextColor" Value="Black" />
<Setter Property="HorizontalOptions" Value="Start" />
</Style>
</the49:BottomSheet.Resources>

<VerticalStackLayout Spacing="16">

<HorizontalStackLayout Spacing="16" Padding="16, 0">
<Border StrokeShape="RoundRectangle 8" StrokeThickness="0">
<Image Source="spicy.jpg" HeightRequest="80" WidthRequest="80">
Expand All @@ -27,15 +31,19 @@
</VerticalStackLayout>
</HorizontalStackLayout>
<BoxView Style="{StaticResource Divider}" x:Name="divider" />

<ContentView x:Name="extra" />

<VerticalStackLayout BindableLayout.ItemsSource="{Binding Actions, Source={x:Reference this}}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<DataTemplate x:DataType="demoPages:ListAction">
<Button Text="{Binding Title}" Padding="16, 8" Command="{Binding Command}" />
</DataTemplate>
</BindableLayout.ItemTemplate>
</VerticalStackLayout>

</VerticalStackLayout>

</the49:BottomSheet>
<!-- Photo by <a href="https://unsplash.com/@medion4you?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Norbert Braun
</a> on
Expand Down
56 changes: 16 additions & 40 deletions sample/DemoPages/SimplePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,32 @@

namespace The49.Maui.BottomSheet.Sample.DemoPages;

public class ListAction
public record ListAction(string Title, ICommand Command)
{
public string Title { get; set; }
public ICommand Command { get; set; }
public ListAction(string title, Action commandAction) : this(title, new Command(commandAction)){}
public ListAction(string title) : this(title, new Command(() => {})){}
}

public partial class SimplePage : BottomSheet
{
public ObservableCollection<ListAction> Actions => new()
{
new ListAction
{
Title = "Share",
Command = new Command(() => { }),
},
new ListAction
{
Title = "Copy",
Command = new Command(() => { }),
},
new ListAction
{
Title = "Open in browser",
Command = new Command(() => { }),
},
new ListAction
{
Title = "Resize",
Command = new Command(Resize),
},
new ListAction
{
Title = "Dismiss",
Command = new Command(() => DismissAsync()),
}
};
public VisualElement Divider => divider;

public ObservableCollection<ListAction> Actions =>
[
new("Share"),
new("Copy"),
new("Open in browser"),
new("Resize", () => divider.HeightRequest = divider.HeightRequest != 32 ? 32 : 1),
new("Dismiss", () => DismissAsync())
];

public SimplePage()
{
InitializeComponent();
}

void Resize()
{
divider.HeightRequest = 32;
}

public VisualElement Divider => divider;

public void SetExtraContent(View view)
public View ExtraContent
{
extra.Content = view;
set => extra.Content = value;
}
}
28 changes: 17 additions & 11 deletions sample/DemoPages/SizingTest.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@
xmlns:the49="https://schemas.the49.com/dotnet/2023/maui"
x:Class="Maui.BottomSheet.Sample.DemoPages.SizingTest"
HasHandle="True"
>
<the49:BottomSheet.Detents>
<the49:FullscreenDetent />
<the49:RatioDetent Ratio=".95" />
<OnPlatform x:TypeArguments="the49:Detent">
<On Platform="Android">
Detents="{OnPlatform Android={StaticResource AndroidDetents}, iOS={StaticResource IosDetents}}">

<the49:BottomSheet.Resources>
<ResourceDictionary>
<x:Array x:Key="AndroidDetents" Type="{x:Type the49:Detent}">
<the49:FullscreenDetent />
<the49:RatioDetent Ratio=".95" />
<the49:RatioDetent Ratio=".5" />
</On>
<On Platform="iOS">
</x:Array>

<x:Array x:Key="IosDetents" Type="{x:Type the49:Detent}">
<the49:FullscreenDetent />
<the49:RatioDetent Ratio=".95" />
<the49:MediumDetent />
</On>
</OnPlatform>
</the49:BottomSheet.Detents>
</x:Array>
</ResourceDictionary>
</the49:BottomSheet.Resources>


<Grid RowDefinitions="*,100">
<Grid Grid.Row="0" BackgroundColor="Orange" Opacity=".5" />
<Button Grid.Row="1" HeightRequest="100" Text="this will be cut off" />
Expand Down
10 changes: 10 additions & 0 deletions sample/Lib/DemoEntry.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows.Input;

namespace The49.Maui.BottomSheet.Sample;

public record DemoEntry
{
public string Title { get; set; }
public string Description { get; set; }
public ICommand Command { get; set; }
}
11 changes: 11 additions & 0 deletions sample/Lib/RandomColors.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace The49.Maui.BottomSheet.Sample;

public static class RandomColors
{
private static readonly Random random = new();

public static Color RandomColor()
{
return Color.FromRgb(random.Next(256), random.Next(256), random.Next(256));
}
}
26 changes: 9 additions & 17 deletions sample/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:the49="https://schemas.the49.com/dotnet/2023/maui"
xmlns:sample="clr-namespace:The49.Maui.BottomSheet.Sample"
x:Class="The49.Maui.BottomSheet.Sample.MainPage"
x:Name="this"
NavigationPage.HasNavigationBar="False"
>
NavigationPage.HasNavigationBar="False">
<ContentPage.Resources>
<Style TargetType="Grid">
<Setter Property="VisualStateManager.VisualStateGroups">
Expand All @@ -24,17 +22,15 @@
</Setter>
</Style>
</ContentPage.Resources>

<Grid RowDefinitions="Auto, *">
<HorizontalStackLayout Padding="16, 0, 0, 8"
BackgroundColor="{StaticResource Primary}"
x:Name="Header">
<HorizontalStackLayout x:Name="Header" Padding="16, 0, 0, 8" BackgroundColor="{StaticResource Primary}">
<Label Text="Maui.BottomSheet"
Style="{StaticResource HeadlineLarge}"
TextColor="{StaticResource White}"
VerticalOptions="End" />
<Button Text="OpenModalPage"
Clicked="Button_Clicked" />
</HorizontalStackLayout>

<CollectionView Grid.Row="1"
BackgroundColor="Transparent"
Scrolled="list_Scrolled"
Expand All @@ -44,19 +40,15 @@
x:Name="list">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="sample:DemoEntry">
<Grid ColumnDefinitions="Auto, *"
Padding="16, 4"
HeightRequest="72">
<VerticalStackLayout Grid.Column="1"
VerticalOptions="Center">
<Label Text="{Binding Title}"
Style="{StaticResource BodyLarge}" />
<Label Text="{Binding Description}"
Style="{StaticResource BodyMedium}" />
<Grid ColumnDefinitions="Auto, *" Padding="16, 4" HeightRequest="72">
<VerticalStackLayout Grid.Column="1" VerticalOptions="Center">
<Label Text="{Binding Title}" Style="{StaticResource BodyLarge}" />
<Label Text="{Binding Description}" Style="{StaticResource BodyMedium}" />
</VerticalStackLayout>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>

</Grid>
</ContentPage>
Loading

0 comments on commit cbb0476

Please sign in to comment.