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
12 changes: 9 additions & 3 deletions src/Controls/src/Core/Handlers/Items/Android/MauiRecyclerView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,18 @@ public virtual void UpdateCanReorderItems()

public virtual void UpdateLayoutManager()
{
_layoutPropertyChangedProxy?.Unsubscribe();
var itemsLayout = _getItemsLayout();

if (itemsLayout == ItemsLayout)
{
return;
}

ItemsLayout = _getItemsLayout();
_layoutPropertyChangedProxy?.Unsubscribe();
ItemsLayout = itemsLayout;

// Keep track of the ItemsLayout's property changes
if (ItemsLayout != null)
if (ItemsLayout is not null)
{
_layoutPropertyChanged ??= LayoutPropertyChanged;
_layoutPropertyChangedProxy = new WeakNotifyPropertyChangedProxy(ItemsLayout, _layoutPropertyChanged);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ public override Size GetDesiredSize(double widthConstraint, double heightConstra
{
var contentSize = Controller.GetSize();

// If contentSize comes back null, it means none of the content has been realized yet;
// we need to return the expansive size the collection view wants by default to get
// it to start measuring its content
if (contentSize.Height == 0 || contentSize.Width == 0)
{
return base.GetDesiredSize(widthConstraint, heightConstraint);
}

// Our target size is the smaller of it and the constraints
var width = contentSize.Width <= widthConstraint ? contentSize.Width : widthConstraint;
var height = contentSize.Height <= heightConstraint ? contentSize.Height : heightConstraint;
Expand Down
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.
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.
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 @@ -95,7 +95,9 @@ public override string ToString()
new GalleryPageFactory(() => new ImageControlPage(), "Image Feature Matrix"),
new GalleryPageFactory(() => new ImageButtonControlPage(), "ImageButton Feature Matrix"),
new GalleryPageFactory(() => new BoxViewControlPage(), "BoxView Feature Matrix"),
new GalleryPageFactory(() => new HybridWebViewControlPage(), "HybridWebView Feature Matrix"),
new GalleryPageFactory(() => new ScrollViewControlPage(), "ScrollView Feature Matrix"),
new GalleryPageFactory(() => new GraphicsViewControlPage(), "GraphicsView Feature Matrix"),
new GalleryPageFactory(() => new EditorControlPage(), "Editor Feature Matrix"),
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?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:local="clr-namespace:Maui.Controls.Sample"
x:Class="Maui.Controls.Sample.GraphicsViewControlMainPage"
Title="GraphicsViewFeature">

<ContentPage.ToolbarItems>
<ToolbarItem Text="Options"
Clicked="NavigateToOptionsPage_Clicked"
AutomationId="Options"/>
</ContentPage.ToolbarItems>

<Grid Padding="20"
RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto"
ColumnDefinitions="0.5*, 0.5*"
RowSpacing="10">
<!-- GraphicsView Control -->
<GraphicsView x:Name="graphicsView"
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
Drawable="{Binding Drawable}"
IsVisible="{Binding IsVisible}"
IsEnabled="{Binding IsEnabled}"
FlowDirection="{Binding FlowDirection}"
Shadow="{Binding Shadow}"
HeightRequest="{Binding HeightRequest}"
WidthRequest="{Binding WidthRequest}"
StartHoverInteraction="OnStartHoverInteraction"
MoveHoverInteraction="OnMoveHoverInteraction"
EndHoverInteraction="OnEndHoverInteraction"
StartInteraction="OnStartInteraction"
DragInteraction="OnDragInteraction"
EndInteraction="OnEndInteraction"
CancelInteraction="OnCancelInteraction"
Margin="0,100,0,100"
AutomationId="GraphicsViewControl"/>

<!-- Drawable Type -->
<Label Grid.Row="1"
Grid.Column="0"
Text="Drawable Type:"
FontSize="16"
VerticalTextAlignment="Start"
HorizontalTextAlignment="Start"
Margin="80,0,10,10"/>
<Label Grid.Row="1"
Grid.Column="1"
Text="{Binding DrawableTypeLabel}"
FontSize="16"
VerticalTextAlignment="Start"
HorizontalTextAlignment="Start"
AutomationId="DrawableTypeLabel"/>

<Label Grid.Row="2"
Grid.Column="0"
FontSize="16"
Text="Triggered Events:"
IsVisible="{Binding IsEventStatusLabelVisible}"
VerticalTextAlignment="Start"
HorizontalTextAlignment="Start"
Margin="80,0,10,10"/>

<Label Grid.Row="2"
Grid.Column="1"
Text="{Binding InteractionEvent}"
FontSize="14"
VerticalTextAlignment="Start"
HorizontalTextAlignment="Start"
Margin="0,0,10,10"
LineBreakMode="WordWrap"
MaxLines="10"
AutomationId="InteractionEventLabel"/>

<Label Grid.Row="3" Grid.Column="0" Text="Drawable Dimensions:" FontSize="16" VerticalTextAlignment="Start" HorizontalTextAlignment="Start" Margin="80,0,10,10" />
<Label Grid.Row="3" Grid.Column="1" Text="{Binding DrawableDimensions}" FontSize="16" VerticalTextAlignment="Start" HorizontalTextAlignment="Start" AutomationId="DrawableDimensionsLabel" />

<!-- Clear Events Button -->
<Button Grid.Row="4"
Grid.Column="0"
Text="Clear Events"
Clicked="OnClearEventsClicked"
BackgroundColor="LightCoral"
TextColor="White"
FontSize="14"
Margin="80,5,10,5"
AutomationId="ClearEventsButton"/>

<!-- Invalidate Button -->
<Button Grid.Row="4"
Grid.Column="1"
Text="Invalidate GraphicsView"
Clicked="OnInvalidateClicked"
BackgroundColor="LightBlue"
TextColor="DarkBlue"
FontSize="14"
Margin="10,5,80,5"
AutomationId="InvalidateButton"/>

</Grid>
</ContentPage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using System;
using System.ComponentModel;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;
using System.Diagnostics;

namespace Maui.Controls.Sample;

public class GraphicsViewControlPage : NavigationPage
{
private GraphicsViewViewModel _viewModel;

public GraphicsViewControlPage()
{
_viewModel = new GraphicsViewViewModel();
PushAsync(new GraphicsViewControlMainPage(_viewModel));
}
}

public partial class GraphicsViewControlMainPage : ContentPage
{
private GraphicsViewViewModel _viewModel;

public GraphicsViewControlMainPage(GraphicsViewViewModel viewModel)
{
InitializeComponent();
_viewModel = viewModel;
BindingContext = _viewModel;

// Ensure GraphicsView invalidates when drawable changes
_viewModel.RequestInvalidate = () => graphicsView.Invalidate();

// Set default drawable
_viewModel.SelectedDrawable = DrawableType.Square;
}

private async void NavigateToOptionsPage_Clicked(object sender, EventArgs e)
{
BindingContext = _viewModel = new GraphicsViewViewModel(); // Ensure the ViewModel is set for the options page
await Navigation.PushAsync(new GraphicsViewOptionsPage(_viewModel));
}

private void OnStartHoverInteraction(object sender, TouchEventArgs e)
{
_viewModel.AddInteractionEvent("StartHoverInteraction");
}

private void OnMoveHoverInteraction(object sender, TouchEventArgs e)
{
_viewModel.AddInteractionEvent("MoveHoverInteraction");
}

private void OnEndHoverInteraction(object sender, EventArgs e)
{
_viewModel.AddInteractionEvent("EndHoverInteraction");
}

private void OnStartInteraction(object sender, TouchEventArgs e)
{
_viewModel.AddInteractionEvent("StartInteraction");
}

private void OnDragInteraction(object sender, TouchEventArgs e)
{
_viewModel.AddInteractionEvent("DragInteraction");
}

private void OnEndInteraction(object sender, EventArgs e)
{
_viewModel.AddInteractionEvent("EndInteraction");
}

private void OnCancelInteraction(object sender, EventArgs e)
{
_viewModel.AddInteractionEvent("CancelInteraction");
}

private void OnInvalidateClicked(object sender, EventArgs e)
{
// Use a constant color for consistent screenshot testing
_viewModel.CurrentDrawColor = Colors.Green;

// Call Invalidate on the GraphicsView to force a redraw
graphicsView.Invalidate();

// Add the invalidate event to the history with color information
_viewModel.AddInteractionEvent($"Invalidate() called - Color changed to {_viewModel.CurrentDrawColor}");
}

private void OnClearEventsClicked(object sender, EventArgs e)
{
// Clear the interaction event history
_viewModel.ClearInteractionHistory();
}

private void DisplayStoredDimensions()
{
var dimensions = _viewModel.GetDrawableDimensions(_viewModel.SelectedDrawable);
if (dimensions.HasValue)
{
Debug.WriteLine($"Stored Dimensions for {_viewModel.SelectedDrawable}: Width = {dimensions.Value.Width}, Height = {dimensions.Value.Height}");
}
else
{
Debug.WriteLine($"No stored dimensions found for {_viewModel.SelectedDrawable}.");
}
}

protected override void OnAppearing()
{
base.OnAppearing();
DisplayStoredDimensions();
}
}
Loading
Loading