1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-26 12:16:07 +01:00

PM-3349 PM-3350 Migrated IconLabelButton Frames to Borders to fix issue with TapGestureRecognizer in Android

Also fixed some minor "styles" for normal Button and IconLabelButton (both Android and iOS)
This commit is contained in:
Dinis Vieira 2023-11-04 17:48:59 +00:00
parent 946c465f0c
commit c6309173ba
No known key found for this signature in database
GPG Key ID: 9389160FF6C295F3
4 changed files with 47 additions and 49 deletions

View File

@ -1,42 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Frame xmlns="http://schemas.microsoft.com/dotnet/2021/maui" <ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Bit.App.Controls.IconLabelButton" x:Class="Bit.App.Controls.IconLabelButton"
xmlns:controls="clr-namespace:Bit.App.Controls" xmlns:controls="clr-namespace:Bit.App.Controls"
x:Name="_iconLabelButton" x:Name="_iconLabelButton"
HeightRequest="45" HeightRequest="45"
Padding="1" StyleClass="btn-icon-secondary">
StyleClass="btn-icon-secondary" <Border StrokeThickness="2" BackgroundColor="{Binding IconLabelBackgroundColor, Source={x:Reference _iconLabelButton}}" Stroke="{Binding IconLabelBorderColor, Source={x:Reference _iconLabelButton}}">
BackgroundColor="{Binding IconLabelBorderColor, Source={x:Reference _iconLabelButton}}" <Border.StrokeShape>
BorderColor="Transparent" <RoundRectangle CornerRadius="{Binding CornerRadius, Source={x:Reference _iconLabelButton}}" />
HasShadow="False"> </Border.StrokeShape>
<Frame.GestureRecognizers> <Grid>
<TapGestureRecognizer Command="{Binding ButtonCommand, Source={x:Reference _iconLabelButton}}" /> <StackLayout
</Frame.GestureRecognizers> Spacing="6"
<Frame Orientation="Horizontal"
Margin="0" HorizontalOptions="Center">
Padding="0" <StackLayout.GestureRecognizers>
CornerRadius="{Binding CornerRadius, Source={x:Reference _iconLabelButton}}" <TapGestureRecognizer Command="{Binding ButtonCommand, Source={x:Reference _iconLabelButton}}" />
BackgroundColor="{Binding IconLabelBackgroundColor, Source={x:Reference _iconLabelButton}}" </StackLayout.GestureRecognizers>
BorderColor="Transparent" <controls:IconLabel
IsClippedToBounds="True" VerticalOptions="Center"
HasShadow="False"> HorizontalTextAlignment="Center"
<StackLayout FontSize="Large"
Orientation="Horizontal" TextColor="{Binding IconLabelColor, Source={x:Reference _iconLabelButton}}"
HorizontalOptions="Center"> Text="{Binding Icon, Source={x:Reference _iconLabelButton}}">
<controls:IconLabel </controls:IconLabel>
VerticalOptions="Center" <Label
HorizontalTextAlignment="Center" VerticalOptions="Center"
FontSize="Large" HorizontalTextAlignment="Center"
TextColor="{Binding IconLabelColor, Source={x:Reference _iconLabelButton}}" TextColor="{Binding IconLabelColor, Source={x:Reference _iconLabelButton}}"
Text="{Binding Icon, Source={x:Reference _iconLabelButton}}"> FontSize="Medium"
</controls:IconLabel> Text="{Binding Label, Source={x:Reference _iconLabelButton}}" />
<Label </StackLayout>
VerticalOptions="Center" </Grid>
HorizontalTextAlignment="Center" </Border>
TextColor="{Binding IconLabelColor, Source={x:Reference _iconLabelButton}}" </ContentView>
FontSize="Medium"
Text="{Binding Label, Source={x:Reference _iconLabelButton}}"/>
</StackLayout>
</Frame>
</Frame>

View File

@ -1,18 +1,8 @@
using System; using System.Windows.Input;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Bit.Core.Models.Domain;
using Microsoft.Maui.Controls.Xaml;
using Microsoft.Maui.Graphics;
using Microsoft.Maui.Controls;
using Microsoft.Maui;
namespace Bit.App.Controls namespace Bit.App.Controls
{ {
public partial class IconLabelButton : Frame public partial class IconLabelButton : ContentView
{ {
public static readonly BindableProperty IconProperty = BindableProperty.Create( public static readonly BindableProperty IconProperty = BindableProperty.Create(
nameof(Icon), typeof(string), typeof(IconLabelButton)); nameof(Icon), typeof(string), typeof(IconLabelButton));
@ -32,6 +22,9 @@ namespace Bit.App.Controls
public static readonly BindableProperty IconLabelBorderColorProperty = BindableProperty.Create( public static readonly BindableProperty IconLabelBorderColorProperty = BindableProperty.Create(
nameof(IconLabelBorderColor), typeof(Color), typeof(IconLabelButton), Colors.White); nameof(IconLabelBorderColor), typeof(Color), typeof(IconLabelButton), Colors.White);
public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(
nameof(CornerRadius), typeof(CornerRadius), typeof(IconLabelButton));
public IconLabelButton() public IconLabelButton()
{ {
InitializeComponent(); InitializeComponent();
@ -72,6 +65,12 @@ namespace Bit.App.Controls
get { return (Color)GetValue(IconLabelBorderColorProperty); } get { return (Color)GetValue(IconLabelBorderColorProperty); }
set { SetValue(IconLabelBorderColorProperty, value); } set { SetValue(IconLabelBorderColorProperty, value); }
} }
public CornerRadius CornerRadius
{
get { return (CornerRadius)GetValue(CornerRadiusProperty); }
set { SetValue(CornerRadiusProperty, value); }
}
} }
} }

View File

@ -107,7 +107,7 @@
</Label> </Label>
</Grid> </Grid>
</StackLayout> </StackLayout>
<StackLayout Padding="10, 10"> <StackLayout Padding="10, 10" Spacing="6">
<Button x:Name="_loginWithMasterPassword" <Button x:Name="_loginWithMasterPassword"
Text="{u:I18n LogInWithMasterPassword}" Text="{u:I18n LogInWithMasterPassword}"
StyleClass="btn-primary" StyleClass="btn-primary"

View File

@ -175,6 +175,10 @@
Value="Bold" /> Value="Bold" />
<Setter Property="Margin" <Setter Property="Margin"
Value="0, 5, 0, 0" /> Value="0, 5, 0, 0" />
<Setter Property="CornerRadius"
Value="5" />
<Setter Property="MinimumHeightRequest"
Value="45" />
<Setter Property="VisualStateManager.VisualStateGroups"> <Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList> <VisualStateGroupList>
<VisualStateGroup x:Name="CommonStates"> <VisualStateGroup x:Name="CommonStates">