mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-17 15:27:43 +01:00
cipher password history page
This commit is contained in:
parent
9195bdcf95
commit
59e412ea09
@ -37,6 +37,9 @@
|
||||
<Compile Update="Pages\Generator\GeneratorPage.xaml.cs">
|
||||
<DependentUpon>GeneratorPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Pages\Vault\PasswordHistoryPage.xaml.cs">
|
||||
<DependentUpon>PasswordHistoryPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Pages\Vault\ViewPage.xaml.cs">
|
||||
<DependentUpon>ViewPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
82
src/App/Pages/Vault/PasswordHistoryPage.xaml
Normal file
82
src/App/Pages/Vault/PasswordHistoryPage.xaml
Normal file
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<pages:BaseContentPage
|
||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||
x:Class="Bit.App.Pages.PasswordHistoryPage"
|
||||
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||
xmlns:u="clr-namespace:Bit.App.Utilities"
|
||||
xmlns:views="clr-namespace:Bit.Core.Models.View;assembly=BitwardenCore"
|
||||
x:DataType="pages:PasswordHistoryPageViewModel"
|
||||
x:Name="_page"
|
||||
Title="{Binding PageTitle}">
|
||||
|
||||
<ContentPage.BindingContext>
|
||||
<pages:PasswordHistoryPageViewModel />
|
||||
</ContentPage.BindingContext>
|
||||
|
||||
<ContentPage.Resources>
|
||||
<ResourceDictionary>
|
||||
<u:InverseBoolConverter x:Key="inverseBool" />
|
||||
<u:DateTimeConverter x:Key="dateTime" />
|
||||
</ResourceDictionary>
|
||||
</ContentPage.Resources>
|
||||
|
||||
<StackLayout x:Name="_mainLayout">
|
||||
<Label IsVisible="{Binding ShowNoData}"
|
||||
Text="{u:I18n NoPasswordsToList}"
|
||||
Margin="20, 0"
|
||||
VerticalOptions="CenterAndExpand"
|
||||
HorizontalOptions="CenterAndExpand"
|
||||
HorizontalTextAlignment="Center"></Label>
|
||||
<ListView x:Name="_listView"
|
||||
IsVisible="{Binding ShowNoData, Converter={StaticResource inverseBool}}"
|
||||
ItemsSource="{Binding History}"
|
||||
VerticalOptions="FillAndExpand"
|
||||
HasUnevenRows="true"
|
||||
CachingStrategy="RecycleElement"
|
||||
StyleClass="list, list-platform">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="views:PasswordHistoryView">
|
||||
<ViewCell>
|
||||
<Grid
|
||||
StyleClass="list-row, list-row-platform"
|
||||
Padding="10"
|
||||
RowSpacing="0"
|
||||
ColumnSpacing="10">
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:MonoLabel LineBreakMode="CharacterWrap"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
StyleClass="list-title, list-title-platform"
|
||||
Text="{Binding Password, Mode=OneWay}" />
|
||||
<Label LineBreakMode="TailTruncation"
|
||||
Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
StyleClass="list-subtitle, list-subtitle-platform"
|
||||
Text="{Binding LastUsedDate, Mode=OneWay, Converter={StaticResource dateTime}}" />
|
||||
<controls:FaButton
|
||||
StyleClass="list-row-button, list-row-button-platform"
|
||||
Text=""
|
||||
Command="{Binding BindingContext.CopyCommand, Source={x:Reference _page}}"
|
||||
CommandParameter="{Binding .}"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"
|
||||
Grid.RowSpan="2" />
|
||||
</Grid>
|
||||
</ViewCell>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</StackLayout>
|
||||
|
||||
</pages:BaseContentPage>
|
26
src/App/Pages/Vault/PasswordHistoryPage.xaml.cs
Normal file
26
src/App/Pages/Vault/PasswordHistoryPage.xaml.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public partial class PasswordHistoryPage : BaseContentPage
|
||||
{
|
||||
private PasswordHistoryPageViewModel _vm;
|
||||
|
||||
public PasswordHistoryPage(string cipherId)
|
||||
{
|
||||
InitializeComponent();
|
||||
SetActivityIndicator();
|
||||
_vm = BindingContext as PasswordHistoryPageViewModel;
|
||||
_vm.Page = this;
|
||||
_vm.CipherId = cipherId;
|
||||
}
|
||||
|
||||
protected override async void OnAppearing()
|
||||
{
|
||||
base.OnAppearing();
|
||||
await LoadOnAppearedAsync(_mainLayout, true, async () => {
|
||||
await _vm.InitAsync();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
53
src/App/Pages/Vault/PasswordHistoryPageViewModel.cs
Normal file
53
src/App/Pages/Vault/PasswordHistoryPageViewModel.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using Bit.App.Resources;
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
public class PasswordHistoryPageViewModel : BaseViewModel
|
||||
{
|
||||
private readonly IPlatformUtilsService _platformUtilsService;
|
||||
private readonly ICipherService _cipherService;
|
||||
|
||||
private bool _showNoData;
|
||||
|
||||
public PasswordHistoryPageViewModel()
|
||||
{
|
||||
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
|
||||
_cipherService = ServiceContainer.Resolve<ICipherService>("cipherService");
|
||||
|
||||
PageTitle = AppResources.PasswordHistory;
|
||||
History = new ExtendedObservableCollection<PasswordHistoryView>();
|
||||
CopyCommand = new Command<PasswordHistoryView>(CopyAsync);
|
||||
}
|
||||
|
||||
public Command CopyCommand { get; set; }
|
||||
public string CipherId { get; set; }
|
||||
public ExtendedObservableCollection<PasswordHistoryView> History { get; set; }
|
||||
|
||||
public bool ShowNoData
|
||||
{
|
||||
get => _showNoData;
|
||||
set => SetProperty(ref _showNoData, value);
|
||||
}
|
||||
|
||||
public async Task InitAsync()
|
||||
{
|
||||
var cipher = await _cipherService.GetAsync(CipherId);
|
||||
var decCipher = await cipher.DecryptAsync();
|
||||
History.ResetWithRange(decCipher.PasswordHistory ?? new List<PasswordHistoryView>());
|
||||
ShowNoData = History.Count == 0;
|
||||
}
|
||||
|
||||
private async void CopyAsync(PasswordHistoryView ph)
|
||||
{
|
||||
await _platformUtilsService.CopyToClipboardAsync(ph.Password);
|
||||
_platformUtilsService.ShowToast("info", null,
|
||||
string.Format(AppResources.ValueHasBeenCopied, AppResources.Password));
|
||||
}
|
||||
}
|
||||
}
|
@ -584,10 +584,18 @@
|
||||
StyleClass="box-footer-label" />
|
||||
<Label FormattedText="{Binding PasswordUpdatedText}"
|
||||
StyleClass="box-footer-label"
|
||||
IsVisible="{Binding Cipher.PasswordRevisionDisplayDate, Converter={StaticResource notNull}}" />
|
||||
IsVisible="{Binding Cipher.PasswordRevisionDisplayDate, Converter={StaticResource notNull}}">
|
||||
<Label.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="PasswordHistory_Tapped" />
|
||||
</Label.GestureRecognizers>
|
||||
</Label>
|
||||
<Label FormattedText="{Binding PasswordHistoryText}"
|
||||
StyleClass="box-footer-label"
|
||||
IsVisible="{Binding Cipher.HasPasswordHistory}" />
|
||||
IsVisible="{Binding Cipher.HasPasswordHistory}">
|
||||
<Label.GestureRecognizers>
|
||||
<TapGestureRecognizer Tapped="PasswordHistory_Tapped" />
|
||||
</Label.GestureRecognizers>
|
||||
</Label>
|
||||
</StackLayout>
|
||||
</StackLayout>
|
||||
</ScrollView>
|
||||
|
@ -1,6 +1,7 @@
|
||||
using Bit.Core.Abstractions;
|
||||
using Bit.Core.Utilities;
|
||||
using System.Collections.Generic;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
@ -46,5 +47,10 @@ namespace Bit.App.Pages
|
||||
_broadcasterService.Unsubscribe(nameof(ViewPage));
|
||||
_vm.CleanUp();
|
||||
}
|
||||
|
||||
private async void PasswordHistory_Tapped(object sender, System.EventArgs e)
|
||||
{
|
||||
await Navigation.PushModalAsync(new NavigationPage(new PasswordHistoryPage(_vm.CipherId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
src/App/Resources/AppResources.Designer.cs
generated
9
src/App/Resources/AppResources.Designer.cs
generated
@ -2472,6 +2472,15 @@ namespace Bit.App.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to No passwords to list..
|
||||
/// </summary>
|
||||
public static string NoPasswordsToList {
|
||||
get {
|
||||
return ResourceManager.GetString("NoPasswordsToList", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Notes.
|
||||
/// </summary>
|
||||
|
@ -1393,4 +1393,7 @@
|
||||
<data name="Types" xml:space="preserve">
|
||||
<value>Types</value>
|
||||
</data>
|
||||
<data name="NoPasswordsToList" xml:space="preserve">
|
||||
<value>No passwords to list.</value>
|
||||
</data>
|
||||
</root>
|
@ -44,6 +44,14 @@
|
||||
<Style TargetType="ImageButton"
|
||||
Class="list-button-platform">
|
||||
</Style>
|
||||
<Style TargetType="Button"
|
||||
ApplyToDerivedTypes="True"
|
||||
Class="list-row-button-platform">
|
||||
<Setter Property="WidthRequest"
|
||||
Value="37" />
|
||||
<Setter Property="FontSize"
|
||||
Value="25" />
|
||||
</Style>
|
||||
|
||||
<!-- Box -->
|
||||
|
||||
|
@ -162,6 +162,20 @@
|
||||
<Setter Property="VerticalOptions"
|
||||
Value="CenterAndExpand" />
|
||||
</Style>
|
||||
<Style TargetType="Button"
|
||||
ApplyToDerivedTypes="True"
|
||||
Class="list-row-button">
|
||||
<Setter Property="BackgroundColor"
|
||||
Value="Transparent" />
|
||||
<Setter Property="Padding"
|
||||
Value="0" />
|
||||
<Setter Property="TextColor"
|
||||
Value="{StaticResource PrimaryColor}" />
|
||||
<Setter Property="HorizontalOptions"
|
||||
Value="End" />
|
||||
<Setter Property="VerticalOptions"
|
||||
Value="CenterAndExpand" />
|
||||
</Style>
|
||||
|
||||
<!-- Box -->
|
||||
|
||||
|
29
src/App/Utilities/DateTimeConverter.cs
Normal file
29
src/App/Utilities/DateTimeConverter.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Utilities
|
||||
{
|
||||
public class DateTimeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter,
|
||||
System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if(targetType != typeof(string))
|
||||
{
|
||||
throw new InvalidOperationException("The target must be a string.");
|
||||
}
|
||||
if(value == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var d = (DateTime)value;
|
||||
return string.Format("{0} {1}", d.ToShortDateString(), d.ToShortTimeString());
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter,
|
||||
System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user