Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PatchVersion>80</PatchVersion>
<SdkBandVersion>9.0.100</SdkBandVersion>
<PreReleaseVersionLabel>ci.main</PreReleaseVersionLabel>
<PreReleaseVersionLabel Condition="'$(BUILD_SOURCEBRANCHNAME)' == 'refs/heads/inflight/current'">ci.inflight</PreReleaseVersionLabel>
<PreReleaseVersionLabel Condition="'$(BUILD_SOURCEBRANCH)' == 'refs/heads/inflight/current'">ci.inflight</PreReleaseVersionLabel>
<PreReleaseVersionIteration>
</PreReleaseVersionIteration>
<!-- Servicing builds have different characteristics for the way dependencies, baselines, and versions are handled. -->
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/src/Core/BindableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public void SetValue(BindableProperty property, object value)
if (property == null)
throw new ArgumentNullException(nameof(property));

if (value is BindingBase binding && !property.ReturnType.IsAssignableFrom(typeof(BindableProperty)))
if (value is BindingBase binding && !property.ReturnType.IsAssignableFrom(typeof(BindingBase)))
{
SetBinding(property, binding);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected RecyclerView.ViewHolder CreateHeaderFooterViewHolder(object content, D
}

// No template, Footer is not a Forms View, so just display Footer.ToString
return SimpleViewHolder.FromText(content?.ToString(), context, false);
return SimpleViewHolder.FromText(content?.ToString(), context, fill: false);
}

protected RecyclerView.ViewHolder CreateEmptyViewHolder(object content, DataTemplate template, ViewGroup parent)
Expand All @@ -235,7 +235,7 @@ protected RecyclerView.ViewHolder CreateEmptyViewHolder(object content, DataTemp
if (content is not View formsView)
{
// No template, EmptyView is not a Forms View, so just display EmptyView.ToString
return SimpleViewHolder.FromText(content?.ToString(), context);
return SimpleViewHolder.FromText(content?.ToString(), context, () => GetWidth(parent), () => GetHeight(parent), ItemsView);
}

// EmptyView is a Forms View; display that
Expand Down Expand Up @@ -319,12 +319,47 @@ void UpdateHeaderFooterHeight(object item, bool isHeader)
size = content.Measure(double.PositiveInfinity, double.PositiveInfinity);
}

var itemHeight = size.Height;
if (item is string text)
{
Label label = new Label { Text = text };
TemplateHelpers.GetHandler(label, ItemsView.FindMauiContext());

size = label.Measure(double.PositiveInfinity, double.PositiveInfinity);
}

if (IsVerticalItemsLayout())
{
var itemHeight = size.Height;

if (isHeader)
_headerHeight = itemHeight;
else
_footerHeight = itemHeight;
if (isHeader)
{
_headerHeight = itemHeight;
}
else
{
_footerHeight = itemHeight;
}
}
}

bool IsVerticalItemsLayout()
{
if (ItemsView is CollectionView collectionView)
{
switch (collectionView.ItemsLayout)
{
case LinearItemsLayout linearLayout:
{
return linearLayout.Orientation == ItemsLayoutOrientation.Vertical;
}
case GridItemsLayout gridItemsLayout:
{
return gridItemsLayout.Orientation == ItemsLayoutOrientation.Vertical;
}
}
}
// Default
return true;
}
}
}
16 changes: 8 additions & 8 deletions src/Controls/src/Core/Handlers/Items/Android/SimpleViewHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ public void Recycle(ItemsView itemsView)
itemsView.RemoveLogicalChild(View);
}

public static SimpleViewHolder FromText(string text, Context context, bool fill = true)
public static SimpleViewHolder FromText(string text, Context context, Func<double> width = null, Func<double> height = null, ItemsView container = null, bool fill = true)
{
var textView = new TextView(context) { Text = text };

if (fill)
{
var layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent,
ViewGroup.LayoutParams.MatchParent);
textView.LayoutParameters = layoutParams;
// When displaying an EmptyView with Header and Footer, we need to account for the Header and Footer sizes in layout calculations.
// This prevents the EmptyView from occupying the full remaining space.
Label label = new Label() { Text = text, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center };
SizedItemContentView itemContentControl = new SizedItemContentView(context, width, height);
itemContentControl.RealizeContent(label, container);
return new SimpleViewHolder(itemContentControl, null);
}

textView.Gravity = GravityFlags.Center;

TextView textView = new TextView(context) { Text = text, Gravity = GravityFlags.Center };
return new SimpleViewHolder(textView, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public static void MapCurrentItem(CarouselViewHandler handler, CarouselView caro
(handler.PlatformView as IMauiCarouselRecyclerView).UpdateFromCurrentItem();
}

// TODO: Change the modifier to public in .NET 10.
internal static void MapItemsLayout(CarouselViewHandler handler, CarouselView carouselView)
{
if (handler.PlatformView is IMauiRecyclerView<CarouselView> recyclerView)
{
recyclerView.UpdateLayoutManager();
}
}

public override Size GetDesiredSize(double widthConstraint, double heightConstraint)
{
_widthConstraint = widthConstraint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,14 @@ protected override void OnScrollViewerFound(ScrollViewer scrollViewer)
_scrollViewer.ViewChanged += OnScrollViewChanged;
_scrollViewer.SizeChanged += OnScrollViewSizeChanged;

UpdateScrollBarVisibilityForLoop();
if (Element.Loop)
{
UpdateScrollBarVisibilityForLoop();
}
else
{
UpdateScrollBarVisibility();
}
}

protected override ICollectionView GetCollectionView(CollectionViewSource collectionViewSource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public CarouselViewHandler(PropertyMapper mapper = null) : base(mapper ?? Mapper

public static PropertyMapper<CarouselView, CarouselViewHandler> Mapper = new(ItemsViewMapper)
{
#if TIZEN
#if TIZEN || ANDROID
[Controls.CarouselView.ItemsLayoutProperty.PropertyName] = MapItemsLayout,
#endif
[Controls.CarouselView.IsSwipeEnabledProperty.PropertyName] = MapIsSwipeEnabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ protected virtual void UpdateItemsLayout()

UpdateItemTemplate();
UpdateItemsSource();
UpdateVerticalScrollBarVisibility();
UpdateHorizontalScrollBarVisibility();
UpdateScrollBarVisibility();
UpdateEmptyView();
}

Expand All @@ -376,6 +375,12 @@ void ListViewLoaded(object sender, RoutedEventArgs e)
listView.Loaded += ListViewLoaded;
}

internal void UpdateScrollBarVisibility()
{
UpdateVerticalScrollBarVisibility();
UpdateHorizontalScrollBarVisibility();
}

void UpdateVerticalScrollBarVisibility()
{
if (Element.VerticalScrollBarVisibility != ScrollBarVisibility.Default)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public CarouselViewHandler2(PropertyMapper mapper = null) : base(mapper ?? Mappe
[Controls.CarouselView.PeekAreaInsetsProperty.PropertyName] = MapPeekAreaInsets,
[Controls.CarouselView.IsBounceEnabledProperty.PropertyName] = MapIsBounceEnabled,
[Controls.CarouselView.PositionProperty.PropertyName] = MapPosition,
[Controls.CarouselView.CurrentItemProperty.PropertyName] = MapCurrentItem
[Controls.CarouselView.CurrentItemProperty.PropertyName] = MapCurrentItem,
[Controls.CarouselView.ItemsLayoutProperty.PropertyName] = MapItemsLayout,
};
}

Expand Down Expand Up @@ -190,6 +191,12 @@ public static void MapIsBounceEnabled(CarouselViewHandler2 handler, CarouselView
handler.Controller.CollectionView.Bounces = carouselView.IsBounceEnabled;
}

// TODO: Change the modifier to public in .NET 10.
internal static void MapItemsLayout(CarouselViewHandler2 handler, CarouselView carouselView)
{
handler?.UpdateLayout();
}

public static void MapPeekAreaInsets(CarouselViewHandler2 handler, CarouselView carouselView)
{
handler.UpdateLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public int LoopCount
get
{
var newCount = ItemCount;
if (newCount > 0)
if (Loop && newCount > 0)
{
newCount = ItemCount + 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,24 @@ public ModalFragment(IMauiContext mauiContext, Page modal)

dialog.Window.SetBackgroundDrawable(TransparentColorDrawable);

var attributes = Context?.GetActivity()?.Window?.Attributes;
var mainActivityWindow = Context?.GetActivity()?.Window;
var attributes = mainActivityWindow?.Attributes;

if (attributes is not null)
{
dialog.Window.SetSoftInputMode(attributes.SoftInputMode);
}

if (mainActivityWindow is not null)
{
var navigationBarColor = mainActivityWindow.NavigationBarColor;
var statusBarColor = mainActivityWindow.StatusBarColor;
#pragma warning disable CA1422
dialog.Window.SetNavigationBarColor(new AColor(navigationBarColor));
dialog.Window.SetStatusBarColor(new AColor(statusBarColor));
#pragma warning restore CA1422
}

return dialog;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Controls/src/Core/Window/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,13 @@ void SendWindowAppearing()
void SendWindowDisppearing()
{
if (Navigation.ModalStack.Count == 0)
{
Page?.SendDisappearing();
}
else if (Navigation.ModalStack.Count > 0)
{
Navigation.ModalStack[Navigation.ModalStack.Count - 1]?.SendDisappearing();
}

IsActivated = false;
}
Expand Down
48 changes: 48 additions & 0 deletions src/Controls/tests/Core.UnitTests/ItemDisplayBindingTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Xunit;

namespace Microsoft.Maui.Controls.Core.UnitTests
{
public class ItemDisplayBindingTests
{

class TestViewModel
{
public string Name { get; set; }
public string Description { get; set; }
}

class TestView : View
{
internal Picker picker = new Picker();
public static readonly BindableProperty ItemDisplayBindingProperty = BindableProperty.Create(nameof(ItemDisplayBinding), typeof(BindingBase), typeof(TestView), propertyChanged: (bindable, _, newValue) =>
{
if (bindable is TestView view)
{
view.picker.ItemDisplayBinding = (BindingBase)newValue;
}
});


public BindingBase ItemDisplayBinding
{
get => (BindingBase)GetValue(ItemDisplayBindingProperty);
set => SetValue(ItemDisplayBindingProperty, value);
}
}

[Fact]
public void TestItemDisplayBinding()
{
var testView = new TestView();


var binding = new Binding("Name");
testView.ItemDisplayBinding = binding;

Assert.Equal(binding, testView.ItemDisplayBinding);
Assert.Equal(binding, testView.picker.ItemDisplayBinding);
}


}
}
22 changes: 22 additions & 0 deletions src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,28 @@ await CreateHandlerAndAddToWindow(window, async () =>
});
}

#if WINDOWS || MACCATALYST
[Fact]
public async Task DisappearingEventFiresWhenWindowClosedWithModal()
{
SetupBuilder();
var rootPage = new ContentPage();
var modalPage = new ContentPage();
bool disappearingTriggered = false;
modalPage.Disappearing += (_, _) => disappearingTriggered = true;
var window = new Window(rootPage);
await rootPage.Navigation.PushModalAsync(modalPage);

await CreateHandlerAndAddToWindow<IWindowHandler>(window, async handler =>
{
await OnLoadedAsync(modalPage);
Application.Current?.CloseWindow(window);
});

Assert.True(disappearingTriggered);
}
#endif

class PageTypes : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator()
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
Loading