1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-16 08:13:20 +00:00

stub native cipher view cell for android

This commit is contained in:
Kyle Spearrin
2019-06-07 14:35:44 -04:00
parent d199c83a61
commit d7bfc64840
5 changed files with 553 additions and 433 deletions

View File

@@ -0,0 +1,61 @@
using Android.App;
using Android.Content;
using Android.Views.InputMethods;
using Android.Widget;
using Bit.App.Controls;
using Bit.Droid.Renderers;
using System.ComponentModel;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(CipherViewCell), typeof(CipherViewCellRenderer))]
namespace Bit.Droid.Renderers
{
public class CipherViewCellRenderer : ViewCellRenderer
{
protected override Android.Views.View GetCellCore(Cell item, Android.Views.View convertView,
Android.Views.ViewGroup parent, Context context)
{
var cipherCell = item as CipherViewCell;
if(!(convertView is AndroidCipherCell cell))
{
cell = new AndroidCipherCell(context, cipherCell);
}
cell.CipherViewCell.PropertyChanged += CellPropertyChanged;
cell.CipherViewCell = cipherCell;
cell.CipherViewCell.PropertyChanged -= CellPropertyChanged;
cell.UpdateCell();
return cell;
}
public void CellPropertyChanged(object sender, PropertyChangedEventArgs e)
{
var nativeCell = sender as AndroidCipherCell;
if(e.PropertyName == CipherViewCell.CipherProperty.PropertyName)
{
nativeCell.UpdateCell();
}
}
}
public class AndroidCipherCell : LinearLayout, INativeElementView
{
public AndroidCipherCell(Context context, CipherViewCell cipherCell)
: base(context)
{
var view = (context as Activity).LayoutInflater.Inflate(Resource.Layout.CipherViewCell, null);
CipherViewCell = cipherCell;
Title = view.FindViewById<TextView>(Resource.Id.CipherCellTitle);
AddView(view);
}
public CipherViewCell CipherViewCell { get; set; }
public Element Element => CipherViewCell;
public TextView Title { get; set; }
public void UpdateCell()
{
Title.Text = CipherViewCell.Cipher.Name;
}
}
}