mirror of
https://github.com/bitwarden/mobile
synced 2025-12-26 21:23:46 +00:00
cipher view cell control
This commit is contained in:
23
src/App/Controls/CipherViewCell/CipherViewCell.xaml
Normal file
23
src/App/Controls/CipherViewCell/CipherViewCell.xaml
Normal file
@@ -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>
|
||||
34
src/App/Controls/CipherViewCell/CipherViewCell.xaml.cs
Normal file
34
src/App/Controls/CipherViewCell/CipherViewCell.xaml.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/App/Controls/CipherViewCell/CipherViewCellViewModel.cs
Normal file
16
src/App/Controls/CipherViewCell/CipherViewCellViewModel.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user