Skip to content

Commit 6846c59

Browse files
kubaflormarinho
authored andcommitted
Fixed controls sample navigation crash
1 parent 2719d46 commit 6846c59

File tree

8 files changed

+13
-50
lines changed

8 files changed

+13
-50
lines changed

src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTabbedPageSwipePage.xaml.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,11 @@ namespace Maui.Controls.Sample.Pages
88
{
99
public partial class AndroidTabbedPageSwipePage : Microsoft.Maui.Controls.TabbedPage
1010
{
11-
ICommand? _returnToPlatformSpecificsPage;
12-
1311
public AndroidTabbedPageSwipePage()
1412
{
1513
InitializeComponent();
1614
}
1715

18-
public AndroidTabbedPageSwipePage(ICommand restore)
19-
{
20-
InitializeComponent();
21-
22-
_returnToPlatformSpecificsPage = restore;
23-
}
24-
2516
void OnSwipePagingButtonClicked(object sender, EventArgs e)
2617
{
2718
On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().SetIsSwipePagingEnabled(!On<Microsoft.Maui.Controls.PlatformConfiguration.Android>().IsSwipePagingEnabled());
@@ -34,7 +25,7 @@ void OnSmoothScrollButtonClicked(object sender, EventArgs e)
3425

3526
void OnReturnButtonClicked(object sender, EventArgs e)
3627
{
37-
_returnToPlatformSpecificsPage?.Execute(null);
28+
Navigation.PopAsync();
3829
}
3930
}
4031
}

src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/Android/AndroidTitleViewPage.xaml.cs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,14 @@ namespace Maui.Controls.Sample.Pages
66
{
77
public partial class AndroidTitleViewPage : ContentPage
88
{
9-
readonly ICommand? _returnToPlatformSpecificsPage;
10-
119
public AndroidTitleViewPage()
1210
{
1311
InitializeComponent();
1412
}
1513

16-
public AndroidTitleViewPage(ICommand restore)
17-
{
18-
InitializeComponent();
19-
_returnToPlatformSpecificsPage = restore;
20-
}
21-
2214
void OnReturnButtonClicked(object sender, EventArgs e)
2315
{
24-
if (_returnToPlatformSpecificsPage == null)
25-
return;
26-
27-
_returnToPlatformSpecificsPage.Execute(null);
16+
Navigation.PopAsync();
2817
}
2918
}
3019
}

src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSLargeTitlePage.xaml.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ namespace Maui.Controls.Sample.Pages
88
{
99
public partial class iOSLargeTitlePage : ContentPage
1010
{
11-
ICommand _returnToPlatformSpecificsPage;
12-
13-
public iOSLargeTitlePage(ICommand restore)
11+
public iOSLargeTitlePage()
1412
{
1513
InitializeComponent();
16-
_returnToPlatformSpecificsPage = restore;
1714
}
1815

1916
void OnButtonClicked(object sender, EventArgs e)
@@ -34,7 +31,7 @@ void OnButtonClicked(object sender, EventArgs e)
3431

3532
void OnReturnButtonClicked(object sender, EventArgs e)
3633
{
37-
_returnToPlatformSpecificsPage.Execute(null);
34+
Navigation.PopAsync();
3835
}
3936
}
4037
}

src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSScrollViewPage.xaml.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ namespace Maui.Controls.Sample.Pages
77
{
88
public partial class iOSScrollViewPage : Microsoft.Maui.Controls.FlyoutPage
99
{
10-
ICommand _returnToPlatformSpecificsPage;
11-
12-
public iOSScrollViewPage(ICommand restore)
10+
public iOSScrollViewPage()
1311
{
1412
InitializeComponent();
15-
_returnToPlatformSpecificsPage = restore;
1613
}
1714

1815
void OnButtonClicked(object sender, EventArgs e)
@@ -22,7 +19,7 @@ void OnButtonClicked(object sender, EventArgs e)
2219

2320
void OnReturnButtonClicked(object sender, EventArgs e)
2421
{
25-
_returnToPlatformSpecificsPage.Execute(null);
22+
Navigation.PopAsync();
2623
}
2724
}
2825
}

src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTitleViewPage.xaml.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,15 @@ namespace Maui.Controls.Sample.Pages
66
{
77
public partial class iOSTitleViewPage : ContentPage
88
{
9-
ICommand _returnToPlatformSpecificsPage;
10-
11-
public iOSTitleViewPage(ICommand restore)
9+
public iOSTitleViewPage()
1210
{
1311
InitializeComponent();
14-
15-
_returnToPlatformSpecificsPage = restore;
1612
_searchBar.Effects.Add(Effect.Resolve("XamarinDocs.SearchBarEffect"));
1713
}
1814

1915
void OnReturnButtonClicked(object sender, EventArgs e)
2016
{
21-
_returnToPlatformSpecificsPage.Execute(null);
17+
Navigation.PopAsync();
2218
}
2319
}
2420
}

src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentNavigationBarPage.xaml.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ namespace Maui.Controls.Sample.Pages
88
{
99
public partial class iOSTranslucentNavigationBarPage : ContentPage
1010
{
11-
ICommand _returnToPlatformSpecificsPage;
12-
13-
public iOSTranslucentNavigationBarPage(ICommand restore)
11+
public iOSTranslucentNavigationBarPage()
1412
{
1513
InitializeComponent();
16-
_returnToPlatformSpecificsPage = restore;
1714
}
1815

1916
void OnTranslucentNavigationBarButtonClicked(object sender, EventArgs e)
@@ -23,7 +20,7 @@ void OnTranslucentNavigationBarButtonClicked(object sender, EventArgs e)
2320

2421
void OnReturnButtonClicked(object sender, EventArgs e)
2522
{
26-
_returnToPlatformSpecificsPage.Execute(null);
23+
Navigation.PopAsync();
2724
}
2825
}
2926
}

src/Controls/samples/Controls.Sample/Pages/PlatformSpecifics/iOS/iOSTranslucentTabbedPage.xaml.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
using System.Windows.Input;
33
using Microsoft.Maui.Controls.PlatformConfiguration;
44
using Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;
5-
65
namespace Maui.Controls.Sample.Pages
76
{
87
public partial class iOSTranslucentTabbedPage : Microsoft.Maui.Controls.TabbedPage
98
{
10-
ICommand returnToPlatformSpecificsPage;
11-
12-
public iOSTranslucentTabbedPage(ICommand restore)
9+
public iOSTranslucentTabbedPage()
1310
{
1411
InitializeComponent();
15-
returnToPlatformSpecificsPage = restore;
1612
}
1713

1814
void OnToggleButtonClicked(object sender, EventArgs e)
@@ -33,7 +29,7 @@ void OnToggleButtonClicked(object sender, EventArgs e)
3329

3430
void OnReturnButtonClicked(object sender, EventArgs e)
3531
{
36-
returnToPlatformSpecificsPage.Execute(null);
32+
Navigation.PopAsync();
3733
}
3834
}
3935
}

src/Controls/samples/Controls.Sample/ViewModels/PlatformSpecificsViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected override IEnumerable<SectionModel> CreateItems()
111111
new SectionModel(typeof(iOSTranslucentNavigationBarPage), "NavigationPage Translucent TabBar",
112112
"This iOS platform-specific is used to set the translucency mode of the tab bar on a NavigationPage."),
113113

114-
new SectionModel(typeof(MainPage), "TabbedPage Translucent TabBar",
114+
new SectionModel(typeof(iOSTranslucentTabbedPage), "TabbedPage Translucent TabBar",
115115
"This iOS platform-specific is used to set the translucency mode of the tab bar on a TabbedPage."),
116116

117117
#if MACCATALYST

0 commit comments

Comments
 (0)