mirror of
https://github.com/bitwarden/android.git
synced 2025-01-13 19:57:37 +03:00
PM-3350 Fixed iOS Share extension lazy views loading and an issue with the avatar loading. Also discovered issue with TapGestureRecognizer not working on MAUI Embedding
This commit is contained in:
parent
5712639492
commit
5f12bb9747
7 changed files with 33 additions and 44 deletions
|
@ -10,8 +10,8 @@ namespace Bit.App.Pages
|
|||
{
|
||||
public class BaseContentPage : ContentPage
|
||||
{
|
||||
private IStateService _stateService;
|
||||
private IDeviceActionService _deviceActionService;
|
||||
private readonly LazyResolve<IStateService> _stateService = new LazyResolve<IStateService>();
|
||||
private readonly LazyResolve<IDeviceActionService> _deviceActionService = new LazyResolve<IDeviceActionService>();
|
||||
|
||||
protected int ShowModalAnimationDelay = 400;
|
||||
protected int ShowPageAnimationDelay = 100;
|
||||
|
@ -122,41 +122,28 @@ namespace Bit.App.Pages
|
|||
|
||||
protected async Task<bool> ShowAccountSwitcherAsync()
|
||||
{
|
||||
return await _stateService.GetActiveUserIdAsync() != null;
|
||||
return await _stateService.Value.GetActiveUserIdAsync() != null;
|
||||
}
|
||||
|
||||
protected async Task<AvatarImageSource> GetAvatarImageSourceAsync(bool useCurrentActiveAccount = true)
|
||||
{
|
||||
if (useCurrentActiveAccount)
|
||||
{
|
||||
var user = await _stateService.GetActiveUserCustomDataAsync(a => (a?.Profile?.UserId, a?.Profile?.Name, a?.Profile?.Email, a?.Profile?.AvatarColor));
|
||||
var user = await _stateService.Value.GetActiveUserCustomDataAsync(a => (a?.Profile?.UserId, a?.Profile?.Name, a?.Profile?.Email, a?.Profile?.AvatarColor));
|
||||
return new AvatarImageSource(user.UserId, user.Name, user.Email, user.AvatarColor);
|
||||
}
|
||||
return new AvatarImageSource();
|
||||
}
|
||||
|
||||
private void SetServices()
|
||||
{
|
||||
if (_stateService == null)
|
||||
{
|
||||
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
|
||||
}
|
||||
if (_deviceActionService == null)
|
||||
{
|
||||
_deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SaveActivityAsync()
|
||||
{
|
||||
SetServices();
|
||||
if (await _stateService.GetActiveUserIdAsync() == null)
|
||||
if (await _stateService.Value.GetActiveUserIdAsync() == null)
|
||||
{
|
||||
// Fresh install and/or all users logged out won't have an active user, skip saving last active time
|
||||
return;
|
||||
}
|
||||
|
||||
await _stateService.SetLastActiveTimeAsync(_deviceActionService.GetActiveTime());
|
||||
await _stateService.Value.SetLastActiveTimeAsync(_deviceActionService.Value.GetActiveTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.App.Behaviors;
|
||||
using Microsoft.Maui.Controls;
|
||||
using Microsoft.Maui;
|
||||
using CommunityToolkit.Maui.Converters;
|
||||
using CommunityToolkit.Maui.ImageSources;
|
||||
using CommunityToolkit.Maui;
|
||||
using CommunityToolkit.Maui.Core;
|
||||
using CommunityToolkit.Maui.Layouts;
|
||||
using CommunityToolkit.Maui.Views;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
|
@ -60,7 +52,7 @@ namespace Bit.App.Pages
|
|||
|
||||
private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||
{
|
||||
if (!_lazyDeletionDateTimePicker.IsLoaded
|
||||
if (!_lazyDeletionDateTimePicker.HasLazyViewLoaded
|
||||
&&
|
||||
e.PropertyName == nameof(SendAddEditPageViewModel.ShowDeletionCustomPickers)
|
||||
&&
|
||||
|
@ -69,7 +61,7 @@ namespace Bit.App.Pages
|
|||
_lazyDeletionDateTimePicker.LoadViewAsync();
|
||||
}
|
||||
|
||||
if (!_lazyExpirationDateTimePicker.IsLoaded
|
||||
if (!_lazyExpirationDateTimePicker.HasLazyViewLoaded
|
||||
&&
|
||||
e.PropertyName == nameof(SendAddEditPageViewModel.ShowExpirationCustomPickers)
|
||||
&&
|
||||
|
|
|
@ -150,6 +150,7 @@
|
|||
InputTransparent="False"
|
||||
Spacing="0"
|
||||
SemanticProperties.Description="{Binding OptionsAccessilibityText}">
|
||||
<!-- TODO: TapGestureRecognizer not working https://github.com/dotnet/maui/issues/17948 -->
|
||||
<StackLayout.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="OptionsHeader_Tapped" />
|
||||
</StackLayout.GestureRecognizers>
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Bit.App.Pages
|
|||
public partial class SendAddOnlyPage : BaseContentPage
|
||||
{
|
||||
private readonly IVaultTimeoutService _vaultTimeoutService;
|
||||
private readonly LazyResolve<ILogger> _logger = new LazyResolve<ILogger>("logger");
|
||||
private readonly LazyResolve<ILogger> _logger = new LazyResolve<ILogger>();
|
||||
|
||||
private AppOptions _appOptions;
|
||||
private SendAddEditPageViewModel _vm;
|
||||
|
@ -61,6 +61,7 @@ namespace Bit.App.Pages
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await _vm.InitAsync();
|
||||
|
||||
if (!await _vm.LoadAsync())
|
||||
|
@ -70,7 +71,7 @@ namespace Bit.App.Pages
|
|||
}
|
||||
|
||||
_accountAvatar?.OnAppearing();
|
||||
await Device.InvokeOnMainThreadAsync(async () => _vm.AvatarImageSource = await GetAvatarImageSourceAsync());
|
||||
await MainThread.InvokeOnMainThreadAsync(async () => _vm.AvatarImageSource = await GetAvatarImageSourceAsync());
|
||||
|
||||
await HandleCreateRequest();
|
||||
if (string.IsNullOrWhiteSpace(_vm.Send?.Name))
|
||||
|
@ -86,10 +87,10 @@ namespace Bit.App.Pages
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnNavigatingFrom(NavigatingFromEventArgs args)
|
||||
{
|
||||
base.OnNavigatingFrom(args);
|
||||
|
||||
_accountAvatar?.OnDisappearing();
|
||||
}
|
||||
|
||||
|
@ -160,14 +161,21 @@ namespace Bit.App.Pages
|
|||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
void OptionsHeader_Tapped(object sender, EventArgs e)
|
||||
async void OptionsHeader_Tapped(object sender, EventArgs e)
|
||||
{
|
||||
_vm.ToggleOptionsCommand.Execute(null);
|
||||
|
||||
if (!_lazyOptionsView.IsLoaded)
|
||||
try
|
||||
{
|
||||
_lazyOptionsView.MainScrollView = _scrollView;
|
||||
_lazyOptionsView.LoadViewAsync();
|
||||
_vm.ToggleOptionsCommand.Execute(null);
|
||||
|
||||
if (!_lazyOptionsView.HasLazyViewLoaded)
|
||||
{
|
||||
_lazyOptionsView.MainScrollView = _scrollView;
|
||||
await _lazyOptionsView.LoadViewAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Value.Exception(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace Bit.iOS.Core.Handlers
|
|||
|
||||
private static void UpdateTintColor(IEditorHandler handler, IEditor editor)
|
||||
{
|
||||
handler.PlatformView.TintColor = editor.TextColor.ToPlatform();
|
||||
// Note: the default black value is to avoid an error on the iOS extensions while lazy loading a view
|
||||
handler.PlatformView.TintColor = editor.TextColor.ToPlatform(Colors.Black);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,10 @@ namespace Bit.iOS.Core.Handlers
|
|||
{
|
||||
public static void Setup()
|
||||
{
|
||||
EntryHandler.Mapper.AppendToMapping("CustomEntryHandler", (handler, editor) =>
|
||||
EntryHandler.Mapper.AppendToMapping("CustomEntryHandler", (handler, entry) =>
|
||||
{
|
||||
handler.PlatformView.ClearButtonMode = UITextFieldViewMode.WhileEditing;
|
||||
UpdateTintColor(handler, editor);
|
||||
UpdateTintColor(handler, entry);
|
||||
iOSHelpers.SetBottomBorder(handler.PlatformView);
|
||||
|
||||
if (!ThemeHelpers.LightTheme)
|
||||
|
@ -24,9 +24,10 @@ namespace Bit.iOS.Core.Handlers
|
|||
EntryHandler.Mapper.AppendToMapping(nameof(IEntry.TextColor), UpdateTintColor);
|
||||
}
|
||||
|
||||
private static void UpdateTintColor(IEntryHandler handler, IEntry editor)
|
||||
private static void UpdateTintColor(IEntryHandler handler, IEntry entry)
|
||||
{
|
||||
handler.PlatformView.TintColor = editor.TextColor.ToPlatform();
|
||||
// Note: the default black value is to avoid an error on the iOS extensions while lazy loading a view
|
||||
handler.PlatformView.TintColor = entry.TextColor.ToPlatform(Colors.Black);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
<Compile Include="ExtensionNavigationController.designer.cs">
|
||||
<DependentUpon>ExtensionNavigationController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainViewController.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="..\iOS\Resources\logo_white%403x.png">
|
||||
|
|
Loading…
Reference in a new issue