1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-17 15:27:43 +01:00

view page card and identity info

This commit is contained in:
Kyle Spearrin 2019-04-29 10:20:29 -04:00
parent b7d87486a8
commit 134a4ec5d2
5 changed files with 282 additions and 19 deletions

View File

@ -19,10 +19,11 @@
<ToolbarItem Icon="cogs.png" <ToolbarItem Icon="cogs.png"
Text="{u:I18n Edit}" /> Text="{u:I18n Edit}" />
</ContentPage.ToolbarItems> </ContentPage.ToolbarItems>
<ContentPage.Resources> <ContentPage.Resources>
<ResourceDictionary> <ResourceDictionary>
<u:InverseBoolConverter x:Key="inverseBool" /> <u:InverseBoolConverter x:Key="inverseBool" />
<u:StringHasValueConverter x:Key="stringHasValue" />
</ResourceDictionary> </ResourceDictionary>
</ContentPage.Resources> </ContentPage.Resources>
@ -42,10 +43,9 @@
StyleClass="box-value" /> StyleClass="box-value" />
</StackLayout> </StackLayout>
<BoxView StyleClass="box-row-separator" /> <BoxView StyleClass="box-row-separator" />
<StackLayout IsVisible="{Binding IsLogin}" <StackLayout IsVisible="{Binding IsLogin}" Spacing="0" Padding="0">
Spacing="0" <Grid StyleClass="box-row"
Padding="0"> IsVisible="{Binding Cipher.Login.Username, Converter={StaticResource stringHasValue}}">
<Grid StyleClass="box-row" IsVisible="{Binding ShowUsername}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -73,8 +73,10 @@
Grid.Column="1" Grid.Column="1"
Grid.RowSpan="2" /> Grid.RowSpan="2" />
</Grid> </Grid>
<BoxView StyleClass="box-row-separator" /> <BoxView StyleClass="box-row-separator"
<Grid StyleClass="box-row" IsVisible="{Binding ShowPasswordBox}"> IsVisible="{Binding Cipher.Login.Username, Converter={StaticResource stringHasValue}}" />
<Grid StyleClass="box-row"
IsVisible="{Binding Cipher.Login.Password, Converter={StaticResource stringHasValue}}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="*" /> <RowDefinition Height="*" />
@ -125,7 +127,8 @@
Grid.Column="3" Grid.Column="3"
Grid.RowSpan="2" /> Grid.RowSpan="2" />
</Grid> </Grid>
<BoxView StyleClass="box-row-separator" /> <BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Login.Password, Converter={StaticResource stringHasValue}}" />
<Grid StyleClass="box-row" IsVisible="{Binding ShowTotp}"> <Grid StyleClass="box-row" IsVisible="{Binding ShowTotp}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -167,11 +170,233 @@
</Grid> </Grid>
<BoxView StyleClass="box-row-separator" IsVisible="{Binding ShowTotp}" /> <BoxView StyleClass="box-row-separator" IsVisible="{Binding ShowTotp}" />
</StackLayout> </StackLayout>
<StackLayout IsVisible="{Binding IsCard}"> <StackLayout IsVisible="{Binding IsCard}" Spacing="0" Padding="0">
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Card.CardholderName, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n CardholderName}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Card.CardholderName, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Card.CardholderName, Converter={StaticResource stringHasValue}}"/>
<Grid StyleClass="box-row"
IsVisible="{Binding Cipher.Card.Number, Converter={StaticResource stringHasValue}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label
Text="{u:I18n Number}"
StyleClass="box-label"
Grid.Row="0"
Grid.Column="0" />
<Label
Text="{Binding Cipher.Card.Number, Mode=OneWay}"
StyleClass="box-value"
Grid.Row="1"
Grid.Column="0" />
<controls:FaButton
StyleClass="box-row-button, box-row-button-platform"
Text="&#xf0ea;"
Command="{Binding CopyCommand}"
CommandParameter="CardNumber"
Grid.Row="0"
Grid.Column="1"
Grid.RowSpan="2" />
</Grid>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Card.Number, Converter={StaticResource stringHasValue}}" />
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Card.Brand, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n Brand}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Card.Brand, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Card.Brand, Converter={StaticResource stringHasValue}}" />
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Card.Expiration, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n Expiration}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Card.Expiration, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Card.Expiration, Converter={StaticResource stringHasValue}}" />
<Grid StyleClass="box-row"
IsVisible="{Binding Cipher.Card.Code, Converter={StaticResource stringHasValue}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label
Text="{u:I18n SecurityCode}"
StyleClass="box-label"
Grid.Row="0"
Grid.Column="0" />
<controls:MonoLabel
Text="{Binding Cipher.Card.MaskedCode, Mode=OneWay}"
StyleClass="box-value"
Grid.Row="1"
Grid.Column="0"
IsVisible="{Binding ShowCardCode, Converter={StaticResource inverseBool}}" />
<controls:MonoLabel
Text="{Binding Cipher.Card.Code, Mode=OneWay}"
StyleClass="box-value"
Grid.Row="1"
Grid.Column="0"
IsVisible="{Binding ShowCardCode}" />
<controls:FaButton
StyleClass="box-row-button, box-row-button-platform"
Text="{Binding ShowCardCodeIcon}"
Command="{Binding ToggleCardCodeCommand}"
Grid.Row="0"
Grid.Column="1"
Grid.RowSpan="2" />
<controls:FaButton
StyleClass="box-row-button, box-row-button-platform"
Text="&#xf0ea;"
Command="{Binding CopyCommand}"
CommandParameter="CardCode"
Grid.Row="0"
Grid.Column="2"
Grid.RowSpan="2" />
</Grid>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Card.Code, Converter={StaticResource stringHasValue}}" />
</StackLayout> </StackLayout>
<StackLayout IsVisible="{Binding IsIdentity}"> <StackLayout IsVisible="{Binding IsIdentity}" Spacing="0" Padding="0">
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Identity.FullName, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n IdentityName}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Identity.FullName, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Identity.FullName, Converter={StaticResource stringHasValue}}" />
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Identity.Username, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n Username}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Identity.Username, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Identity.Username, Converter={StaticResource stringHasValue}}" />
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Identity.Company, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n Company}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Identity.Company, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Identity.Company, Converter={StaticResource stringHasValue}}" />
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Identity.SSN, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n SSN}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Identity.SSN, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Identity.SSN, Converter={StaticResource stringHasValue}}"/>
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Identity.PassportNumber, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n PassportNumber}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Identity.PassportNumber, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Identity.PassportNumber, Converter={StaticResource stringHasValue}}" />
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Identity.LicenseNumber, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n LicenseNumber}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Identity.LicenseNumber, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Identity.LicenseNumber, Converter={StaticResource stringHasValue}}" />
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Identity.Email, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n Email}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Identity.Email, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Identity.Email, Converter={StaticResource stringHasValue}}" />
<StackLayout StyleClass="box-row"
IsVisible="{Binding Cipher.Identity.Phone, Converter={StaticResource stringHasValue}}">
<Label
Text="{u:I18n Phone}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Identity.Phone, Mode=OneWay}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding Cipher.Identity.Phone, Converter={StaticResource stringHasValue}}" />
<StackLayout StyleClass="box-row" IsVisible="{Binding ShowIdentityAddress}">
<Label
Text="{u:I18n Address}"
StyleClass="box-label" />
<Label
Text="{Binding Cipher.Identity.Address1, Mode=OneWay}"
IsVisible="{Binding Cipher.Identity.Address1, Converter={StaticResource stringHasValue}}"
StyleClass="box-value" />
<Label
Text="{Binding Cipher.Identity.Address2, Mode=OneWay}"
IsVisible="{Binding Cipher.Identity.Address2, Converter={StaticResource stringHasValue}}"
StyleClass="box-value" />
<Label
Text="{Binding Cipher.Identity.Address3, Mode=OneWay}"
IsVisible="{Binding Cipher.Identity.Address3, Converter={StaticResource stringHasValue}}"
StyleClass="box-value" />
<Label
Text="{Binding Cipher.Identity.FullAddressPart2, Mode=OneWay}"
IsVisible="{Binding Cipher.Identity.FullAddressPart2, Converter={StaticResource stringHasValue}}"
StyleClass="box-value" />
<Label
Text="{Binding Cipher.Identity.Country, Mode=OneWay}"
IsVisible="{Binding Cipher.Identity.Country, Converter={StaticResource stringHasValue}}"
StyleClass="box-value" />
</StackLayout>
<BoxView StyleClass="box-row-separator" IsVisible="{Binding ShowIdentityAddress}" />
</StackLayout> </StackLayout>
</StackLayout> </StackLayout>
<StackLayout StyleClass="box" IsVisible="{Binding ShowUris}"> <StackLayout StyleClass="box" IsVisible="{Binding ShowUris}">
@ -234,7 +459,8 @@
</controls:RepeaterView.ItemTemplate> </controls:RepeaterView.ItemTemplate>
</controls:RepeaterView> </controls:RepeaterView>
</StackLayout> </StackLayout>
<StackLayout StyleClass="box" IsVisible="{Binding ShowNotes}"> <StackLayout StyleClass="box"
IsVisible="{Binding Cipher.Notes, Converter={StaticResource stringHasValue}}">
<StackLayout StyleClass="box-row-header"> <StackLayout StyleClass="box-row-header">
<Label Text="{u:I18n Notes}" <Label Text="{u:I18n Notes}"
StyleClass="box-header, box-header-platform" /> StyleClass="box-header, box-header-platform" />

View File

@ -69,11 +69,9 @@ namespace Bit.App.Pages
nameof(IsSecureNote), nameof(IsSecureNote),
nameof(ShowUris), nameof(ShowUris),
nameof(ShowFields), nameof(ShowFields),
nameof(ShowNotes),
nameof(ShowTotp), nameof(ShowTotp),
nameof(ShowUsername),
nameof(ColoredPassword), nameof(ColoredPassword),
nameof(ShowPasswordBox) nameof(ShowIdentityAddress),
}); });
} }
public List<ViewFieldViewModel> Fields public List<ViewFieldViewModel> Fields
@ -108,11 +106,12 @@ namespace Bit.App.Pages
public bool IsIdentity => _cipher?.Type == Core.Enums.CipherType.Identity; public bool IsIdentity => _cipher?.Type == Core.Enums.CipherType.Identity;
public bool IsCard => _cipher?.Type == Core.Enums.CipherType.Card; public bool IsCard => _cipher?.Type == Core.Enums.CipherType.Card;
public bool IsSecureNote => _cipher?.Type == Core.Enums.CipherType.SecureNote; public bool IsSecureNote => _cipher?.Type == Core.Enums.CipherType.SecureNote;
public bool ShowUsername => IsLogin && !string.IsNullOrWhiteSpace(_cipher.Login.Username);
public FormattedString ColoredPassword => PasswordFormatter.FormatPassword(_cipher.Login.Password); public FormattedString ColoredPassword => PasswordFormatter.FormatPassword(_cipher.Login.Password);
public bool ShowPasswordBox => IsLogin && !string.IsNullOrWhiteSpace(_cipher.Login.Password);
public bool ShowUris => IsLogin && _cipher.Login.HasUris; public bool ShowUris => IsLogin && _cipher.Login.HasUris;
public bool ShowNotes => !string.IsNullOrWhiteSpace(_cipher.Notes); public bool ShowIdentityAddress => IsIdentity && (
!string.IsNullOrWhiteSpace(_cipher.Identity.Address1) ||
!string.IsNullOrWhiteSpace(_cipher.Identity.City) ||
!string.IsNullOrWhiteSpace(_cipher.Identity.Country));
public bool ShowFields => _cipher.HasFields; public bool ShowFields => _cipher.HasFields;
public bool ShowTotp => IsLogin && !string.IsNullOrWhiteSpace(_cipher.Login.Totp) && public bool ShowTotp => IsLogin && !string.IsNullOrWhiteSpace(_cipher.Login.Totp) &&
!string.IsNullOrWhiteSpace(TotpCodeFormatted); !string.IsNullOrWhiteSpace(TotpCodeFormatted);
@ -266,6 +265,16 @@ namespace Bit.App.Pages
{ {
name = AppResources.URI; name = AppResources.URI;
} }
else if(id == "CardNumber")
{
text = Cipher.Card.Number;
name = AppResources.Number;
}
else if(id == "CardCode")
{
text = Cipher.Card.Code;
name = AppResources.SecurityCode;
}
if(text != null) if(text != null)
{ {

View File

@ -1779,6 +1779,15 @@ namespace Bit.App.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Identity Name.
/// </summary>
internal static string IdentityName {
get {
return ResourceManager.GetString("IdentityName", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Identity Server URL. /// Looks up a localized string similar to Identity Server URL.
/// </summary> /// </summary>

View File

@ -1381,4 +1381,7 @@
<data name="PasswordSafe" xml:space="preserve"> <data name="PasswordSafe" xml:space="preserve">
<value>This password was not found in any known data breaches. It should be safe to use.</value> <value>This password was not found in any known data breaches. It should be safe to use.</value>
</data> </data>
<data name="IdentityName" xml:space="preserve">
<value>Identity Name</value>
</data>
</root> </root>

View File

@ -125,5 +125,21 @@ namespace Bit.Core.Models.View
return address; return address;
} }
} }
public string FullAddressPart2
{
get
{
if(string.IsNullOrWhiteSpace(City) && string.IsNullOrWhiteSpace(State) &&
string.IsNullOrWhiteSpace(PostalCode))
{
return null;
}
var city = string.IsNullOrWhiteSpace(City) ? "-" : City;
var state = string.IsNullOrWhiteSpace(State) ? "-" : State;
var postalCode = string.IsNullOrWhiteSpace(PostalCode) ? "-" : PostalCode;
return string.Format("{0}, {1}, {2}", city, state, postalCode);
}
}
} }
} }