Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add samples for scrolling content #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions sample/DemoPages/SimpleSCrollViewPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<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"
x:Class="The49.Maui.BottomSheet.DemoPages.SimpleScrollViewPage"
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="StartAndExpand" />
</Style>
</the49:BottomSheet.Resources>

<ScrollView>

<VerticalStackLayout BindableLayout.ItemsSource="{Binding Items, Source={x:Reference this}}" Spacing="4">

<BindableLayout.ItemTemplate>
<DataTemplate>

<VerticalStackLayout>
<Label Text="{Binding .}" Margin="20, 10" />
<Line HeightRequest="1" BackgroundColor="LightCyan" />
</VerticalStackLayout>

</DataTemplate>
</BindableLayout.ItemTemplate>

</VerticalStackLayout>

</ScrollView>

</the49:BottomSheet>
14 changes: 14 additions & 0 deletions sample/DemoPages/SimpleSCrollViewPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace The49.Maui.BottomSheet.DemoPages;


public partial class SimpleScrollViewPage: BottomSheet
{
public List<string> Items { get; }

public SimpleScrollViewPage()
{
Items = Enumerable.Range(0, 50).Select(i => $"Item #{i}").ToList();

InitializeComponent();
}
}
59 changes: 58 additions & 1 deletion sample/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ public MainPage()
Description = "define a detent to be opened by default",
Command = new Command(OpenDefaultDetent),
},
new DemoEntry
{
Title = "Content with scrolling collection",
Description = "the sheet contains a CollectionView",
Command = new Command(OpenWithCollectionView),
},
new DemoEntry
{
Title = "Content is ScrollView",
Description = "the sheet contains a ScrollView",
Command = new Command(OpenWithScrollView),
},
#if ANDROID
new DemoEntry
{
Expand Down Expand Up @@ -282,6 +294,51 @@ void OpenNoAnimationSheet()
page.ShowAsync(Window, false);
}

void OpenWithCollectionView()
{
var page = new SimplePage
{
Detents = new DetentsCollection
{
new FullscreenDetent(),
new MediumDetent { IsDefault = true },
new RatioDetent { Ratio = .2f },
},
HasBackdrop = true,
};

page.SetExtraContent(
new CollectionView
{
HeightRequest = 400,
ItemsSource = Enumerable.Range(0,1000).Select(i => $"item {i}").ToList(),
ItemTemplate = new DataTemplate(() =>
{
var label = new Label { Margin = new(20, 10, 20, 10) };
label.SetBinding(Label.TextProperty, new Binding("."));
return label;
})
});

page.ShowAsync(Window);
}

void OpenWithScrollView()
{
var page = new SimpleScrollViewPage
{
Detents = new DetentsCollection
{
new FullscreenDetent(),
new MediumDetent { IsDefault = true },
new RatioDetent { Ratio = .2f },
},
HasBackdrop = true,
};

page.ShowAsync(Window);
}

#if ANDROID
void OpenCustomizeBehavior()
{
Expand Down Expand Up @@ -316,7 +373,7 @@ private void list_SelectionChanged(object sender, SelectionChangedEventArgs e)
item.Command.Execute(null);
}

void list_Scrolled(object sender, ItemsViewScrolledEventArgs e)
void list_Scrolled(object? sender, ItemsViewScrolledEventArgs e)
{
Header.TranslationY = Math.Max(-e.VerticalOffset, -72);
}
Expand Down
12 changes: 11 additions & 1 deletion sample/The49.Maui.BottomSheet.Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
Expand Down Expand Up @@ -56,7 +57,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="5.1.0" />
<PackageReference Include="CommunityToolkit.Maui" Version="5.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="The49.Maui.Insets" Version="1.0.0-alpha4" />
</ItemGroup>
Expand All @@ -66,6 +67,15 @@
</ItemGroup>

<ItemGroup>
<Compile Update="DemoPages\SimpleSCrollViewPage.xaml.cs">
<DependentUpon>SimpleScrollViewPage.xaml</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<MauiXaml Update="DemoPages\SimpleScrollViewPage.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="DemoPages\SimplePage.xaml">
<Generator></Generator>
</MauiXaml>
Expand Down
2 changes: 1 addition & 1 deletion src/The49.Maui.BottomSheet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="M.BindableProperty.Generator" Version="0.9.3" PrivateAssets="all" />
<PackageReference Include="M.BindableProperty.Generator" Version="0.10.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down