Skip to content
Merged
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Maui.Controls.Sample.CollectionViewGalleries.GroupingGalleries;
using Maui.Controls.Sample.CollectionViewGalleries.HeaderFooterGalleries;
using Maui.Controls.Sample.CollectionViewGalleries.ItemSizeGalleries;
using Maui.Controls.Sample.CollectionViewGalleries.PerformanceGalleries;
using Maui.Controls.Sample.CollectionViewGalleries.SelectionGalleries;

namespace Maui.Controls.Sample.CollectionViewGalleries
Expand Down Expand Up @@ -45,7 +46,8 @@ public CollectionViewCoreGalleryContentPage()
// ItemsFromViewModelShouldBeSelected (src\Compatibility\ControlGallery\src\Issues.Shared\CollectionViewBoundMultiSelection.cs)
TestBuilder.NavButton("Selection Galleries", () => new SelectionGallery(), Navigation),
TestBuilder.NavButton("Item Size Galleries", () => new ItemsSizeGallery(), Navigation),
TestBuilder.NavButton("EmptyView Galleries", () => new EmptyViewGallery(), Navigation)
TestBuilder.NavButton("EmptyView Galleries", () => new EmptyViewGallery(), Navigation),
TestBuilder.NavButton("Performance Galleries", () => new ShadowBenchmark(), Navigation),
}
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
<?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"
x:Class="Maui.Controls.Sample.CollectionViewGalleries.PerformanceGalleries.ShadowBenchmark"
Title="Shadow Benchmark">
<ContentView.Resources>
<ResourceDictionary>

<Style x:Key="PostBorderStyle" TargetType="Border">
<Setter Property="StrokeThickness" Value="0" />
<Setter Property="HeightRequest" Value="240" />
</Style>

<Style x:Key="UserBorderStyle" TargetType="Border">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Stroke" Value="{Binding User.Color}" />
<Setter Property="StrokeThickness" Value="4" />
<Setter Property="HeightRequest" Value="54" />
<Setter Property="WidthRequest" Value="54" />
<Setter Property="HorizontalOptions" Value="Start" />
<Setter Property="Margin" Value="12" />
</Style>

<Style x:Key="UserNameStyle" TargetType="Label">
<Setter Property="TextColor" Value="Black" />
<Setter Property="FontAttributes" Value="Bold" />
</Style>

<Style x:Key="CreatedAtStyle" TargetType="Label">
<Setter Property="FontSize" Value="10" />
<Setter Property="TextColor" Value="Black" />
<Setter Property="Opacity" Value="0.75" />
</Style>

<Style x:Key="InfoLayoutStyle" TargetType="StackLayout">
<Setter Property="Margin" Value="12, 0" />
</Style>

<Style x:Key="HeartIconStyle" TargetType="Path">
<Setter Property="Fill" Value="Black" />
<Setter Property="Scale" Value="0.5" />
<Setter Property="HorizontalOptions" Value="Start" />
<Setter Property="VerticalOptions" Value="Center" />
</Style>

<Style x:Key="HeartTextStyle" TargetType="Label">
<Setter Property="FontSize" Value="10" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="Margin" Value="2, 0" />
</Style>

<Style x:Key="MarkIconStyle" TargetType="Path">
<Setter Property="Fill" Value="Black" />
<Setter Property="Scale" Value="0.5" />
<Setter Property="HorizontalOptions" Value="Start" />
<Setter Property="VerticalOptions" Value="Center" />
</Style>

<Style x:Key="PlayBorderStyle" TargetType="Border">
<Setter Property="Background" Value="White" />
<Setter Property="StrokeThickness" Value="0" />
<Setter Property="HeightRequest" Value="44" />
<Setter Property="WidthRequest" Value="44" />
<Setter Property="Margin" Value="12" />
</Style>

<Style x:Key="PlayIconStyle" TargetType="Path">
<Setter Property="Fill" Value="Black" />
<Setter Property="HorizontalOptions" Value="Center" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="Scale" Value="0.5" />
<Setter Property="Margin" Value="6" />
</Style>

<Style x:Key="TitleTextStyle" TargetType="Label">
<Setter Property="FontSize" Value="18" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="TextColor" Value="White" />
<Setter Property="LineBreakMode" Value="WordWrap" />
<Setter Property="MaxLines" Value="2" />
<Setter Property="HorizontalOptions" Value="Start" />
<Setter Property="WidthRequest" Value="280" />
</Style>

<Style x:Key="FromTextStyle" TargetType="Label">
<Setter Property="FontSize" Value="12" />
<Setter Property="TextColor" Value="LightGray" />
<Setter Property="Opacity" Value="0.95" />
</Style>

</ResourceDictionary>
</ContentView.Resources>
<ContentPage.Content>
<CollectionView
ItemsSource="{Binding Posts}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="16">
<Border
BackgroundColor="White"
Style="{StaticResource PostBorderStyle}">
<Border.StrokeShape>
<RoundRectangle
CornerRadius="12, 120, 12, 12"/>
</Border.StrokeShape>
<Border.Shadow>
<Shadow
Brush="Black"
Radius="6"
Offset="2, 2"/>
</Border.Shadow>
<Grid>
<Image
Aspect="AspectFill"
Source="{Binding Image}"/>
<Grid
BackgroundColor="Black"
Opacity="0.1"/>
<Grid
ColumnDefinitions="72, Auto"
RowDefinitions="Auto, Auto, *">
<Grid
HorizontalOptions="Start">
<Border
Style="{StaticResource UserBorderStyle}">
<Border.StrokeShape>
<Ellipse />
</Border.StrokeShape>
<Image
Source="{Binding User.Image}"
HorizontalOptions="Center"
VerticalOptions="Center"
Margin="1">
<Image.Clip>
<EllipseGeometry
Center="25, 25"
RadiusX="25"
RadiusY="25"/>
</Image.Clip>
</Image>
</Border>
</Grid>
<Grid
Grid.Column="1"
RowDefinitions="Auto, Auto"
Margin="0, 18" >
<Label
Text="{Binding User.Name}"
Style="{StaticResource UserNameStyle}"/>
<Label
Grid.Row="1"
Text="4 HOURS AGO"
Style="{StaticResource CreatedAtStyle}"/>
</Grid>
<StackLayout
Grid.Row="1"
Style="{StaticResource InfoLayoutStyle}">
<StackLayout
Orientation="Horizontal">
<Path
Data="M8.5319849,0C11.560988,7.3866431E-08 14.464015,1.6680007 15.99997,4.5209999 18.139016,0.55099538 22.921994,-1.1230173 27.008008,0.7949839 31.297024,2.8069787 33.185032,8.0069957 31.22604,12.411997 29.27303,16.804 15.998994,30.380001 15.998994,30.380001 15.915985,30.327022 2.7269701,16.804 0.77395964,12.411997 -1.1850933,8.0069957 0.70291448,2.8069787 4.9929701,0.7949839 6.1419612,0.25497467 7.3469826,7.3866431E-08 8.5319849,0z"
Style="{StaticResource HeartIconStyle}"/>
<Label
Text="{Binding Likes}"
Style="{StaticResource HeartTextStyle}"/>
</StackLayout>
<Grid>
<Path
Data="M4.2800019,0L11.127999,0C13.491008,0,15.408001,1.9349976,15.408001,4.3209839L15.408001,32 7.5820063,23.104004 0,32 0,4.3209839C2.0228617E-07,1.9349976,1.9169938,0,4.2800019,0z"
Style="{StaticResource MarkIconStyle}"/>
</Grid>
</StackLayout>
<Grid
Grid.ColumnSpan="2"
Grid.Row="2"
ColumnDefinitions="Auto, *"
VerticalOptions="End"
Margin="0, 12">
<Border
Style="{StaticResource PlayBorderStyle}">
<Border.StrokeShape>
<Ellipse />
</Border.StrokeShape>
<Border.Shadow>
<Shadow
Brush="LightGray"
Radius="6"
Offset="4, 4"/>
</Border.Shadow>
<Path
Data="M0,0L15.825011,8.0009766 31.650999,15.997986 15.825011,23.998993 0,32 0,15.997986z"
Style="{StaticResource PlayIconStyle}"/>
</Border>
<StackLayout
Grid.Column="1">
<Label
Text="{Binding Title}"
Style="{StaticResource TitleTextStyle}">
<!--
<Label.Shadow>
<Shadow
Brush="LightGray"
Radius="6"
Offset="2, 2"/>
</Label.Shadow>
-->
</Label>
<Label
Text="{Binding User.From}"
Style="{StaticResource FromTextStyle}"/>
</StackLayout>
</Grid>
</Grid>
</Grid>
</Border>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</ContentPage.Content>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
namespace Maui.Controls.Sample.CollectionViewGalleries.PerformanceGalleries
{
public class ShadowBenchmarkShell : Shell
{
public ShadowBenchmarkShell()
{
FlyoutBehavior = FlyoutBehavior.Flyout;
Items.Add(new ShellContent
{
Content = new ShadowBenchmark(),
Title = "Shadow Benchmark"
});
}
}

public partial class ShadowBenchmark : ContentPage
{
public ShadowBenchmark()
{
BindingContext = new ShadowBenchmarkViewModel();
InitializeComponent();
}
}

public class User
{
public string Name { get; set; }
public string Image { get; set; }
public Color Color { get; set; }
public string From { get; set; }
}

public class Post
{
public string Title { get; set; }
public string Content { get; set; }
public string Image { get; set; }
public string Likes { get; set; }
public User User { get; set; }
public DateTime CreatedAt { get; set; }
}

public class ShadowBenchmarkViewModel
{
public List<Post> Posts { get; } = GetData();

static List<Post> GetData()
{
var posts = new List<Post>();

User user = new User
{
Name = "Lorem ipsum",
Image = "oasis.jpg",
Color = Color.FromArgb("#62D7FB"),
From = "Lorem ipsum"
};

for(int i = 0; i < 1000; i++)
{
posts.Add(new Post { Title = $"Lorem ipsum {i + 1} dolor sit amet, consectetur adipiscing elit", Image = "photo21314.jpg", Likes = "1k", User = user });
}

return posts;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Bugzilla39489 : TestNavigationPage
{
protected override void Init()
{
PushAsync(new Bz39489Content());
PushAsync(new Bz39489Root());
}
}

Expand All @@ -29,44 +29,51 @@ public Bz39489Map()
}
}


public class Bz39489Content : ContentPage
public class Bz39489Root : ContentPage
{
static int s_count;

public Bz39489Content()
public Bz39489Root()
{
Interlocked.Increment(ref s_count);
Debug.WriteLine($">>>>> Bz39489Content Bz39489Content 54: Constructor, count is {s_count}");

var button = new Button { AutomationId = "NewPage", Text = "New Page" };

var gcbutton = new Button { AutomationId = "GC", Text = "GC" };

var map = new Bz39489Map();

button.Clicked += Button_Clicked;
gcbutton.Clicked += GCbutton_Clicked;

Content = new StackLayout { Children = { button, gcbutton, map } };
Content = new VerticalStackLayout { button, gcbutton };
}

void GCbutton_Clicked(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine(">>>>>>>> Running Garbage Collection");
Debug.WriteLine(">>>>>>>> Running Garbage Collection");
GarbageCollectionHelper.Collect();
System.Diagnostics.Debug.WriteLine($">>>>>>>> GC.GetTotalMemory = {GC.GetTotalMemory(true):n0}");
Debug.WriteLine($">>>>>>>> GC.GetTotalMemory = {GC.GetTotalMemory(true):n0}");
}

void Button_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new Bz39489Content());
}
}


public class Bz39489Content : ContentPage
{
static int s_count;

public Bz39489Content()
{
Interlocked.Increment(ref s_count);
Debug.WriteLine($">>>>> Bz39489Content: Constructor, count is {s_count}");

var label = new Label { AutomationId = "StubLabel", Text = "Now press the back button." };

var map = new Bz39489Map();

Content = new StackLayout { Children = { label, map } };
}

~Bz39489Content()
{
Interlocked.Decrement(ref s_count);
Debug.WriteLine($">>>>> Bz39489Content ~Bz39489Content 82: Destructor, count is {s_count}");
Debug.WriteLine($">>>>> Bz39489Content: Destructor, count is {s_count}");
}
}
}
Loading
Loading