Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/NanthiniMahalingam/maui int…
Browse files Browse the repository at this point in the history
…o issue-18452
  • Loading branch information
NanthiniMahalingam committed Sep 26, 2024
2 parents df7968e + 7005a68 commit 7fa653b
Show file tree
Hide file tree
Showing 32 changed files with 663 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]
},
"microsoft.dotnet.xharness.cli": {
"version": "10.0.0-prerelease.24466.1",
"version": "10.0.0-prerelease.24467.4",
"commands": [
"xharness"
]
Expand Down
38 changes: 0 additions & 38 deletions .github/workflows/similarIssues.yml

This file was deleted.

12 changes: 6 additions & 6 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Dependencies>
<ProductDependencies>
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="10.0.0-prerelease.24466.1">
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Common" Version="10.0.0-prerelease.24467.4">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>f20e52f7731da99588dd6b4f4bd60119f03220a3</Sha>
<Sha>3cfb1a3d86da666fb80ba0adb970525e88339d57</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="10.0.0-prerelease.24466.1">
<Dependency Name="Microsoft.DotNet.XHarness.TestRunners.Xunit" Version="10.0.0-prerelease.24467.4">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>f20e52f7731da99588dd6b4f4bd60119f03220a3</Sha>
<Sha>3cfb1a3d86da666fb80ba0adb970525e88339d57</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="10.0.0-prerelease.24466.1">
<Dependency Name="Microsoft.DotNet.XHarness.CLI" Version="10.0.0-prerelease.24467.4">
<Uri>https://github.com/dotnet/xharness</Uri>
<Sha>f20e52f7731da99588dd6b4f4bd60119f03220a3</Sha>
<Sha>3cfb1a3d86da666fb80ba0adb970525e88339d57</Sha>
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
Expand Down
6 changes: 3 additions & 3 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@
<_HarfBuzzSharpVersion>7.3.0.2</_HarfBuzzSharpVersion>
<_SkiaSharpNativeAssetsVersion>0.0.0-commit.7af1d0840a381c0ce7ef2877454a88dbb2949686.1086</_SkiaSharpNativeAssetsVersion>
<MicrosoftTemplateEngineTasksVersion>7.0.114</MicrosoftTemplateEngineTasksVersion>
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>10.0.0-prerelease.24466.1</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>10.0.0-prerelease.24466.1</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
<MicrosoftDotNetXHarnessCLIVersion>10.0.0-prerelease.24466.1</MicrosoftDotNetXHarnessCLIVersion>
<MicrosoftDotNetXHarnessTestRunnersCommonVersion>10.0.0-prerelease.24467.4</MicrosoftDotNetXHarnessTestRunnersCommonVersion>
<MicrosoftDotNetXHarnessTestRunnersXunitVersion>10.0.0-prerelease.24467.4</MicrosoftDotNetXHarnessTestRunnersXunitVersion>
<MicrosoftDotNetXHarnessCLIVersion>10.0.0-prerelease.24467.4</MicrosoftDotNetXHarnessCLIVersion>
<TizenUIExtensionsVersion>0.9.2</TizenUIExtensionsVersion>
<SvgSkiaPackageVersion>1.0.0.16</SvgSkiaPackageVersion>
<FizzlerPackageVersion>1.3.0</FizzlerPackageVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
{
UpdateUseLargeTitles();
}
else if (e.PropertyName == NavigationPage.BackButtonTitleProperty.PropertyName)
else if (e.PropertyName == NavigationPage.BackButtonTitleProperty.PropertyName || e.PropertyName == NavigationPage.TitleProperty.PropertyName)
{
var pack = (ParentingViewController)TopViewController;
pack?.UpdateTitleArea(pack.Child);
Expand Down Expand Up @@ -1508,16 +1508,17 @@ internal void UpdateTitleArea(Page page)
if (!(OperatingSystem.IsIOSVersionAtLeast(11) || OperatingSystem.IsMacCatalystVersionAtLeast(11)) && !isBackButtonTextSet)
backButtonText = "";

_navigation.TryGetTarget(out NavigationRenderer n);

// First page and we have a flyout detail to contend with
UpdateLeftBarButtonItem();
UpdateBackButtonTitle(page.Title, backButtonText);
UpdateBackButtonTitle(page.Title ?? n?.NavPage.Title, backButtonText);

//var hadTitleView = NavigationItem.TitleView != null;
ClearTitleViewContainer();
if (needContainer)
{
NavigationRenderer n;
if (!_navigation.TryGetTarget(out n))
if (n is null)
return;

Container titleViewContainer = new Container(titleView, n.NavigationBar);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,30 @@ public override AView OnCreateView(LayoutInflater inflater, ViewGroup container,
return _rootView = root;
}

void OnShellContentPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == ShellContent.TitleProperty.PropertyName && sender is ShellContent shellContent)
{
UpdateTabTitle(shellContent);
}
}

void UpdateTabTitle(ShellContent shellContent)
{
if (_tablayout == null || SectionController.GetItems().Count == 0)
return;

int index = SectionController.GetItems().IndexOf(shellContent);
if (index >= 0)
{
var tab = _tablayout.GetTabAt(index);
if (tab != null)
{
tab.SetText(new string(shellContent.Title));
}
}
}

void OnTabLayoutChange(object sender, AView.LayoutChangeEventArgs e)
{
if (_disposed)
Expand Down Expand Up @@ -327,13 +351,21 @@ void HookEvents()
SectionController.ItemsCollectionChanged += OnItemsCollectionChanged;
((IShellController)_shellContext.Shell).AddAppearanceObserver(this, ShellSection);
ShellSection.PropertyChanged += OnShellItemPropertyChanged;
foreach (var item in SectionController.GetItems())
{
item.PropertyChanged += OnShellContentPropertyChanged;
}
}

void UnhookEvents()
{
SectionController.ItemsCollectionChanged -= OnItemsCollectionChanged;
((IShellController)_shellContext?.Shell)?.RemoveAppearanceObserver(this);
ShellSection.PropertyChanged -= OnShellItemPropertyChanged;
foreach (var item in SectionController.GetItems())
{
item.PropertyChanged -= OnShellContentPropertyChanged;
}
}

protected virtual void OnPageSelected(int position)
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/src/Core/Element/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ internal void OnResourcesChanged(IEnumerable<KeyValuePair<string, object>> value
internal override void OnSetDynamicResource(BindableProperty property, string key, SetterSpecificity specificity)
{
base.OnSetDynamicResource(property, key, specificity);
if (!DynamicResources.TryGetValue(property, out var existing) || existing.Item2.CompareTo(specificity) < 0)
if (!DynamicResources.TryGetValue(property, out var existing) || existing.Item2.CompareTo(specificity) <= 0)
DynamicResources[property] = (key, specificity);
if (this.TryGetResource(key, out var value))
OnResourceChanged(property, value, specificity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Microsoft.Maui.Controls.Handlers
public partial class ShellContentHandler : ElementHandler<ShellContent, FrameworkElement>
{
public static PropertyMapper<ShellContent, ShellContentHandler> Mapper =
new PropertyMapper<ShellContent, ShellContentHandler>(ElementMapper);
new PropertyMapper<ShellContent, ShellContentHandler>(ElementMapper) { [nameof(ShellContent.Title)] = MapTitle };

public static CommandMapper<ShellContent, ShellContentHandler> CommandMapper =
new CommandMapper<ShellContent, ShellContentHandler>(ElementCommandMapper);
Expand All @@ -16,6 +16,14 @@ public ShellContentHandler() : base(Mapper, CommandMapper)
{
}

internal static void MapTitle(ShellContentHandler handler, ShellContent item)
{
var shellSection = item.Parent as ShellSection;
var shellItem = shellSection?.Parent as ShellItem;
var shellItemHandler = shellItem?.Handler as ShellItemHandler;
shellItemHandler?.UpdateTitle();
}

protected override FrameworkElement CreatePlatformElement()
{
return (VirtualView as IShellContentController).GetOrCreateContent().ToPlatform(MauiContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ string GetTitle()
return string.Empty;
}

return _currentNavigationPage?.CurrentPage?.Title;
return _currentNavigationPage?.CurrentPage?.Title ?? _currentNavigationPage?.Title;
}

VisualElement GetTitleView()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#nullable enable
#nullable enable
2 changes: 1 addition & 1 deletion src/Controls/src/Core/Shell/BaseShellItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class BaseShellItem : NavigableElement, IPropertyPropagationController, I

/// <summary>Bindable property for <see cref="Title"/>.</summary>
public static readonly BindableProperty TitleProperty =
BindableProperty.Create(nameof(Title), typeof(string), typeof(BaseShellItem), null, BindingMode.OneTime, propertyChanged: OnTitlePropertyChanged);
BindableProperty.Create(nameof(Title), typeof(string), typeof(BaseShellItem), null, BindingMode.TwoWay, propertyChanged: OnTitlePropertyChanged);

/// <summary>Bindable property for <see cref="IsVisible"/>.</summary>
public static readonly BindableProperty IsVisibleProperty =
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.
40 changes: 40 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue19859.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<FlyoutPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue19859"
Title="DemoFlyoutPage"
FlyoutLayoutBehavior="Default">

<FlyoutPage.Flyout>
<ContentPage Title="The Flyout" BackgroundColor="DarkBlue">
<VerticalStackLayout>
<Label Text="This is FlyoutPage Flyout"
FontAttributes="Bold"
FontSize="20"
TextColor="White"
HorizontalTextAlignment="Center"
Margin="20"/>
<Button Clicked="OnClicked" Text="Change Title"/>
</VerticalStackLayout>
</ContentPage>
</FlyoutPage.Flyout>

<FlyoutPage.Detail>
<NavigationPage BarBackgroundColor="Yellow" BarTextColor="Red" Title="Title 1" x:Name="NavigationPage">
<x:Arguments>
<ContentPage BackgroundColor="DarkRed">
<VerticalStackLayout>
<Label Text="This is FlyoutPage Detail"
FontAttributes="Bold"
FontSize="20"
TextColor="White"
HorizontalTextAlignment="Center"
Margin="20"/>
<Button x:Name="button" Clicked="OnClicked" AutomationId="Button" Text="Change Title"/>
</VerticalStackLayout>
</ContentPage>
</x:Arguments>
</NavigationPage>
</FlyoutPage.Detail>

</FlyoutPage>
37 changes: 37 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue19859.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace Maui.Controls.Sample.Issues
{
[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 19859, "NavigationPage: BarBackgroundColor, BarTextColor and Title not updating", PlatformAffected.Android)]
public partial class Issue19859 : FlyoutPage
{
public Issue19859()
{
InitializeComponent();
}

private static int _count = 0;

private void OnClicked(object sender, EventArgs e)
{
var oldBarBackgroundColor = NavigationPage.BarBackgroundColor;
NavigationPage.BarBackgroundColor = oldBarBackgroundColor.Equals(Colors.Yellow)
? Colors.Red
: Colors.Yellow;
var newBarBackgroundColor = NavigationPage.BarBackgroundColor;

var oldBarTextColor = NavigationPage.BarTextColor;
NavigationPage.BarTextColor = oldBarTextColor.Equals(Colors.Yellow)
? Colors.Red
: Colors.Yellow;
var newBarTextColor = NavigationPage.BarTextColor;

var oldTitle = NavigationPage.Title;
NavigationPage.Title = oldTitle == "Title 1"
? "Title 2"
: "Title 1";
var newTitle = NavigationPage.Title;

button.Text = $"{_count++}";
}
}
}
29 changes: 29 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue7453.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Maui.Controls.Sample.Issues.Issue7453"
FlyoutBehavior="Disabled"
Title="Issue7453">
<TabBar AutomationId="TabBar">
<Tab Title="Nested Tabs" AutomationId="tabbar">
<ShellContent x:Name="tab" Title="Home">
<ContentPage>
<StackLayout HorizontalOptions="Center" Spacing="30">
<HorizontalStackLayout>
<Label Text="Current Shell Title : " FontAttributes="Bold"/>
<Label Text="{Binding Source={x:Reference tab}, Path=Title}" AutomationId="LabelId" />
</HorizontalStackLayout>
<Button Text="Change Title" AutomationId="ChangeShellContentTitle" VerticalOptions="Center" HorizontalOptions="Center" WidthRequest="100" HeightRequest="40" Clicked="OnButtonClicked"/>
</StackLayout>
</ContentPage>
</ShellContent>

<ShellContent Title="Settings">
<ContentPage>
<Label Text="This is Settings page"/>
</ContentPage>
</ShellContent>
</Tab>
</TabBar>

</Shell>
16 changes: 16 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue7453.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Maui.Controls.Sample.Issues;

[XamlCompilation(XamlCompilationOptions.Compile)]
[Issue(IssueTracker.Github, 7453, "ShellContent Title doesn't observe changes to bound properties", PlatformAffected.UWP | PlatformAffected.Android)]
public partial class Issue7453 : Shell
{
public Issue7453()
{
InitializeComponent();
}

private void OnButtonClicked(object sender, EventArgs e)
{
this.tab.Title = "Updated title";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?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:issues="clr-namespace:Maui.Controls.Sample.Issues"
x:Class="Maui.Controls.Sample.Issues.RenderingPerformance"
Title="RenderingPerformance">

<Grid Padding="24" RowDefinitions="Auto,Auto,*" RowSpacing="8">
<Button x:Name="StartButton" Clicked="ButtonClicked" Text="Start" AutomationId="StartButton" />
<Label Grid.Row="1" Text="Do not press 'Start' more than once, just wait." />

<ScrollView Grid.Row="2">
<ContentView>
<VerticalStackLayout x:Name="BindableContainer" BindableLayout.ItemsSource="{Binding Models}">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Border Margin="0,16" Padding="8" StrokeShape="RoundRectangle 8" Background="LightBlue">
<Grid RowDefinitions="Auto,Auto,Auto">
<Label Text="{Binding Header}" />
<Label Text="{Binding Content}" Grid.Row="1" />
<VerticalStackLayout Grid.Row="2" BindableLayout.ItemsSource="{Binding SubModels}" Margin="16,0">
<BindableLayout.ItemTemplate>
<DataTemplate>
<ContentView>
<VerticalStackLayout Margin="0,8">
<Label Text="{Binding Header}" />
<issues:MeasuredLabel IsMeasured="{Binding IsMeasured}" Text="{Binding Content}" />
</VerticalStackLayout>
</ContentView>
</DataTemplate>
</BindableLayout.ItemTemplate>
</VerticalStackLayout>
</Grid>
</Border>
</DataTemplate>
</BindableLayout.ItemTemplate>
</VerticalStackLayout>
</ContentView>
</ScrollView>
</Grid>
</ContentPage>
Loading

0 comments on commit 7fa653b

Please sign in to comment.