1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-30 23:23:38 +00:00

ExtendedTextCell and ExtendedViewCell for iOS and Android. BackgroundColor and Disclousure Indicators

This commit is contained in:
Kyle Spearrin
2016-05-17 21:28:19 -04:00
parent e9999adcf2
commit 72c807a5b2
14 changed files with 186 additions and 26 deletions

View File

@@ -0,0 +1,45 @@
using Bit.App.Controls;
using Bit.iOS.Controls;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using CoreGraphics;
[assembly: ExportRenderer(typeof(ExtendedTextCell), typeof(ExtendedTextCellRenderer))]
namespace Bit.iOS.Controls
{
public class ExtendedTextCellRenderer : TextCellRenderer
{
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var extendedCell = (ExtendedTextCell)item;
var cell = base.GetCell(item, reusableCell, tv);
if(cell != null)
{
cell.BackgroundColor = extendedCell.BackgroundColor.ToUIColor();
if(extendedCell.ShowDisclousure)
{
cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
if(!string.IsNullOrEmpty(extendedCell.DisclousureImage))
{
var detailDisclosureButton = UIButton.FromType(UIButtonType.Custom);
detailDisclosureButton.SetImage(UIImage.FromBundle(extendedCell.DisclousureImage), UIControlState.Normal);
detailDisclosureButton.SetImage(UIImage.FromBundle(extendedCell.DisclousureImage), UIControlState.Selected);
detailDisclosureButton.Frame = new CGRect(0f, 0f, 30f, 30f);
detailDisclosureButton.TouchUpInside += (sender, e) =>
{
var index = tv.IndexPathForCell(cell);
tv.SelectRow(index, true, UITableViewScrollPosition.None);
tv.Source.AccessoryButtonTapped(tv, index);
};
cell.AccessoryView = detailDisclosureButton;
}
}
}
return cell;
}
}
}

View File

@@ -0,0 +1,25 @@
using Bit.App.Controls;
using Bit.iOS.Controls;
using UIKit;
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
[assembly: ExportRenderer(typeof(ExtendedViewCell), typeof(ExtendedViewCellRenderer))]
namespace Bit.iOS.Controls
{
public class ExtendedViewCellRenderer : ViewCellRenderer
{
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv)
{
var extendedCell = (ExtendedViewCell)item;
var cell = base.GetCell(item, reusableCell, tv);
if(cell != null)
{
cell.BackgroundColor = extendedCell.BackgroundColor.ToUIColor();
}
return cell;
}
}
}