Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 38977a3

Browse files
committed
Merge branch '4.8.0' into 5.0.0
2 parents 2131ea1 + 93f3cf8 commit 38977a3

File tree

17 files changed

+308
-29
lines changed

17 files changed

+308
-29
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
4+
using System.Text;
5+
using Xamarin.Forms.CustomAttributes;
6+
using Xamarin.Forms.Internals;
7+
8+
9+
#if UITEST
10+
using Xamarin.UITest;
11+
using NUnit.Framework;
12+
using Xamarin.Forms.Core.UITests;
13+
#endif
14+
15+
namespace Xamarin.Forms.Controls.Issues
16+
{
17+
[Preserve(AllMembers = true)]
18+
[Issue(IssueTracker.Github, 11769, "[Bug] Shell throws exception when delay adding Shell Content", issueTestNumber: 2)]
19+
#if UITEST
20+
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github10000)]
21+
[NUnit.Framework.Category(UITestCategories.Shell)]
22+
#endif
23+
24+
public class Issue11769_DelayedShellContent : TestShell
25+
{
26+
protected override void Init()
27+
{
28+
Items.Add(new FlyoutItem()
29+
{
30+
Items =
31+
{
32+
new Tab()
33+
}
34+
});
35+
36+
Device.InvokeOnMainThreadAsync(() =>
37+
{
38+
var shellContent = new ShellContent()
39+
{
40+
Content = new ContentPage()
41+
{
42+
Content = new Label() { Text = "Success" }
43+
}
44+
};
45+
46+
Items[0].Items[0].Items.Add(shellContent);
47+
});
48+
}
49+
50+
#if UITEST
51+
[Test]
52+
public void DelayedAddingOfShellContentDoesntCrash()
53+
{
54+
RunningApp.WaitForElement("Success");
55+
}
56+
#endif
57+
}
58+
59+
[Preserve(AllMembers = true)]
60+
[Issue(IssueTracker.Github, 11769, "[Bug] Shell throws exception when delay adding Shell Section", issueTestNumber: 1)]
61+
#if UITEST
62+
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github10000)]
63+
[NUnit.Framework.Category(UITestCategories.Shell)]
64+
#endif
65+
66+
public class Issue11769_DelayedShellSection : TestShell
67+
{
68+
protected override void Init()
69+
{
70+
Items.Add(new FlyoutItem());
71+
Device.InvokeOnMainThreadAsync(() =>
72+
{
73+
var tab = new Tab()
74+
{
75+
Items =
76+
{
77+
new ShellContent()
78+
{
79+
Content = new ContentPage()
80+
{
81+
Content = new Label() { Text = "Success" }
82+
}
83+
}
84+
}
85+
};
86+
87+
Items[0].Items.Add(tab);
88+
});
89+
}
90+
91+
#if UITEST
92+
[Test]
93+
public void DelayedAddingOfShellSectionDoesntCrash()
94+
{
95+
RunningApp.WaitForElement("Success");
96+
}
97+
#endif
98+
}
99+
100+
[Preserve(AllMembers = true)]
101+
[Issue(IssueTracker.Github, 11769, "[Bug] Shell throws exception when delay adding Shell Item", issueTestNumber: 0)]
102+
#if UITEST
103+
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github10000)]
104+
[NUnit.Framework.Category(UITestCategories.Shell)]
105+
#endif
106+
107+
public class Issue11769_DelayedShellItem : TestShell
108+
{
109+
protected override void Init()
110+
{
111+
Device.InvokeOnMainThreadAsync(() =>
112+
{
113+
var page = AddBottomTab("Success");
114+
page.Content = new Label() { Text = "Success" };
115+
});
116+
}
117+
118+
#if UITEST
119+
[Test]
120+
public void DelayedAddingOfShellItemDoesntCrash()
121+
{
122+
RunningApp.WaitForElement("Success");
123+
}
124+
#endif
125+
}
126+
}

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue3390.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ protected override void Init()
2525
WidthRequest = 50,
2626
HeightRequest = 50,
2727
CornerRadius = 25,
28+
BackgroundColor = Color.Accent
2829
};
2930

3031
btn.Command = new Command(async () =>

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue8836.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ protected override void Init()
1212
var stack = new StackLayout();
1313

1414
stack.Children.Add(new Label {Text = "Click the button to toggle the clear button visibility."});
15+
stack.Children.Add(new Label { Text = "The default state when this page loaded is NEVER. The clear button should not be visible until you click toggle." });
1516

1617
Entry = new Entry
1718
{
18-
Text = "Clear Button: While Editing",
19-
ClearButtonVisibility = ClearButtonVisibility.WhileEditing
19+
Text = "Clear Button: Never",
20+
ClearButtonVisibility = ClearButtonVisibility.Never
2021
};
2122
stack.Children.Add(Entry);
2223

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<Compile Include="$(MSBuildThisFileDirectory)Issue11794.xaml.cs">
3030
<DependentUpon>Issue11794.xaml</DependentUpon>
3131
</Compile>
32+
<Compile Include="$(MSBuildThisFileDirectory)Issue11769.cs" />
3233
<Compile Include="$(MSBuildThisFileDirectory)Issue8613.cs" />
3334
<Compile Include="$(MSBuildThisFileDirectory)Issue9137.cs" />
3435
<Compile Include="$(MSBuildThisFileDirectory)Issue8691.cs" />
@@ -1785,7 +1786,7 @@
17851786
</EmbeddedResource>
17861787
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11653.xaml">
17871788
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
1788-
</EmbeddedResource>
1789+
</EmbeddedResource>
17891790
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Issue11496.xaml">
17901791
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
17911792
</EmbeddedResource>

Xamarin.Forms.Core.UnitTests/ShellUriHandlerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ public async Task RelativeNavigationWithRoute()
379379

380380
}
381381

382-
383382
[Test]
384383
public async Task ConvertToStandardFormat()
385384
{

Xamarin.Forms.Core/Shell/Shell.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ async void SetCurrentItem()
804804
try
805805
{
806806
var location = CurrentState.Location;
807-
var navRequest = ShellUriHandler.GetNavigationRequest(this, ((ShellNavigationState)location).FullLocation, false);
807+
var navRequest = ShellUriHandler.GetNavigationRequest(this, ((ShellNavigationState)location).FullLocation, false, false);
808808

809809
if (navRequest != null)
810810
{

Xamarin.Forms.Core/Shell/ShellUriHandler.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static Uri ConvertToStandardFormat(string routeScheme, string routeHost,
7979
return new Uri(uri);
8080
}
8181

82-
internal static NavigationRequest GetNavigationRequest(Shell shell, Uri uri, bool enableRelativeShellRoutes = false)
82+
internal static NavigationRequest GetNavigationRequest(Shell shell, Uri uri, bool enableRelativeShellRoutes = false, bool throwNavigationErrorAsException = true)
8383
{
8484
uri = FormatUri(uri, shell);
8585
// figure out the intent of the Uri
@@ -97,7 +97,12 @@ internal static NavigationRequest GetNavigationRequest(Shell shell, Uri uri, boo
9797

9898

9999
if (possibleRouteMatches.Count == 0)
100-
throw new ArgumentException($"unable to figure out route for: {uri}", nameof(uri));
100+
{
101+
if(throwNavigationErrorAsException)
102+
throw new ArgumentException($"unable to figure out route for: {uri}", nameof(uri));
103+
104+
return null;
105+
}
101106
else if (possibleRouteMatches.Count > 1)
102107
{
103108
string[] matches = new string[possibleRouteMatches.Count];
@@ -109,8 +114,11 @@ internal static NavigationRequest GetNavigationRequest(Shell shell, Uri uri, boo
109114
}
110115

111116
string matchesFound = String.Join(",", matches);
112-
throw new ArgumentException($"Ambiguous routes matched for: {uri} matches found: {matchesFound}", nameof(uri));
113117

118+
if (throwNavigationErrorAsException)
119+
throw new ArgumentException($"Ambiguous routes matched for: {uri} matches found: {matchesFound}", nameof(uri));
120+
121+
return null;
114122
}
115123

116124
var theWinningRoute = possibleRouteMatches[0];

Xamarin.Forms.Platform.UAP/FormsTextBox.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ protected override void OnApplyTemplate()
163163
_DeleteButtonVisibleStateGroups = stateGroups.SingleOrDefault(sg => sg.Name == "ButtonStates");
164164
if (_DeleteButtonVisibleStateGroups != null)
165165
_DeleteButtonVisibleState = _DeleteButtonVisibleStateGroups.States.SingleOrDefault(s => s.Name == "ButtonVisible");
166+
UpdateClearButtonVisible();
166167
}
167168

168169
_scrollViewer= GetTemplateChild("ContentElement") as ScrollViewer;
@@ -387,21 +388,26 @@ void SyncBaseText()
387388
SelectionStart = base.Text.Length;
388389
}
389390

390-
static void ClearButtonVisibleChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
391+
void UpdateClearButtonVisible()
391392
{
392-
var textBox = (FormsTextBox)dependencyObject;
393-
var visibleState = textBox._DeleteButtonVisibleState;
394-
var states = textBox._DeleteButtonVisibleStateGroups?.States;
393+
var visibleState = _DeleteButtonVisibleState;
394+
var states = _DeleteButtonVisibleStateGroups?.States;
395395

396396
if (states != null && visibleState != null)
397397
{
398-
if (textBox.ClearButtonVisible && !states.Contains(visibleState))
398+
if (ClearButtonVisible && !states.Contains(visibleState))
399399
states.Add(visibleState);
400400
else
401401
states.Remove(visibleState);
402402
}
403403
}
404404

405+
static void ClearButtonVisibleChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
406+
{
407+
var textBox = (FormsTextBox)dependencyObject;
408+
textBox.UpdateClearButtonVisible();
409+
}
410+
405411
static void TextPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
406412
{
407413
var textBox = (FormsTextBox)dependencyObject;

Xamarin.Forms.Platform.UAP/Shell/ShellItemRenderer.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ internal void SetShellContext(ShellRenderer context)
9898
internal void NavigateToShellItem(ShellItem newItem, bool animate)
9999
{
100100
UnhookEvents(ShellItem);
101+
102+
if (newItem?.CurrentItem?.CurrentItem == null)
103+
return;
104+
101105
ShellItem = newItem;
102106

103107
if (newItem.CurrentItem == null)

Xamarin.Forms.Platform.UAP/Shell/ShellRenderer.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ void OnShellNavigated(object sender, ShellNavigatedEventArgs e)
259259

260260
void UpdateToolBar()
261261
{
262+
if (SelectedItem == null)
263+
return;
264+
262265
if(_shell.Navigation.NavigationStack.Count > 1)
263266
{
264267
IsBackEnabled = true;

0 commit comments

Comments
 (0)