1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-22 03:03:46 +00:00

Account switching

This commit is contained in:
Matt Portune
2022-01-16 22:43:37 -05:00
parent 86397a6f1e
commit ebae2585f6
129 changed files with 3883 additions and 1265 deletions

View File

@@ -1,7 +1,5 @@
using Bit.App.Models;
using Bit.App.Resources;
using Bit.Core.Abstractions;
using Bit.Core.Utilities;
using System;
using System.Threading.Tasks;
using Bit.App.Utilities;
@@ -11,8 +9,6 @@ namespace Bit.App.Pages
{
public partial class LoginPage : BaseContentPage
{
private readonly IMessagingService _messagingService;
private readonly IStorageService _storageService;
private readonly LoginPageViewModel _vm;
private readonly AppOptions _appOptions;
@@ -20,9 +16,6 @@ namespace Bit.App.Pages
public LoginPage(string email = null, AppOptions appOptions = null)
{
_storageService = ServiceContainer.Resolve<IStorageService>("storageService");
_messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
_messagingService.Send("showStatusBar", true);
_appOptions = appOptions;
InitializeComponent();
_vm = BindingContext as LoginPageViewModel;
@@ -33,7 +26,6 @@ namespace Bit.App.Pages
() => Device.BeginInvokeOnMainThread(async () => await UpdateTempPasswordAsync());
_vm.CloseAction = async () =>
{
_messagingService.Send("showStatusBar", false);
await Navigation.PopModalAsync();
};
_vm.Email = email;
@@ -42,6 +34,12 @@ namespace Bit.App.Pages
{
ToolbarItems.RemoveAt(0);
}
if (_appOptions?.ShowAccountSwitcher ?? false)
{
_appOptions.ShowAccountSwitcher = false;
ToolbarItems.Add(_accountAvatar);
ToolbarItems.Remove(_closeItem);
}
_email.ReturnType = ReturnType.Next;
_email.ReturnCommand = new Command(() => _masterPassword.Focus());
@@ -61,6 +59,11 @@ namespace Bit.App.Pages
protected override async void OnAppearing()
{
base.OnAppearing();
_mainContent.Content = _mainLayout;
if (_appOptions?.ShowAccountSwitcher ?? false)
{
_vm.AvatarImageSource = await GetAvatarImageSourceAsync();
}
await _vm.InitAsync();
if (!_inputFocused)
{
@@ -130,5 +133,22 @@ namespace Bit.App.Pages
var page = new UpdateTempPasswordPage();
await Navigation.PushModalAsync(new NavigationPage(page));
}
private async void AccountSwitch_Clicked(object sender, EventArgs e)
{
if (_accountListOverlay.IsVisible)
{
await ShowAccountListAsync(false, _accountListView, _accountListOverlay);
}
else
{
await ShowAccountListAsync(true, _accountListView, _accountListOverlay);
}
}
private async void AccountRow_Selected(object sender, SelectedItemChangedEventArgs e)
{
await AccountRowSelectedAsync(sender, e, _accountListView, _accountListOverlay);
}
}
}