cipher view cell control
This commit is contained in:
parent
53974c4464
commit
a1c853d7fc
|
@ -37,4 +37,10 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Pages\Accounts\" />
|
<Folder Include="Pages\Accounts\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Controls\CipherViewCell\CipherViewCell.xaml">
|
||||||
|
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ViewCell xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
|
x:Class="Bit.App.Controls.CipherViewCell"
|
||||||
|
xmlns:controls="clr-namespace:Bit.App.Controls">
|
||||||
|
|
||||||
|
<ViewCell.View>
|
||||||
|
<StackLayout x:Name="_layout"
|
||||||
|
Padding="10"
|
||||||
|
x:DataType="controls:CipherViewCellViewModel">
|
||||||
|
|
||||||
|
<StackLayout.BindingContext>
|
||||||
|
<controls:CipherViewCellViewModel />
|
||||||
|
</StackLayout.BindingContext>
|
||||||
|
|
||||||
|
<Label Text="{Binding Cipher.Name}"
|
||||||
|
LineBreakMode="NoWrap"
|
||||||
|
FontSize="16" />
|
||||||
|
|
||||||
|
</StackLayout>
|
||||||
|
</ViewCell.View>
|
||||||
|
|
||||||
|
</ViewCell>
|
|
@ -0,0 +1,34 @@
|
||||||
|
using Bit.Core.Models.View;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
|
namespace Bit.App.Controls
|
||||||
|
{
|
||||||
|
public partial class CipherViewCell : ViewCell
|
||||||
|
{
|
||||||
|
public static readonly BindableProperty CipherProperty = BindableProperty.Create(
|
||||||
|
nameof(Cipher), typeof(CipherView), typeof(CipherViewCell), default(CipherView), BindingMode.OneWay);
|
||||||
|
|
||||||
|
private CipherViewCellViewModel _viewModel;
|
||||||
|
|
||||||
|
public CipherViewCell()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_viewModel = _layout.BindingContext as CipherViewCellViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CipherView Cipher
|
||||||
|
{
|
||||||
|
get => GetValue(CipherProperty) as CipherView;
|
||||||
|
set => SetValue(CipherProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPropertyChanged(string propertyName = null)
|
||||||
|
{
|
||||||
|
base.OnPropertyChanged(propertyName);
|
||||||
|
if(propertyName == CipherProperty.PropertyName)
|
||||||
|
{
|
||||||
|
_viewModel.Cipher = Cipher;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
using Bit.Core.Models.View;
|
||||||
|
using Bit.Core.Utilities;
|
||||||
|
|
||||||
|
namespace Bit.App.Controls
|
||||||
|
{
|
||||||
|
public class CipherViewCellViewModel : ExtendedViewModel
|
||||||
|
{
|
||||||
|
private CipherView _cipher;
|
||||||
|
|
||||||
|
public CipherView Cipher
|
||||||
|
{
|
||||||
|
get => _cipher;
|
||||||
|
set => SetProperty(ref _cipher, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<ContentPage
|
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
|
||||||
xmlns="http://xamarin.com/schemas/2014/forms"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
x:Class="Bit.App.Pages.GroupingsPage"
|
x:Class="Bit.App.Pages.GroupingsPage"
|
||||||
xmlns:pages="clr-namespace:Bit.App.Pages"
|
xmlns:pages="clr-namespace:Bit.App.Pages"
|
||||||
|
xmlns:controls="clr-namespace:Bit.App.Controls"
|
||||||
x:DataType="pages:GroupingsPageViewModel"
|
x:DataType="pages:GroupingsPageViewModel"
|
||||||
Title="{Binding PageTitle}">
|
Title="{Binding PageTitle}">
|
||||||
|
|
||||||
|
@ -13,47 +13,34 @@
|
||||||
|
|
||||||
<ContentPage.Resources>
|
<ContentPage.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<DataTemplate
|
<DataTemplate x:Key="cipherTemplate"
|
||||||
x:Key="cipherTemplate"
|
x:DataType="pages:GroupingsPageListItem">
|
||||||
|
<controls:CipherViewCell Cipher="{Binding Cipher}" />
|
||||||
|
</DataTemplate>
|
||||||
|
|
||||||
|
<DataTemplate x:Key="folderTemplate"
|
||||||
x:DataType="pages:GroupingsPageListItem">
|
x:DataType="pages:GroupingsPageListItem">
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
<StackLayout Padding="10">
|
<StackLayout Padding="10">
|
||||||
<Label
|
<Label Text="{Binding Folder.Name}"
|
||||||
Text="{Binding Cipher.Name}"
|
|
||||||
LineBreakMode="NoWrap"
|
LineBreakMode="NoWrap"
|
||||||
FontSize="16" />
|
FontSize="16" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ViewCell>
|
</ViewCell>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<DataTemplate
|
<DataTemplate x:Key="collectionTemplate"
|
||||||
x:Key="folderTemplate"
|
|
||||||
x:DataType="pages:GroupingsPageListItem">
|
x:DataType="pages:GroupingsPageListItem">
|
||||||
<ViewCell>
|
<ViewCell>
|
||||||
<StackLayout Padding="10">
|
<StackLayout Padding="10">
|
||||||
<Label
|
<Label Text="{Binding Collection.Name}"
|
||||||
Text="{Binding Folder.Name}"
|
|
||||||
LineBreakMode="NoWrap"
|
LineBreakMode="NoWrap"
|
||||||
FontSize="16" />
|
FontSize="16" />
|
||||||
</StackLayout>
|
</StackLayout>
|
||||||
</ViewCell>
|
</ViewCell>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
||||||
<DataTemplate
|
<pages:GroupingsPageListItemSelector x:Key="listItemDataTemplateSelector"
|
||||||
x:Key="collectionTemplate"
|
|
||||||
x:DataType="pages:GroupingsPageListItem">
|
|
||||||
<ViewCell>
|
|
||||||
<StackLayout Padding="10">
|
|
||||||
<Label
|
|
||||||
Text="{Binding Collection.Name}"
|
|
||||||
LineBreakMode="NoWrap"
|
|
||||||
FontSize="16" />
|
|
||||||
</StackLayout>
|
|
||||||
</ViewCell>
|
|
||||||
</DataTemplate>
|
|
||||||
|
|
||||||
<pages:GroupingsPageListItemSelector
|
|
||||||
x:Key="listItemDataTemplateSelector"
|
|
||||||
CipherTemplate="{StaticResource cipherTemplate}"
|
CipherTemplate="{StaticResource cipherTemplate}"
|
||||||
FolderTemplate="{StaticResource folderTemplate}"
|
FolderTemplate="{StaticResource folderTemplate}"
|
||||||
CollectionTemplate="{StaticResource collectionTemplate}" />
|
CollectionTemplate="{StaticResource collectionTemplate}" />
|
||||||
|
@ -61,8 +48,7 @@
|
||||||
</ContentPage.Resources>
|
</ContentPage.Resources>
|
||||||
|
|
||||||
<StackLayout>
|
<StackLayout>
|
||||||
<ListView
|
<ListView x:Name="ItemsListView"
|
||||||
x:Name="ItemsListView"
|
|
||||||
ItemsSource="{Binding Items}"
|
ItemsSource="{Binding Items}"
|
||||||
VerticalOptions="FillAndExpand"
|
VerticalOptions="FillAndExpand"
|
||||||
HasUnevenRows="true"
|
HasUnevenRows="true"
|
||||||
|
|
|
@ -9,8 +9,8 @@ namespace Bit.Core.Utilities
|
||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
protected bool SetProperty<T>(ref T backingStore, T value, [CallerMemberName]string propertyName = "",
|
protected bool SetProperty<T>(ref T backingStore, T value, Action onChanged = null,
|
||||||
Action onChanged = null)
|
[CallerMemberName]string propertyName = "")
|
||||||
{
|
{
|
||||||
if(EqualityComparer<T>.Default.Equals(backingStore, value))
|
if(EqualityComparer<T>.Default.Equals(backingStore, value))
|
||||||
{
|
{
|
||||||
|
@ -18,14 +18,9 @@ namespace Bit.Core.Utilities
|
||||||
}
|
}
|
||||||
|
|
||||||
backingStore = value;
|
backingStore = value;
|
||||||
onChanged?.Invoke();
|
|
||||||
OnPropertyChanged(propertyName);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
||||||
{
|
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
|
onChanged?.Invoke();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue