attachment listing

This commit is contained in:
Kyle Spearrin 2019-04-29 14:35:44 -04:00
parent 2a6fe3f351
commit a5bf16a415
5 changed files with 72 additions and 13 deletions

View file

@ -544,6 +544,42 @@
</controls:RepeaterView.ItemTemplate> </controls:RepeaterView.ItemTemplate>
</controls:RepeaterView> </controls:RepeaterView>
</StackLayout> </StackLayout>
<StackLayout StyleClass="box" IsVisible="{Binding ShowAttachments}">
<StackLayout StyleClass="box-row-header">
<Label Text="{u:I18n Attachments}"
StyleClass="box-header, box-header-platform" />
</StackLayout>
<controls:RepeaterView ItemsSource="{Binding Cipher.Attachments}">
<controls:RepeaterView.ItemTemplate>
<DataTemplate x:DataType="views:AttachmentView">
<StackLayout Spacing="0" Padding="0">
<StackLayout Orientation="Horizontal" StyleClass="box-row" Spacing="10">
<Label
Text="{Binding FileName, Mode=OneWay}"
StyleClass="box-value"
VerticalTextAlignment="Center"
HorizontalOptions="StartAndExpand" />
<Label
Text="{Binding SizeName, Mode=OneWay}"
StyleClass="box-sub-label"
HorizontalTextAlignment="End"
HorizontalOptions="End"
VerticalTextAlignment="Center"
VerticalOptions="CenterAndExpand" />
<controls:FaButton
StyleClass="box-row-button, box-row-button-platform"
Text="&#xf019;"
Command="{Binding BindingContext.DownloadAttachmentCommand, Source={x:Reference _page}}"
CommandParameter="{Binding .}"
HorizontalOptions="End"
VerticalOptions="CenterAndExpand" />
</StackLayout>
<BoxView StyleClass="box-row-separator" />
</StackLayout>
</DataTemplate>
</controls:RepeaterView.ItemTemplate>
</controls:RepeaterView>
</StackLayout>
</StackLayout> </StackLayout>
</ScrollView> </ScrollView>

View file

@ -47,6 +47,7 @@ namespace Bit.App.Pages
TogglePasswordCommand = new Command(TogglePassword); TogglePasswordCommand = new Command(TogglePassword);
ToggleCardCodeCommand = new Command(ToggleCardCode); ToggleCardCodeCommand = new Command(ToggleCardCode);
CheckPasswordCommand = new Command(CheckPasswordAsync); CheckPasswordCommand = new Command(CheckPasswordAsync);
DownloadAttachmentCommand = new Command<AttachmentView>(DownloadAttachmentAsync);
PageTitle = AppResources.ViewItem; PageTitle = AppResources.ViewItem;
} }
@ -58,6 +59,7 @@ namespace Bit.App.Pages
public Command TogglePasswordCommand { get; set; } public Command TogglePasswordCommand { get; set; }
public Command ToggleCardCodeCommand { get; set; } public Command ToggleCardCodeCommand { get; set; }
public Command CheckPasswordCommand { get; set; } public Command CheckPasswordCommand { get; set; }
public Command DownloadAttachmentCommand { get; set; }
public string CipherId { get; set; } public string CipherId { get; set; }
public CipherView Cipher public CipherView Cipher
{ {
@ -104,21 +106,22 @@ namespace Bit.App.Pages
nameof(ShowCardCodeIcon) nameof(ShowCardCodeIcon)
}); });
} }
public bool IsLogin => _cipher?.Type == Core.Enums.CipherType.Login; public bool IsLogin => Cipher?.Type == Core.Enums.CipherType.Login;
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 FormattedString ColoredPassword => PasswordFormatter.FormatPassword(_cipher.Login.Password); public FormattedString ColoredPassword => PasswordFormatter.FormatPassword(Cipher.Login.Password);
public bool ShowUris => IsLogin && _cipher.Login.HasUris; public bool ShowUris => IsLogin && Cipher.Login.HasUris;
public bool ShowIdentityAddress => IsIdentity && ( public bool ShowIdentityAddress => IsIdentity && (
!string.IsNullOrWhiteSpace(_cipher.Identity.Address1) || !string.IsNullOrWhiteSpace(Cipher.Identity.Address1) ||
!string.IsNullOrWhiteSpace(_cipher.Identity.City) || !string.IsNullOrWhiteSpace(Cipher.Identity.City) ||
!string.IsNullOrWhiteSpace(_cipher.Identity.Country)); !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 ShowAttachments => Cipher.HasAttachments && (CanAccessPremium || Cipher.OrganizationId != null);
public bool ShowTotp => IsLogin && !string.IsNullOrWhiteSpace(Cipher.Login.Totp) &&
!string.IsNullOrWhiteSpace(TotpCodeFormatted); !string.IsNullOrWhiteSpace(TotpCodeFormatted);
public string ShowPasswordIcon => _showPassword ? "" : ""; public string ShowPasswordIcon => ShowPassword ? "" : "";
public string ShowCardCodeIcon => _showCardCode ? "" : ""; public string ShowCardCodeIcon => ShowCardCode ? "" : "";
public string TotpCodeFormatted public string TotpCodeFormatted
{ {
get => _totpCodeFormatted; get => _totpCodeFormatted;
@ -245,6 +248,17 @@ namespace Bit.App.Pages
} }
} }
private async void DownloadAttachmentAsync(AttachmentView attachment)
{
if(Cipher.OrganizationId == null && !CanAccessPremium)
{
await _platformUtilsService.ShowDialogAsync(AppResources.PremiumRequired);
}
await _deviceActionService.ShowLoadingAsync(AppResources.Downloading);
await Task.Delay(2000); // TODO: download
await _deviceActionService.HideLoadingAsync();
}
private async void CopyAsync(string id, string text = null) private async void CopyAsync(string id, string text = null)
{ {
string name = null; string name = null;

View file

@ -145,4 +145,11 @@
<Setter Property="LineBreakMode" <Setter Property="LineBreakMode"
Value="CharacterWrap" /> Value="CharacterWrap" />
</Style> </Style>
<Style TargetType="Label"
Class="box-sub-label">
<Setter Property="FontSize"
Value="Small" />
<Setter Property="TextColor"
Value="{StaticResource MutedColor}" />
</Style>
</ResourceDictionary> </ResourceDictionary>

View file

@ -13,6 +13,7 @@
<Color x:Key="PasswordSpecialColor">#c40800</Color> <Color x:Key="PasswordSpecialColor">#c40800</Color>
<Color x:Key="BorderColor">#dddddd</Color> <Color x:Key="BorderColor">#dddddd</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</Color>
<Color x:Key="BoxBorderColor">#f0f0f0</Color> <Color x:Key="BoxBorderColor">#f0f0f0</Color>
<Color x:Key="BoxHeaderTextColor">#3c8dbc</Color> <Color x:Key="BoxHeaderTextColor">#3c8dbc</Color>

View file

@ -13,6 +13,7 @@
<Color x:Key="PasswordSpecialColor">#c40800</Color> <Color x:Key="PasswordSpecialColor">#c40800</Color>
<Color x:Key="BorderColor">#dddddd</Color> <Color x:Key="BorderColor">#dddddd</Color>
<Color x:Key="DisabledIconColor">#c7c7cd</Color>
<Color x:Key="BoxBorderColor">#dddddd</Color> <Color x:Key="BoxBorderColor">#dddddd</Color>
<Color x:Key="BoxHeaderTextColor">#3c8dbc</Color> <Color x:Key="BoxHeaderTextColor">#3c8dbc</Color>