grouping types filter

This commit is contained in:
Kyle Spearrin 2019-05-01 11:31:00 -04:00
parent caaec3ea57
commit ba9605383d
10 changed files with 118 additions and 43 deletions

View File

@ -43,8 +43,8 @@
ErrorPlaceholder="login.png"
HorizontalOptions="Center"
VerticalOptions="Center"
WidthRequest="20"
HeightRequest="20"
WidthRequest="22"
HeightRequest="22"
IsVisible="False"/>
<Label LineBreakMode="TailTruncation"
Grid.Column="1"

View File

@ -22,34 +22,16 @@
ButtonCommand="{Binding BindingContext.CipherOptionsCommand, Source={x:Reference _page}}" />
</DataTemplate>
<DataTemplate x:Key="folderTemplate"
<DataTemplate x:Key="groupTemplate"
x:DataType="pages:GroupingsPageListItem">
<ViewCell>
<StackLayout Orientation="Horizontal"
StyleClass="list-row, list-row-platform">
<controls:FaLabel Text="{Binding Icon, Mode=OneWay}"
HorizontalOptions="Start"
VerticalOptions="CenterAndExpand"
HorizontalOptions="Center"
VerticalOptions="Center"
StyleClass="list-icon" />
<Label Text="{Binding Folder.Name, Mode=OneWay}"
LineBreakMode="TailTruncation"
HorizontalOptions="StartAndExpand"
VerticalOptions="CenterAndExpand"
StyleClass="list-title"/>
</StackLayout>
</ViewCell>
</DataTemplate>
<DataTemplate x:Key="collectionTemplate"
x:DataType="pages:GroupingsPageListItem">
<ViewCell>
<StackLayout Orientation="Horizontal"
StyleClass="list-row, list-row-platform">
<controls:FaLabel Text="{Binding Icon, Mode=OneWay}"
HorizontalOptions="Start"
VerticalOptions="CenterAndExpand"
StyleClass="list-icon" />
<Label Text="{Binding Collection.Name, Mode=OneWay}"
<Label Text="{Binding Name, Mode=OneWay}"
LineBreakMode="TailTruncation"
HorizontalOptions="StartAndExpand"
VerticalOptions="CenterAndExpand"
@ -60,8 +42,7 @@
<pages:GroupingsPageListItemSelector x:Key="listItemDataTemplateSelector"
CipherTemplate="{StaticResource cipherTemplate}"
FolderTemplate="{StaticResource folderTemplate}"
CollectionTemplate="{StaticResource collectionTemplate}" />
GroupTemplate="{StaticResource groupTemplate}" />
</ResourceDictionary>
</ContentPage.Resources>
<StackLayout x:Name="_mainLayout">

View File

@ -90,6 +90,10 @@ namespace Bit.App.Pages
{
await _viewModel.SelectCollectionAsync(item.Collection);
}
else if(item.Type != null)
{
await _viewModel.SelectTypeAsync(item.Type.Value);
}
}
}
}

View File

@ -4,6 +4,10 @@ namespace Bit.App.Pages
{
public class GroupingsPageListGroup : List<GroupingsPageListItem>
{
public GroupingsPageListGroup(string name, bool doUpper = true)
: this(new List<GroupingsPageListItem>(), name, doUpper)
{ }
public GroupingsPageListGroup(List<GroupingsPageListItem> groupItems, string name, bool doUpper = true)
{
AddRange(groupItems);

View File

@ -1,14 +1,59 @@
using Bit.Core.Models.View;
using Bit.App.Resources;
using Bit.Core.Enums;
using Bit.Core.Models.View;
namespace Bit.App.Pages
{
public class GroupingsPageListItem
{
private string _icon;
private string _name;
public FolderView Folder { get; set; }
public CollectionView Collection { get; set; }
public CipherView Cipher { get; set; }
public CipherType? Type { get; set; }
public string Name
{
get
{
if(_name != null)
{
return _name;
}
if(Folder != null)
{
_name = Folder.Name;
}
else if(Collection != null)
{
_name = Collection.Name;
}
else if(Type != null)
{
switch(Type.Value)
{
case CipherType.Login:
_name = AppResources.TypeLogin;
break;
case CipherType.SecureNote:
_name = AppResources.TypeSecureNote;
break;
case CipherType.Card:
_name = AppResources.TypeCard;
break;
case CipherType.Identity:
_name = AppResources.TypeIdentity;
break;
default:
break;
}
}
return _name;
}
}
public string Icon
{
get
@ -25,6 +70,27 @@ namespace Bit.App.Pages
{
_icon = "";
}
else if(Type != null)
{
switch(Type.Value)
{
case CipherType.Login:
_icon = "";
break;
case CipherType.SecureNote:
_icon = "";
break;
case CipherType.Card:
_icon = "";
break;
case CipherType.Identity:
_icon = "";
break;
default:
_icon = "";
break;
}
}
return _icon;
}
}

View File

@ -5,22 +5,13 @@ namespace Bit.App.Pages
public class GroupingsPageListItemSelector : DataTemplateSelector
{
public DataTemplate CipherTemplate { get; set; }
public DataTemplate FolderTemplate { get; set; }
public DataTemplate CollectionTemplate { get; set; }
public DataTemplate GroupTemplate { get; set; }
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
{
if(item is GroupingsPageListItem listItem)
{
if(listItem.Collection != null)
{
return CollectionTemplate;
}
else if(listItem.Folder != null)
{
return FolderTemplate;
}
return CipherTemplate;
return listItem.Cipher != null ? CipherTemplate : GroupTemplate;
}
return null;
}

View File

@ -125,6 +125,17 @@ namespace Bit.App.Pages
groupedItems.Add(new GroupingsPageListGroup(favListItems, AppResources.Favorites,
Device.RuntimePlatform == Device.iOS));
}
if(MainPage)
{
groupedItems.Add(new GroupingsPageListGroup(
AppResources.Types, Device.RuntimePlatform == Device.iOS)
{
new GroupingsPageListItem { Type = CipherType.Login },
new GroupingsPageListItem { Type = CipherType.Card },
new GroupingsPageListItem { Type = CipherType.Identity },
new GroupingsPageListItem { Type = CipherType.SecureNote }
});
}
if(folderListItems?.Any() ?? false)
{
groupedItems.Add(new GroupingsPageListGroup(folderListItems, AppResources.Folders,
@ -158,10 +169,10 @@ namespace Bit.App.Pages
await Page.Navigation.PushModalAsync(new NavigationPage(page));
}
public async Task SelectFolderAsync(CipherType type)
public async Task SelectTypeAsync(CipherType type)
{
string title = null;
switch(Type.Value)
switch(type)
{
case CipherType.Login:
title = AppResources.Logins;

View File

@ -3219,6 +3219,15 @@ namespace Bit.App.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Types.
/// </summary>
public static string Types {
get {
return ResourceManager.GetString("Types", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Secure Note.
/// </summary>

View File

@ -1390,4 +1390,7 @@
<data name="PasswordHistory" xml:space="preserve">
<value>Password History</value>
</data>
<data name="Types" xml:space="preserve">
<value>Types</value>
</data>
</root>

View File

@ -62,7 +62,7 @@
<Style TargetType="StackLayout"
Class="list-row">
<Setter Property="Padding"
Value="12" />
Value="10, 12" />
</Style>
<Style TargetType="Grid"
Class="list-row">
@ -90,8 +90,14 @@
<Style TargetType="Label"
Class="list-icon"
ApplyToDerivedTypes="True">
<Setter Property="Margin"
Value="3, 3, 3, 0" />
<Setter Property="WidthRequest"
Value="26" />
<Setter Property="HeightRequest"
Value="26" />
<Setter Property="HorizontalTextAlignment"
Value="Center" />
<Setter Property="VerticalTextAlignment"
Value="Center" />
<Setter Property="FontSize"
Value="Large" />
<Setter Property="TextColor"