mirror of
https://github.com/bitwarden/mobile.git
synced 2024-06-24 10:14:55 +02:00
* Improved theming logic and performance, also fixed some issues regarding changing the theme after vault timeout and fixed theme applying on password generator/history * Removed messenger from theme update, and now the navigation stack is traversed and each IThemeDirtablePage gets theme updated * Improved code on update theme on pages
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Bit.App.Utilities
|
|
{
|
|
public static class PageExtensions
|
|
{
|
|
public static async Task TraverseNavigationRecursivelyAsync(this Page page, Func<Page, Task> actionOnPage)
|
|
{
|
|
if (page?.Navigation?.ModalStack != null)
|
|
{
|
|
foreach (var p in page.Navigation.ModalStack)
|
|
{
|
|
if (p is NavigationPage modalNavPage)
|
|
{
|
|
await TraverseNavigationStackRecursivelyAsync(modalNavPage.CurrentPage, actionOnPage);
|
|
}
|
|
else
|
|
{
|
|
await TraverseNavigationStackRecursivelyAsync(p, actionOnPage);
|
|
}
|
|
}
|
|
}
|
|
|
|
await TraverseNavigationStackRecursivelyAsync(page, actionOnPage);
|
|
}
|
|
|
|
private static async Task TraverseNavigationStackRecursivelyAsync(this Page page, Func<Page, Task> actionOnPage)
|
|
{
|
|
if (page is MultiPage<Page> multiPage && multiPage.Children != null)
|
|
{
|
|
foreach (var p in multiPage.Children)
|
|
{
|
|
await TraverseNavigationStackRecursivelyAsync(p, actionOnPage);
|
|
}
|
|
}
|
|
|
|
if (page is NavigationPage && page.Navigation != null)
|
|
{
|
|
if (page.Navigation.NavigationStack != null)
|
|
{
|
|
foreach (var p in page.Navigation.NavigationStack)
|
|
{
|
|
await TraverseNavigationStackRecursivelyAsync(p, actionOnPage);
|
|
}
|
|
}
|
|
}
|
|
|
|
await actionOnPage(page);
|
|
}
|
|
}
|
|
}
|