1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-27 12:26:31 +01:00

border for sections

This commit is contained in:
Kyle Spearrin 2019-05-31 11:36:44 -04:00
parent defac4e2d5
commit dcf412d94d
4 changed files with 29 additions and 17 deletions

View File

@ -82,17 +82,19 @@ namespace Bit.App.Pages
var groupedItems = new List<GroupingsPageListGroup>();
var ciphers = await _cipherService.GetAllDecryptedByUrlAsync(Uri, null);
var matching = ciphers.Item1?.Select(c => new GroupingsPageListItem { Cipher = c }).ToList();
var hasMatching = matching?.Any() ?? false;
if(matching?.Any() ?? false)
{
groupedItems.Add(
new GroupingsPageListGroup(matching, AppResources.MatchingItems, matching.Count, false));
new GroupingsPageListGroup(matching, AppResources.MatchingItems, matching.Count, false, true));
}
var fuzzy = ciphers.Item2?.Select(c =>
new GroupingsPageListItem { Cipher = c, FuzzyAutofill = true }).ToList();
if(fuzzy?.Any() ?? false)
{
groupedItems.Add(
new GroupingsPageListGroup(fuzzy, AppResources.PossibleMatchingItems, fuzzy.Count, false));
new GroupingsPageListGroup(fuzzy, AppResources.PossibleMatchingItems, fuzzy.Count, false,
!hasMatching));
}
GroupedItems.ResetWithRange(groupedItems);
ShowList = groupedItems.Any();

View File

@ -20,6 +20,8 @@
<ContentPage.Resources>
<ResourceDictionary>
<u:InverseBoolConverter x:Key="inverseBool" />
<ToolbarItem x:Name="_syncItem" x:Key="syncItem" Text="{u:I18n Sync}"
Clicked="Sync_Clicked" Order="Secondary" />
<ToolbarItem x:Name="_lockItem" x:Key="lockItem" Text="{u:I18n Lock}"
@ -95,13 +97,17 @@
<ListView.GroupHeaderTemplate>
<DataTemplate x:DataType="pages:GroupingsPageListGroup">
<ViewCell>
<StackLayout StyleClass="list-row-header">
<Label
Text="{Binding Name}"
StyleClass="list-header, list-header-platform" />
<Label
Text="{Binding ItemCount}"
StyleClass="list-header-sub" />
<StackLayout Spacing="0" Padding="0">
<BoxView StyleClass="box-row-separator"
IsVisible="{Binding First, Converter={StaticResource inverseBool}}" />
<StackLayout StyleClass="list-row-header">
<Label
Text="{Binding Name}"
StyleClass="list-header, list-header-platform" />
<Label
Text="{Binding ItemCount}"
StyleClass="list-header-sub" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>

View File

@ -4,12 +4,12 @@ namespace Bit.App.Pages
{
public class GroupingsPageListGroup : List<GroupingsPageListItem>
{
public GroupingsPageListGroup(string name, int count, bool doUpper = true)
: this(new List<GroupingsPageListItem>(), name, count, doUpper)
public GroupingsPageListGroup(string name, int count, bool doUpper = true, bool first = false)
: this(new List<GroupingsPageListItem>(), name, count, doUpper, first)
{ }
public GroupingsPageListGroup(List<GroupingsPageListItem> groupItems, string name, int count,
bool doUpper = true)
bool doUpper = true, bool first = false)
{
AddRange(groupItems);
if(string.IsNullOrWhiteSpace(name))
@ -25,8 +25,10 @@ namespace Bit.App.Pages
Name = name;
}
ItemCount = count.ToString("N0");
First = first;
}
public bool First { get; set; }
public string Name { get; set; }
public string NameShort => string.IsNullOrWhiteSpace(Name) || Name.Length == 0 ? "-" : Name[0].ToString();
public string ItemCount { get; set; }

View File

@ -150,15 +150,16 @@ namespace Bit.App.Pages
_collectionCounts[c.Node.Id] : 0).ToString("N0")
}).ToList();
var hasFavorites = favListItems?.Any() ?? false;
if(favListItems?.Any() ?? false)
{
groupedItems.Add(new GroupingsPageListGroup(favListItems, AppResources.Favorites,
favListItems.Count, Device.RuntimePlatform == Device.iOS));
favListItems.Count, Device.RuntimePlatform == Device.iOS, true));
}
if(MainPage)
{
groupedItems.Add(new GroupingsPageListGroup(
AppResources.Types, 4, Device.RuntimePlatform == Device.iOS)
AppResources.Types, 4, Device.RuntimePlatform == Device.iOS, !hasFavorites)
{
new GroupingsPageListItem
{
@ -189,17 +190,18 @@ namespace Bit.App.Pages
if(folderListItems?.Any() ?? false)
{
groupedItems.Add(new GroupingsPageListGroup(folderListItems, AppResources.Folders,
folderListItems.Count, Device.RuntimePlatform == Device.iOS));
folderListItems.Count, Device.RuntimePlatform == Device.iOS, !MainPage));
}
if(collectionListItems?.Any() ?? false)
{
groupedItems.Add(new GroupingsPageListGroup(collectionListItems, AppResources.Collections,
collectionListItems.Count, Device.RuntimePlatform == Device.iOS));
collectionListItems.Count, Device.RuntimePlatform == Device.iOS, !MainPage));
}
if(ciphersListItems?.Any() ?? false)
{
groupedItems.Add(new GroupingsPageListGroup(ciphersListItems, AppResources.Items,
ciphersListItems.Count, Device.RuntimePlatform == Device.iOS));
ciphersListItems.Count, Device.RuntimePlatform == Device.iOS,
!MainPage && !groupedItems.Any()));
}
GroupedItems.ResetWithRange(groupedItems);
}