mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
view page updates
This commit is contained in:
parent
d7312e2977
commit
9b2ce98b46
4 changed files with 85 additions and 7 deletions
25
src/App/Models/ViewFieldViewModel.cs
Normal file
25
src/App/Models/ViewFieldViewModel.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
using Bit.App.Pages;
|
||||||
|
using Bit.Core.Models.View;
|
||||||
|
|
||||||
|
namespace Bit.App.Models
|
||||||
|
{
|
||||||
|
public class ViewFieldViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
private FieldView _field;
|
||||||
|
|
||||||
|
public ViewFieldViewModel(FieldView field)
|
||||||
|
{
|
||||||
|
Field = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FieldView Field
|
||||||
|
{
|
||||||
|
get => _field;
|
||||||
|
set => SetProperty(ref _field, value,
|
||||||
|
additionalPropertyNames: new string[]
|
||||||
|
{
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
xmlns:u="clr-namespace:Bit.App.Utilities"
|
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||||
xmlns:controls="clr-namespace:Bit.App.Controls"
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore"
|
xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore"
|
||||||
|
xmlns:models="clr-namespace:Bit.App.Models"
|
||||||
x:DataType="pages:ViewPageViewModel"
|
x:DataType="pages:ViewPageViewModel"
|
||||||
x:Name="_page"
|
x:Name="_page"
|
||||||
Title="{Binding PageTitle}">
|
Title="{Binding PageTitle}">
|
||||||
|
@ -18,6 +19,12 @@
|
||||||
<ToolbarItem Icon="cogs.png"
|
<ToolbarItem Icon="cogs.png"
|
||||||
Text="{u:I18n Edit}" />
|
Text="{u:I18n Edit}" />
|
||||||
</ContentPage.ToolbarItems>
|
</ContentPage.ToolbarItems>
|
||||||
|
|
||||||
|
<ContentPage.Resources>
|
||||||
|
<ResourceDictionary>
|
||||||
|
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||||
|
</ResourceDictionary>
|
||||||
|
</ContentPage.Resources>
|
||||||
|
|
||||||
<ScrollView>
|
<ScrollView>
|
||||||
<StackLayout Spacing="20">
|
<StackLayout Spacing="20">
|
||||||
|
@ -167,7 +174,14 @@
|
||||||
Text="{u:I18n URI}"
|
Text="{u:I18n URI}"
|
||||||
StyleClass="box-label"
|
StyleClass="box-label"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="0" />
|
Grid.Column="0"
|
||||||
|
IsVisible="{Binding IsWebsite, Mode=OneWay, Converter={StaticResource inverseBool}}" />
|
||||||
|
<Label
|
||||||
|
Text="{u:I18n Website}"
|
||||||
|
StyleClass="box-label"
|
||||||
|
Grid.Row="0"
|
||||||
|
Grid.Column="0"
|
||||||
|
IsVisible="{Binding IsWebsite, Mode=OneWay}" />
|
||||||
<Label
|
<Label
|
||||||
Text="{Binding HostnameOrUri, Mode=OneWay}"
|
Text="{Binding HostnameOrUri, Mode=OneWay}"
|
||||||
StyleClass="box-value"
|
StyleClass="box-value"
|
||||||
|
@ -181,7 +195,8 @@
|
||||||
CommandParameter="{Binding .}"
|
CommandParameter="{Binding .}"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Grid.RowSpan="2" />
|
Grid.RowSpan="2"
|
||||||
|
IsVisible="{Binding CanLaunch, Mode=OneWay}" />
|
||||||
<controls:FaButton
|
<controls:FaButton
|
||||||
StyleClass="box-row-button, box-row-button-platform"
|
StyleClass="box-row-button, box-row-button-platform"
|
||||||
Text=""
|
Text=""
|
||||||
|
@ -215,9 +230,9 @@
|
||||||
<Label Text="{u:I18n CustomFields}"
|
<Label Text="{u:I18n CustomFields}"
|
||||||
StyleClass="box-header, box-header-platform" />
|
StyleClass="box-header, box-header-platform" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
<controls:RepeaterView ItemsSource="{Binding Cipher.Fields}">
|
<controls:RepeaterView ItemsSource="{Binding Fields}">
|
||||||
<controls:RepeaterView.ItemTemplate>
|
<controls:RepeaterView.ItemTemplate>
|
||||||
<DataTemplate x:DataType="views:FieldView">
|
<DataTemplate x:DataType="models:ViewFieldViewModel">
|
||||||
<StackLayout Spacing="0" Padding="0">
|
<StackLayout Spacing="0" Padding="0">
|
||||||
<Grid StyleClass="box-row">
|
<Grid StyleClass="box-row">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
@ -229,12 +244,12 @@
|
||||||
<ColumnDefinition Width="Auto" />
|
<ColumnDefinition Width="Auto" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Label
|
<Label
|
||||||
Text="{Binding Name, Mode=OneWay}"
|
Text="{Binding Field.Name, Mode=OneWay}"
|
||||||
StyleClass="box-label"
|
StyleClass="box-label"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="0" />
|
Grid.Column="0" />
|
||||||
<Label
|
<Label
|
||||||
Text="{Binding Value, Mode=OneWay}"
|
Text="{Binding Field.Value, Mode=OneWay}"
|
||||||
StyleClass="box-value"
|
StyleClass="box-value"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="0" />
|
Grid.Column="0" />
|
||||||
|
@ -242,7 +257,7 @@
|
||||||
StyleClass="box-row-button, box-row-button-platform"
|
StyleClass="box-row-button, box-row-button-platform"
|
||||||
Text=""
|
Text=""
|
||||||
Command="{Binding BindingContext.CopyFieldCommand, Source={x:Reference _page}}"
|
Command="{Binding BindingContext.CopyFieldCommand, Source={x:Reference _page}}"
|
||||||
CommandParameter="{Binding .}"
|
CommandParameter="{Binding Field}"
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Grid.RowSpan="2" />
|
Grid.RowSpan="2" />
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
using Bit.App.Abstractions;
|
using Bit.App.Abstractions;
|
||||||
|
using Bit.App.Models;
|
||||||
using Bit.App.Resources;
|
using Bit.App.Resources;
|
||||||
using Bit.Core.Abstractions;
|
using Bit.Core.Abstractions;
|
||||||
using Bit.Core.Models.View;
|
using Bit.Core.Models.View;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
@ -17,6 +20,7 @@ namespace Bit.App.Pages
|
||||||
private readonly ITotpService _totpService;
|
private readonly ITotpService _totpService;
|
||||||
private readonly IPlatformUtilsService _platformUtilsService;
|
private readonly IPlatformUtilsService _platformUtilsService;
|
||||||
private CipherView _cipher;
|
private CipherView _cipher;
|
||||||
|
private List<ViewFieldViewModel> _fields;
|
||||||
private bool _canAccessPremium;
|
private bool _canAccessPremium;
|
||||||
private string _totpCode;
|
private string _totpCode;
|
||||||
private string _totpCodeFormatted;
|
private string _totpCodeFormatted;
|
||||||
|
@ -58,6 +62,11 @@ namespace Bit.App.Pages
|
||||||
nameof(ShowTotp)
|
nameof(ShowTotp)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public List<ViewFieldViewModel> Fields
|
||||||
|
{
|
||||||
|
get => _fields;
|
||||||
|
set => SetProperty(ref _fields, value);
|
||||||
|
}
|
||||||
public bool CanAccessPremium
|
public bool CanAccessPremium
|
||||||
{
|
{
|
||||||
get => _canAccessPremium;
|
get => _canAccessPremium;
|
||||||
|
@ -102,6 +111,7 @@ namespace Bit.App.Pages
|
||||||
var cipher = await _cipherService.GetAsync(CipherId);
|
var cipher = await _cipherService.GetAsync(CipherId);
|
||||||
Cipher = await cipher.DecryptAsync();
|
Cipher = await cipher.DecryptAsync();
|
||||||
CanAccessPremium = await _userService.CanAccessPremiumAsync();
|
CanAccessPremium = await _userService.CanAccessPremiumAsync();
|
||||||
|
Fields = Cipher.Fields?.Select(f => new ViewFieldViewModel(f)).ToList();
|
||||||
|
|
||||||
if(Cipher.Type == Core.Enums.CipherType.Login && !string.IsNullOrWhiteSpace(Cipher.Login.Totp) &&
|
if(Cipher.Type == Core.Enums.CipherType.Login && !string.IsNullOrWhiteSpace(Cipher.Login.Totp) &&
|
||||||
(Cipher.OrganizationUseTotp || CanAccessPremium))
|
(Cipher.OrganizationUseTotp || CanAccessPremium))
|
||||||
|
|
28
src/App/Utilities/InverseBoolConverter.cs
Normal file
28
src/App/Utilities/InverseBoolConverter.cs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
using System;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.App.Utilities
|
||||||
|
{
|
||||||
|
public class InverseBoolConverter : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter,
|
||||||
|
System.Globalization.CultureInfo culture)
|
||||||
|
{
|
||||||
|
if(targetType == typeof(bool))
|
||||||
|
{
|
||||||
|
return !(bool)value;
|
||||||
|
}
|
||||||
|
if(targetType == typeof(bool?))
|
||||||
|
{
|
||||||
|
return !((bool?)value).GetValueOrDefault();
|
||||||
|
}
|
||||||
|
throw new InvalidOperationException("The target must be a boolean.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter,
|
||||||
|
System.Globalization.CultureInfo culture)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue