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