1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-03 17:13:50 +00:00

paperclip icon for attachments in listing

This commit is contained in:
Kyle Spearrin
2017-07-23 00:09:24 -04:00
parent c96cf2b0e5
commit 4e8f69f692
15 changed files with 68 additions and 21 deletions

View File

@@ -28,6 +28,14 @@ namespace Bit.App.Controls
Margin = new Thickness(5, 0, 0, 0)
};
LabelIcon2 = new CachedImage
{
WidthRequest = 16,
HeightRequest = 16,
HorizontalOptions = LayoutOptions.Start,
Margin = new Thickness(5, 0, 0, 0)
};
Button = new ExtendedButton
{
WidthRequest = 60
@@ -42,13 +50,15 @@ namespace Bit.App.Controls
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(60, GridUnitType.Absolute) });
grid.Children.Add(Label, 0, 0);
grid.Children.Add(Detail, 0, 1);
grid.Children.Add(LabelIcon, 1, 0);
grid.Children.Add(Button, 2, 0);
Grid.SetColumnSpan(Detail, 2);
grid.Children.Add(LabelIcon2, 2, 0);
grid.Children.Add(Button, 3, 0);
Grid.SetColumnSpan(Detail, 3);
Grid.SetRowSpan(Button, 2);
if(Device.RuntimePlatform == Device.Android)
@@ -62,6 +72,7 @@ namespace Bit.App.Controls
public Label Label { get; private set; }
public Label Detail { get; private set; }
public CachedImage LabelIcon { get; private set; }
public CachedImage LabelIcon2 { get; private set; }
public Button Button { get; private set; }
}
}

View File

@@ -15,12 +15,14 @@ namespace Bit.App.Controls
Label.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Login.Name));
Detail.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Login.Username));
LabelIcon.SetBinding(VisualElement.IsVisibleProperty, nameof(VaultListPageModel.Login.Shared));
LabelIcon2.SetBinding(VisualElement.IsVisibleProperty, nameof(VaultListPageModel.Login.HasAttachments));
Button.Image = "more";
Button.Command = new Command(() => moreClickedAction?.Invoke(LoginParameter));
Button.BackgroundColor = Color.Transparent;
LabelIcon.Source = "share";
LabelIcon2.Source = "paperclip";
BackgroundColor = Color.White;
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Bit.App.Resources;
using System.Linq;
namespace Bit.App.Models.Page
{
@@ -12,6 +13,7 @@ namespace Bit.App.Models.Page
{
Id = login.Id;
Shared = !string.IsNullOrWhiteSpace(login.OrganizationId);
HasAttachments = login.Attachments?.Any() ?? false;
FolderId = login.FolderId;
Name = login.Name?.Decrypt(login.OrganizationId);
Username = login.Username?.Decrypt(login.OrganizationId) ?? " ";
@@ -22,6 +24,7 @@ namespace Bit.App.Models.Page
public string Id { get; set; }
public bool Shared { get; set; }
public bool HasAttachments { get; set; }
public string FolderId { get; set; }
public string Name { get; set; }
public string Username { get; set; }

View File

@@ -54,15 +54,19 @@ namespace Bit.App.Services
public async Task<IEnumerable<Login>> GetAllAsync()
{
var attachmentData = await _attachmentRepository.GetAllByUserIdAsync(_authService.UserId);
var attachmentDict = attachmentData.GroupBy(a => a.LoginId).ToDictionary(g => g.Key, g => g.ToList());
var data = await _loginRepository.GetAllByUserIdAsync(_authService.UserId);
var logins = data.Select(f => new Login(f));
var logins = data.Select(f => new Login(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null));
return logins;
}
public async Task<IEnumerable<Login>> GetAllAsync(bool favorites)
{
var attachmentData = await _attachmentRepository.GetAllByUserIdAsync(_authService.UserId);
var attachmentDict = attachmentData.GroupBy(a => a.LoginId).ToDictionary(g => g.Key, g => g.ToList());
var data = await _loginRepository.GetAllByUserIdAsync(_authService.UserId, favorites);
var logins = data.Select(f => new Login(f));
var logins = data.Select(f => new Login(f, attachmentDict.ContainsKey(f.Id) ? attachmentDict[f.Id] : null));
return logins;
}