mirror of
https://github.com/bitwarden/mobile
synced 2026-01-04 01:23:15 +00:00
vault list grouping page
This commit is contained in:
43
src/App/Controls/SectionHeaderViewCell.cs
Normal file
43
src/App/Controls/SectionHeaderViewCell.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
{
|
||||
public class SectionHeaderViewCell : ExtendedViewCell
|
||||
{
|
||||
public SectionHeaderViewCell(string bindingName, string countBindingName = null, Thickness? padding = null)
|
||||
{
|
||||
var label = new Label
|
||||
{
|
||||
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
|
||||
Style = (Style)Application.Current.Resources["text-muted"],
|
||||
VerticalTextAlignment = TextAlignment.Center,
|
||||
HorizontalOptions = LayoutOptions.StartAndExpand
|
||||
};
|
||||
|
||||
label.SetBinding(Label.TextProperty, bindingName);
|
||||
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Padding = padding ?? new Thickness(16, 8, 0, 8),
|
||||
Children = { label },
|
||||
Orientation = StackOrientation.Horizontal
|
||||
};
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(countBindingName))
|
||||
{
|
||||
var countLabel = new Label
|
||||
{
|
||||
LineBreakMode = LineBreakMode.NoWrap,
|
||||
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
|
||||
Style = (Style)Application.Current.Resources["text-muted"],
|
||||
HorizontalOptions = LayoutOptions.End
|
||||
};
|
||||
countLabel.SetBinding(Label.TextProperty, countBindingName);
|
||||
stackLayout.Children.Add(countLabel);
|
||||
}
|
||||
|
||||
View = stackLayout;
|
||||
BackgroundColor = Color.FromHex("efeff4");
|
||||
}
|
||||
}
|
||||
}
|
||||
79
src/App/Controls/VaultGroupingViewCell.cs
Normal file
79
src/App/Controls/VaultGroupingViewCell.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using Bit.App.Models.Page;
|
||||
using FFImageLoading.Forms;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Bit.App.Controls
|
||||
{
|
||||
public class VaultGroupingViewCell : ExtendedViewCell
|
||||
{
|
||||
public static readonly BindableProperty GroupingParameterProeprty = BindableProperty.Create(nameof(GroupingParameter),
|
||||
typeof(VaultListPageModel.Grouping), typeof(VaultGroupingViewCell), null);
|
||||
|
||||
public VaultGroupingViewCell()
|
||||
{
|
||||
Icon = new CachedImage
|
||||
{
|
||||
WidthRequest = 20,
|
||||
HeightRequest = 20,
|
||||
HorizontalOptions = LayoutOptions.Center,
|
||||
VerticalOptions = LayoutOptions.Center,
|
||||
Source = "folder.png",
|
||||
Margin = new Thickness(0, 0, 10, 0)
|
||||
};
|
||||
|
||||
Label = new Label
|
||||
{
|
||||
LineBreakMode = LineBreakMode.TailTruncation,
|
||||
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
|
||||
HorizontalOptions = LayoutOptions.StartAndExpand
|
||||
};
|
||||
Label.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Grouping.Name));
|
||||
|
||||
CountLabel = new Label
|
||||
{
|
||||
LineBreakMode = LineBreakMode.NoWrap,
|
||||
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
|
||||
Style = (Style)Application.Current.Resources["text-muted"],
|
||||
HorizontalOptions = LayoutOptions.End
|
||||
};
|
||||
CountLabel.SetBinding(Label.TextProperty, nameof(VaultListPageModel.Grouping.CipherCount));
|
||||
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Spacing = 0,
|
||||
Padding = new Thickness(16, 8),
|
||||
Children = { Icon, Label, CountLabel },
|
||||
Orientation = StackOrientation.Horizontal
|
||||
};
|
||||
|
||||
if(Device.RuntimePlatform == Device.Android)
|
||||
{
|
||||
Label.TextColor = Color.Black;
|
||||
}
|
||||
|
||||
View = stackLayout;
|
||||
BackgroundColor = Color.White;
|
||||
SetBinding(GroupingParameterProeprty, new Binding("."));
|
||||
}
|
||||
|
||||
public VaultListPageModel.Grouping GroupingParameter
|
||||
{
|
||||
get => GetValue(GroupingParameterProeprty) as VaultListPageModel.Grouping;
|
||||
set { SetValue(GroupingParameterProeprty, value); }
|
||||
}
|
||||
public CachedImage Icon { get; private set; }
|
||||
public Label Label { get; private set; }
|
||||
public Label CountLabel { get; private set; }
|
||||
|
||||
protected override void OnBindingContextChanged()
|
||||
{
|
||||
if(BindingContext is VaultListPageModel.Grouping grouping)
|
||||
{
|
||||
Icon.Source = grouping.Folder ? "folder.png" : "cube.png";
|
||||
}
|
||||
|
||||
base.OnBindingContextChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Bit.App.Models.Page;
|
||||
using FFImageLoading.Forms;
|
||||
using System;
|
||||
using Xamarin.Forms;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user