1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-14 07:13:33 +00:00

Improve Theming (#1707)

* 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
This commit is contained in:
Federico Maccaroni
2022-01-24 17:20:48 -03:00
committed by GitHub
parent 939db8ebe0
commit 74e90da662
16 changed files with 264 additions and 84 deletions

View File

@@ -1,15 +1,15 @@
using Bit.App.Resources;
using System;
using System;
using System.Threading.Tasks;
using Bit.App.Resources;
using Bit.App.Styles;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
namespace Bit.App.Pages
{
public partial class GeneratorPage : BaseContentPage
public partial class GeneratorPage : BaseContentPage, IThemeDirtablePage
{
private readonly IBroadcasterService _broadcasterService;
@@ -49,7 +49,7 @@ namespace Bit.App.Pages
}
if (isIos)
{
_typePicker.On<iOS>().SetUpdateMode(UpdateMode.WhenFinished);
_typePicker.On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUpdateMode(UpdateMode.WhenFinished);
}
}
@@ -61,18 +61,19 @@ namespace Bit.App.Pages
protected async override void OnAppearing()
{
base.OnAppearing();
lblPassword.IsVisible = true;
if (!_fromTabPage)
{
await InitAsync();
}
_broadcasterService.Subscribe(nameof(GeneratorPage), async (message) =>
_broadcasterService.Subscribe(nameof(GeneratorPage), (message) =>
{
if (message.Command == "updatedTheme")
{
Device.BeginInvokeOnMainThread(() =>
{
_vm.RedrawPassword();
});
Device.BeginInvokeOnMainThread(() => _vm.RedrawPassword());
}
});
}
@@ -80,6 +81,9 @@ namespace Bit.App.Pages
protected override void OnDisappearing()
{
base.OnDisappearing();
lblPassword.IsVisible = false;
_broadcasterService.Unsubscribe(nameof(GeneratorPage));
}
@@ -141,5 +145,12 @@ namespace Bit.App.Pages
await Navigation.PopModalAsync();
}
}
public override async Task UpdateOnThemeChanged()
{
await base.UpdateOnThemeChanged();
await Device.InvokeOnMainThreadAsync(() => _vm?.RedrawPassword());
}
}
}