maui icon indicating copy to clipboard operation
maui copied to clipboard

IndicatorView with DataTemplate - improvements

Open kubaflo opened this issue 1 year ago • 7 comments

Issues Fixed

Fixes https://github.com/dotnet/maui/issues/21980 Fixes https://github.com/dotnet/maui/issues/24739 Closes https://github.com/dotnet/maui/pull/24717

Before After

kubaflo avatar Sep 15 '24 14:09 kubaflo

/azp run

PureWeen avatar Sep 16 '24 17:09 PureWeen

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Sep 16 '24 17:09 azure-pipelines[bot]

/azp run

rmarinho avatar Sep 17 '24 12:09 rmarinho

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Sep 17 '24 12:09 azure-pipelines[bot]

@kubaflo Could you rebase to fix the conflicts? Thanks in advance.

jsuarezruiz avatar Oct 23 '24 08:10 jsuarezruiz

@jsuarezruiz rebased and fixed conflicts

kubaflo avatar Oct 25 '24 23:10 kubaflo

/rebase

jsuarezruiz avatar Nov 12 '24 10:11 jsuarezruiz

/azp run

PureWeen avatar Nov 27 '24 04:11 PureWeen

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Nov 27 '24 04:11 azure-pipelines[bot]

@rmarinho I see, this is a screenshot from 2 months ago, I just reuploaded a new one :)

Unfortunately,, I cannot fix this problem: https://github.com/dotnet/maui/pull/24776#discussion_r1817845429, because I don't have Windows

kubaflo avatar Nov 28 '24 12:11 kubaflo

/rebase

rmarinho avatar Dec 16 '24 14:12 rmarinho

/azp run

rmarinho avatar Dec 16 '24 14:12 rmarinho

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Dec 16 '24 14:12 azure-pipelines[bot]

I double check and the test is crashing on Windows IndicatorViewShouldRenderCorrectly.

https://dev.azure.com/xamarin/public/_build/results?buildId=130815&view=ms.vss-test-web.build-test-results-tab&runId=3514041&resultId=100085&paneView=debug

I cannot fix it on Windows :/ https://github.com/dotnet/maui/pull/24776#issuecomment-2506036415

kubaflo avatar Dec 18 '24 14:12 kubaflo

I double check and the test is crashing on Windows IndicatorViewShouldRenderCorrectly. https://dev.azure.com/xamarin/public/_build/results?buildId=130815&view=ms.vss-test-web.build-test-results-tab&runId=3514041&resultId=100085&paneView=debug

I cannot fix it on Windows :/ #24776 (comment)

oh sorry so many comments, let me give it a look .

rmarinho avatar Dec 18 '24 14:12 rmarinho

/rebase

PureWeen avatar Jan 29 '25 21:01 PureWeen

/azp run

PureWeen avatar Jan 29 '25 21:01 PureWeen

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Jan 29 '25 21:01 azure-pipelines[bot]

/rebase

rmarinho avatar Feb 20 '25 17:02 rmarinho

/azp run

rmarinho avatar Feb 20 '25 18:02 rmarinho

Azure Pipelines successfully started running 3 pipeline(s).

azure-pipelines[bot] avatar Feb 20 '25 18:02 azure-pipelines[bot]

/rebase

jsuarezruiz avatar Mar 03 '25 10:03 jsuarezruiz

/azp run

jsuarezruiz avatar Mar 03 '25 10:03 jsuarezruiz

I wonder if instead of setting the WidthRequest and HeightRequest for this one we can override MeasureOverride and provide the proper measure values from that?

For example, as a quick test I did this

#pragma warning disable RS0016 // Add public types and members to the declared API
		protected override Size MeasureOverride(double widthConstraint, double heightConstraint)
#pragma warning restore RS0016 // Add public types and members to the declared API
		{
			var size = base.MeasureOverride(widthConstraint, heightConstraint);

			var width = templatedItemWidth.Value * Count + DefaultPadding * (Count - 1);
			var height = templatedItemHeight.Value;

			return new Size(width, height);

		}

And that worked without having to set the Width/HeightReuqest

Or alternatively

Why don't we override SizeThatFits on MauiPageControl ?

Thanks!

kubaflo avatar Mar 05 '25 00:03 kubaflo

I tried on android, but when I change the item, it doesn t change the selected item of the carouselview, also if I click one on the indicator, sometimes it goes to the next item, other it doesn't.

Works fine on iOS

I've checked, and the issue happens when we have the same images in carousel view. It appears to be already existing bug. I've updated the sample in the UI test. Can you have a look if it works for you?

kubaflo avatar Apr 21 '25 16:04 kubaflo

@rmarinho This is what happens on main, but I'd rather fix it in a separate PR

Same images Different images

kubaflo avatar Apr 21 '25 16:04 kubaflo

@rmarinho it happens because all of the items have a bindingContext="dotnet_bot.png", so

int GetIndexFromTemplatedCell(global::Android.Views.View view)
{
	int itemIndex = -1;

	if (view is ItemContentView templatedCell && ItemsViewAdapter != null)
	{
		var bContext = (templatedCell?.View as VisualElement)?.BindingContext;
		itemIndex = ItemsViewAdapter.GetPositionForItem(bContext);
	}

	return itemIndex;
}

in CarouselViewOnScrollListener.cs returns the same index for all the elements

kubaflo avatar Apr 21 '25 18:04 kubaflo