1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-30 04:17:55 +02:00

PM-3350 Fixed account toolbar item and TitleView on SendAddOnlyPage, also removed comments on AvatarImageSource given the workaround is not needed anymore to draw the image successfully.

This commit is contained in:
Federico Maccaroni 2023-11-20 16:09:23 -03:00
parent 1a0b52d644
commit ce41eb0578
No known key found for this signature in database
GPG Key ID: 5D233F8F2B034536
4 changed files with 65 additions and 36 deletions

View File

@ -1,12 +1,5 @@
using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Bit.Core.Utilities;
using Bit.Core.Utilities;
using SkiaSharp;
using Microsoft.Maui.Controls;
using Microsoft.Maui;
namespace Bit.App.Controls
{
@ -48,11 +41,7 @@ namespace Bit.App.Controls
private Task<Stream> GetStreamAsync(CancellationToken userToken = new CancellationToken())
{
// TODO: [MAUI-Avatar] now methods are private protected so cannot be used here, figure out workaround
//OnLoadingStarted();
//userToken.Register(CancellationTokenSource.Cancel);
var result = Draw();
//OnLoadingCompleted(CancellationTokenSource.IsCancellationRequested);
return Task.FromResult(result);
}

View File

@ -10,26 +10,44 @@
xmlns:effects="clr-namespace:Bit.App.Effects"
x:DataType="pages:SendAddEditPageViewModel"
HideSoftInputOnTapped="True"
x:Name="_page"
Title="{Binding PageTitle}">
x:Name="_page">
<ContentPage.BindingContext>
<pages:SendAddEditPageViewModel />
</ContentPage.BindingContext>
<ContentPage.ToolbarItems>
<!--Order matters here or the avatar's image won't be updated correctly, check iOS CustomNavigationRenderer for more info-->
<controls:ExtendedToolbarItem
x:Name="_accountAvatar"
IconImageSource="{Binding AvatarImageSource}"
Command="{Binding Source={x:Reference _accountListOverlay}, Path=ToggleVisibililtyCommand}"
Order="Primary"
Priority="-2"
UseOriginalImage="True"
SemanticProperties.Description="{u:I18n Account}"
AutomationId="AccountIconButton" />
<ToolbarItem Text="{u:I18n Cancel}" Clicked="Close_Clicked" Order="Primary" Priority="-1" x:Name="_closeItem" />
<ToolbarItem Text="{u:I18n Save}" Clicked="Save_Clicked" Order="Primary" x:Name="_saveItem"/>
</ContentPage.ToolbarItems>
<!--Using a TitleView because ToolbarItem doesn't support adding the item to the left of the title-->
<NavigationPage.TitleView>
<Grid
ColumnDefinitions="Auto,*,Auto,Auto">
<ImageButton
Source="{Binding AvatarImageSource}"
Command="{Binding Source={x:Reference _accountListOverlay}, Path=ToggleVisibililtyCommand}"
SemanticProperties.Description="{u:I18n Account}"
AutomationId="AccountIconButton"/>
<Label
Grid.Column="1"
Text="{Binding PageTitle}"
StyleClass="toolbar-title"
HorizontalOptions="Center"
VerticalOptions="Center"
AutomationId="ViewTitleLabel"/>
<Button
Grid.Column="2"
Text="{u:I18n Cancel}"
StyleClass="toolbar-borderless-button"
Clicked="Close_Clicked"
SemanticProperties.Description="{u:I18n Cancel}"
AutomationId="CloseButton"/>
<Button
Grid.Column="3"
x:Name="_saveItem"
Text="{u:I18n Save}"
StyleClass="toolbar-borderless-button"
Clicked="Save_Clicked"
SemanticProperties.Description="{u:I18n Save}"
AutomationId="SaveButton"/>
</Grid>
</NavigationPage.TitleView>
<ContentPage.Resources>
<ResourceDictionary>

View File

@ -70,7 +70,6 @@ namespace Bit.App.Pages
return;
}
_accountAvatar?.OnAppearing();
await MainThread.InvokeOnMainThreadAsync(async () => _vm.AvatarImageSource = await GetAvatarImageSourceAsync());
await HandleCreateRequest();
@ -87,13 +86,6 @@ namespace Bit.App.Pages
}
}
protected override void OnNavigatingFrom(NavigatingFromEventArgs args)
{
base.OnNavigatingFrom(args);
_accountAvatar?.OnDisappearing();
}
private async Task CloseAsync()
{
if (OnClose is null)

View File

@ -625,5 +625,35 @@
<Setter Property="IsVisible"
Value="{OnPlatform Android=True, iOS=False}" />
</Style>
<Style TargetType="Label"
ApplyToDerivedTypes="True"
Class="toolbar-title">
<Setter Property="TextColor"
Value="{DynamicResource TitleTextColor}" />
<Setter Property="FontSize"
Value="Header" />
<Setter Property="FontAttributes"
Value="Bold" />
<Setter Property="MaxLines"
Value="1" />
<Setter Property="LineBreakMode"
Value="TailTruncation" />
</Style>
<Style TargetType="Button"
ApplyToDerivedTypes="True"
Class="toolbar-borderless-button">
<Setter Property="TextColor"
Value="{DynamicResource TitleTextColor}" />
<Setter Property="Background"
Value="Transparent" />
<Setter Property="BackgroundColor"
Value="Transparent" />
<Setter Property="BorderWidth"
Value="0" />
<Setter Property="FontSize"
Value="Header" />
</Style>
</ResourceDictionary>