mirror of
https://github.com/bitwarden/mobile
synced 2025-12-05 23:53:33 +00:00
wip
This commit is contained in:
@@ -7,18 +7,18 @@ namespace Bit.App.Controls
|
||||
{
|
||||
public static readonly BindableProperty AccountProperty = BindableProperty.Create(
|
||||
nameof(Account), typeof(AccountView), typeof(AccountViewCell), default(AccountView), BindingMode.OneWay);
|
||||
|
||||
|
||||
public AccountViewCell()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
public AccountView Account
|
||||
{
|
||||
get => GetValue(AccountProperty) as AccountView;
|
||||
set => SetValue(AccountProperty, value);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnPropertyChanged(string propertyName = null)
|
||||
{
|
||||
base.OnPropertyChanged(propertyName);
|
||||
@@ -33,4 +33,3 @@ namespace Bit.App.Controls
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Bit.App.Controls
|
||||
{
|
||||
AccountView = accountView;
|
||||
}
|
||||
|
||||
|
||||
public AccountView AccountView
|
||||
{
|
||||
get => _accountView;
|
||||
@@ -22,7 +22,7 @@ namespace Bit.App.Controls
|
||||
{
|
||||
get => AccountView.IsAccount;
|
||||
}
|
||||
|
||||
|
||||
public string AuthStatusText
|
||||
{
|
||||
get => AccountView.AuthStatus.ToString();
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace Bit.App.Controls
|
||||
public class AvatarImageSource : StreamImageSource
|
||||
{
|
||||
private string _data;
|
||||
|
||||
|
||||
public AvatarImageSource(string data = null)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
|
||||
public override Func<CancellationToken, Task<Stream>> Stream => GetStreamAsync;
|
||||
|
||||
private Task<Stream> GetStreamAsync(CancellationToken userToken = new CancellationToken())
|
||||
@@ -31,7 +31,7 @@ namespace Bit.App.Controls
|
||||
{
|
||||
string chars = null;
|
||||
string upperData = null;
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(_data))
|
||||
{
|
||||
chars = "..";
|
||||
@@ -41,11 +41,11 @@ namespace Bit.App.Controls
|
||||
upperData = _data.ToUpper();
|
||||
chars = upperData.Substring(0, 2).ToUpper();
|
||||
}
|
||||
|
||||
|
||||
var bgColor = StringToColor(upperData);
|
||||
var textColor = Color.White;;
|
||||
var textColor = Color.White;
|
||||
var size = 50;
|
||||
|
||||
|
||||
var bitmap = new SKBitmap(
|
||||
size * 2,
|
||||
size * 2,
|
||||
@@ -84,7 +84,7 @@ namespace Bit.App.Controls
|
||||
|
||||
return SKImage.FromBitmap(bitmap).Encode(SKEncodedImageFormat.Png, 100).AsStream();
|
||||
}
|
||||
|
||||
|
||||
private Color StringToColor(string str)
|
||||
{
|
||||
if (str == null)
|
||||
|
||||
@@ -15,6 +15,18 @@
|
||||
</ContentPage.BindingContext>
|
||||
|
||||
<ContentPage.ToolbarItems>
|
||||
<controls:ExtendedToolbarItem
|
||||
x:Name="_accountAvatar"
|
||||
x:Key="accountAvatar"
|
||||
IconImageSource="{Binding AvatarImageSource}"
|
||||
Clicked="AccountSwitch_Clicked"
|
||||
Order="Primary"
|
||||
Priority="-1"
|
||||
UseOriginalImage="True"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
AutomationProperties.Name="{u:I18n Account}" />
|
||||
<ToolbarItem x:Name="_closeItem" x:Key="closeItem" Text="{u:I18n Close}"
|
||||
Clicked="Close_Clicked" Order="Primary" Priority="-1" />
|
||||
<ToolbarItem
|
||||
Icon="cog_environment.png" Clicked="Environment_Clicked" Order="Primary"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
@@ -23,19 +35,6 @@
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<controls:ExtendedToolbarItem
|
||||
x:Name="_accountAvatar"
|
||||
x:Key="accountAvatar"
|
||||
IconImageSource="{Binding AvatarImageSource}"
|
||||
Clicked="AccountSwitch_Clicked"
|
||||
Order="Primary"
|
||||
Priority="-1"
|
||||
UseOriginalImage="True"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
AutomationProperties.Name="{u:I18n Account}" />
|
||||
<ToolbarItem x:Name="_closeItem" x:Key="closeItem" Text="{u:I18n Close}"
|
||||
Clicked="Close_Clicked" Order="Primary" />
|
||||
|
||||
<StackLayout x:Name="_mainLayout" x:Key="mainLayout" Spacing="0" Padding="10, 5">
|
||||
<StackLayout VerticalOptions="CenterAndExpand" Spacing="20">
|
||||
<Image
|
||||
|
||||
@@ -14,8 +14,6 @@ namespace Bit.App.Pages
|
||||
private readonly AppOptions _appOptions;
|
||||
private IBroadcasterService _broadcasterService;
|
||||
|
||||
private bool _appeared;
|
||||
|
||||
public HomePage(AppOptions appOptions = null)
|
||||
{
|
||||
_broadcasterService = ServiceContainer.Resolve<IBroadcasterService>("broadcasterService");
|
||||
@@ -29,9 +27,9 @@ namespace Bit.App.Pages
|
||||
_vm.StartEnvironmentAction = () => Device.BeginInvokeOnMainThread(async () => await StartEnvironmentAsync());
|
||||
UpdateLogo();
|
||||
|
||||
if (_appOptions?.IosExtension ?? false)
|
||||
if (!_appOptions?.IosExtension ?? false)
|
||||
{
|
||||
ToolbarItems.Add(_closeItem);
|
||||
ToolbarItems.Remove(_closeItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +42,15 @@ namespace Bit.App.Pages
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
_mainContent.Content = _mainLayout;
|
||||
if (await HasMultipleAccountsAsync())
|
||||
{
|
||||
_vm.AvatarImageSource = await GetAvatarImageSourceAsync(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToolbarItems.Remove(_accountAvatar);
|
||||
}
|
||||
_broadcasterService.Subscribe(nameof(HomePage), async (message) =>
|
||||
{
|
||||
if (message.Command == "updatedTheme")
|
||||
@@ -54,17 +61,6 @@ namespace Bit.App.Pages
|
||||
});
|
||||
}
|
||||
});
|
||||
if (_appeared)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_appeared = true;
|
||||
_mainContent.Content = _mainLayout;
|
||||
if (await HasMultipleAccountsAsync())
|
||||
{
|
||||
ToolbarItems.Add(_accountAvatar);
|
||||
_vm.AvatarImageSource = await GetAvatarImageSourceAsync(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDisappearing()
|
||||
|
||||
@@ -15,10 +15,8 @@
|
||||
<pages:LockPageViewModel />
|
||||
</ContentPage.BindingContext>
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||
<controls:ExtendedToolbarItem
|
||||
<ContentPage.ToolbarItems>
|
||||
<controls:ExtendedToolbarItem
|
||||
x:Name="_accountAvatar"
|
||||
x:Key="accountAvatar"
|
||||
IconImageSource="{Binding AvatarImageSource}"
|
||||
@@ -28,6 +26,11 @@
|
||||
UseOriginalImage="True"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
AutomationProperties.Name="{u:I18n Account}" />
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||
<ToolbarItem Icon="more_vert.png" Clicked="More_Clicked" Order="Primary"
|
||||
x:Name="_moreItem" x:Key="moreItem"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
|
||||
@@ -64,9 +64,12 @@ namespace Bit.App.Pages
|
||||
_mainContent.Content = _mainLayout;
|
||||
if (await HasMultipleAccountsAsync())
|
||||
{
|
||||
ToolbarItems.Add(_accountAvatar);
|
||||
_vm.AvatarImageSource = await GetAvatarImageSourceAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToolbarItems.Remove(_accountAvatar);
|
||||
}
|
||||
await _vm.InitAsync();
|
||||
if (!_vm.BiometricLock)
|
||||
{
|
||||
|
||||
@@ -16,14 +16,7 @@
|
||||
</ContentPage.BindingContext>
|
||||
|
||||
<ContentPage.ToolbarItems>
|
||||
<ToolbarItem x:Name="_closeItem" x:Key="closeItem" Text="{u:I18n Close}"
|
||||
Clicked="Close_Clicked" Order="Primary" Priority="-1" />
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||
<controls:ExtendedToolbarItem
|
||||
<controls:ExtendedToolbarItem
|
||||
x:Name="_accountAvatar"
|
||||
x:Key="accountAvatar"
|
||||
IconImageSource="{Binding AvatarImageSource}"
|
||||
@@ -33,6 +26,13 @@
|
||||
UseOriginalImage="True"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
AutomationProperties.Name="{u:I18n Account}" />
|
||||
<ToolbarItem x:Name="_closeItem" x:Key="closeItem" Text="{u:I18n Close}"
|
||||
Clicked="Close_Clicked" Order="Primary" Priority="-1" />
|
||||
</ContentPage.ToolbarItems>
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||
<ToolbarItem Icon="more_vert.png" Clicked="More_Clicked" Order="Primary"
|
||||
x:Name="_moreItem" x:Key="moreItem"
|
||||
AutomationProperties.IsInAccessibleTree="True"
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace Bit.App.Pages
|
||||
private readonly LoginPageViewModel _vm;
|
||||
private readonly AppOptions _appOptions;
|
||||
|
||||
private bool _appeared;
|
||||
private bool _inputFocused;
|
||||
|
||||
public LoginPage(string email = null, AppOptions appOptions = null)
|
||||
@@ -47,6 +46,11 @@ namespace Bit.App.Pages
|
||||
{
|
||||
ToolbarItems.Add(_getPasswordHint);
|
||||
}
|
||||
|
||||
if (!_appOptions?.IosExtension ?? false)
|
||||
{
|
||||
ToolbarItems.Remove(_closeItem);
|
||||
}
|
||||
}
|
||||
|
||||
public Entry MasterPasswordEntry { get; set; }
|
||||
@@ -54,24 +58,21 @@ namespace Bit.App.Pages
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
_mainContent.Content = _mainLayout;
|
||||
if (await HasMultipleAccountsAsync())
|
||||
{
|
||||
_vm.AvatarImageSource = await GetAvatarImageSourceAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToolbarItems.Remove(_accountAvatar);
|
||||
}
|
||||
await _vm.InitAsync();
|
||||
if (!_inputFocused)
|
||||
{
|
||||
RequestFocus(string.IsNullOrWhiteSpace(_vm.Email) ? _email : _masterPassword);
|
||||
_inputFocused = true;
|
||||
}
|
||||
if (_appeared)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_appeared = true;
|
||||
_mainContent.Content = _mainLayout;
|
||||
if (await HasMultipleAccountsAsync())
|
||||
{
|
||||
ToolbarItems.Add(_accountAvatar);
|
||||
ToolbarItems.Remove(_closeItem);
|
||||
_vm.AvatarImageSource = await GetAvatarImageSourceAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async void LogIn_Clicked(object sender, EventArgs e)
|
||||
|
||||
@@ -123,6 +123,7 @@ namespace Bit.Core.Services
|
||||
{
|
||||
await ScaffoldNewAccountAsync(account);
|
||||
await SetActiveUserAsync(account.Profile.UserId);
|
||||
await RefreshAccountViews();
|
||||
}
|
||||
|
||||
public async Task ClearAsync(string userId)
|
||||
|
||||
Reference in New Issue
Block a user