Skip to content

Commit a447ce0

Browse files
committed
Refactor MainActivity, MainApplication, and Breadcrumb
Refactored `MainActivity` to a single-line declaration for simplicity. Streamlined `MainApplication` by moving the constructor inline and removing its explicit body. Updated `Breadcrumb.xaml.cs` to use the C# range operator (`[..]`) for cleaner and more concise syntax in LINQ expressions and list operations.
1 parent ae05116 commit a447ce0

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

Demo/Platforms/Android/MainActivity.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44
namespace App;
55

66
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
7-
public class MainActivity : MauiAppCompatActivity
8-
{
9-
}
7+
public class MainActivity : MauiAppCompatActivity;

Demo/Platforms/Android/MainApplication.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
namespace App;
55

66
[Application]
7-
public class MainApplication : MauiApplication
7+
public class MainApplication(IntPtr handle, JniHandleOwnership ownership) : MauiApplication(handle, ownership)
88
{
9-
public MainApplication(IntPtr handle, JniHandleOwnership ownership) : base(handle, ownership)
10-
{
11-
}
12-
139
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
1410
}

Scr/Breadcrumb.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ async void BreadCrumbContainer_Loaded(object? sender, EventArgs e)
155155
BreadCrumbContainer.Loaded -= BreadCrumbContainer_Loaded;
156156

157157
// Get list of all pages in the NavigationStack that has a selectedPage title
158-
List<Page> pages = Navigation.NavigationStack.Select(x => x).Where(x => !string.IsNullOrEmpty(x?.Title)).ToList();
158+
List<Page> pages = [.. Navigation.NavigationStack.Select(x => x).Where(x => !string.IsNullOrEmpty(x?.Title))];
159159

160160
// If any pages, make the control visible
161161
BreadCrumbsScrollView.IsVisible = pages.Count > 0;
@@ -332,13 +332,13 @@ async Task GoBack(Page selectedPage)
332332
}
333333

334334
// Get all pages after and including selectedPage
335-
List<Page> pages = Navigation.NavigationStack.SkipWhile(x => x != selectedPage).ToList();
335+
List<Page> pages = [.. Navigation.NavigationStack.SkipWhile(x => x != selectedPage)];
336336

337337
// Remove selectedPage
338338
pages.Remove(selectedPage);
339339

340340
// Remove current page (this will be removed with a PopAsync after all other relevant pages are removed)
341-
pages = pages.Take(pages.Count - 1).ToList();
341+
pages = [.. pages.Take(pages.Count - 1)];
342342

343343
// Remove all pages left in list (i.e. all pages after selectedPage, minus the current page)
344344
foreach(Page page in pages)

0 commit comments

Comments
 (0)