remove old boxedview

This commit is contained in:
Kyle Spearrin 2019-06-04 09:38:31 -04:00
parent 11e5b2ea5d
commit 0c699e6c12
7 changed files with 0 additions and 1023 deletions

View file

@ -1,85 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Xamarin.Forms;
using Xamarin.Forms.Internals;
namespace Bit.App.Controls.BoxedView
{
public class BoxedModel : TableModel
{
private static readonly BindableProperty PathProperty = BindableProperty.Create(
"Path", typeof(Tuple<int, int>), typeof(Cell), null);
private BoxedRoot _root;
private IEnumerable<BoxedSection> _visibleSections;
public BoxedModel(BoxedRoot root)
{
_root = root;
_visibleSections = _root.Where(x => x.IsVisible);
}
public override Cell GetCell(int section, int row)
{
var cell = (Cell)GetItem(section, row);
SetPath(cell, new Tuple<int, int>(section, row));
return cell;
}
public override object GetItem(int section, int row)
{
return _visibleSections.ElementAt(section)[row];
}
public override int GetRowCount(int section)
{
return _visibleSections.ElementAt(section).Count;
}
public override int GetSectionCount()
{
return _visibleSections.Count();
}
public virtual BoxedSection GetSection(int section)
{
return _visibleSections.ElementAtOrDefault(section);
}
public override string GetSectionTitle(int section)
{
return _visibleSections.ElementAt(section).Title;
}
public virtual string GetFooterText(int section)
{
return _visibleSections.ElementAt(section).FooterText;
}
protected override void OnRowSelected(object item)
{
base.OnRowSelected(item);
(item as BaseCell)?.OnTapped();
}
public virtual double GetHeaderHeight(int section)
{
return _visibleSections.ElementAt(section).HeaderHeight;
}
public static Tuple<int, int> GetPath(Cell item)
{
if(item == null)
{
throw new ArgumentNullException(nameof(item));
}
return item.GetValue(PathProperty) as Tuple<int, int>;
}
private static void SetPath(Cell item, Tuple<int, int> index)
{
item?.SetValue(PathProperty, index);
}
}
}

View file

@ -1,61 +0,0 @@
using System;
using System.Collections.Specialized;
using System.ComponentModel;
using Xamarin.Forms;
namespace Bit.App.Controls.BoxedView
{
public class BoxedRoot : TableSectionBase<BoxedSection>
{
public BoxedRoot()
{
SetupEvents();
}
public event EventHandler<EventArgs> SectionCollectionChanged;
private void ChildCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
{
SectionCollectionChanged?.Invoke(this, EventArgs.Empty);
}
private void ChildPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if(e.PropertyName == TitleProperty.PropertyName)
{
OnPropertyChanged(TitleProperty.PropertyName);
}
else if(e.PropertyName == BoxedSection.FooterTextProperty.PropertyName)
{
OnPropertyChanged(BoxedSection.FooterTextProperty.PropertyName);
}
else if(e.PropertyName == BoxedSection.IsVisibleProperty.PropertyName)
{
OnPropertyChanged(BoxedSection.IsVisibleProperty.PropertyName);
}
}
private void SetupEvents()
{
CollectionChanged += (sender, args) =>
{
if(args.NewItems != null)
{
foreach(BoxedSection section in args.NewItems)
{
section.CollectionChanged += ChildCollectionChanged;
section.PropertyChanged += ChildPropertyChanged;
}
}
if(args.OldItems != null)
{
foreach(BoxedSection section in args.OldItems)
{
section.CollectionChanged -= ChildCollectionChanged;
section.PropertyChanged -= ChildPropertyChanged;
}
}
};
}
}
}

View file

@ -1,147 +0,0 @@
using System.Collections;
using System.Collections.Specialized;
using Xamarin.Forms;
namespace Bit.App.Controls.BoxedView
{
public class BoxedSection : TableSectionBase<Cell>
{
public static BindableProperty IsVisibleProperty = BindableProperty.Create(
nameof(IsVisible), typeof(bool), typeof(BoxedSection), true, defaultBindingMode: BindingMode.OneWay);
public static BindableProperty FooterTextProperty = BindableProperty.Create(
nameof(FooterText), typeof(string), typeof(BoxedSection), default(string),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ItemTemplateProperty = BindableProperty.Create(
nameof(ItemTemplate), typeof(DataTemplate), typeof(BoxedSection), default(DataTemplate),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ItemsSourceProperty = BindableProperty.Create(
nameof(ItemsSource), typeof(IList), typeof(BoxedSection), default(IList),
defaultBindingMode: BindingMode.OneWay, propertyChanged: ItemsChanged);
public static BindableProperty HeaderHeightProperty = BindableProperty.Create(
nameof(HeaderHeight), typeof(double), typeof(BoxedSection), -1d, defaultBindingMode: BindingMode.OneWay);
public static BindableProperty UseDragSortProperty = BindableProperty.Create(
nameof(UseDragSort), typeof(bool), typeof(BoxedSection), false, defaultBindingMode: BindingMode.OneWay);
public BoxedSection()
{ }
public BoxedSection(string title)
: base(title)
{ }
public bool IsVisible
{
get => (bool)GetValue(IsVisibleProperty);
set => SetValue(IsVisibleProperty, value);
}
public string FooterText
{
get => (string)GetValue(FooterTextProperty);
set => SetValue(FooterTextProperty, value);
}
public DataTemplate ItemTemplate
{
get => (DataTemplate)GetValue(ItemTemplateProperty);
set => SetValue(ItemTemplateProperty, value);
}
public IList ItemsSource
{
get => (IList)GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
public double HeaderHeight
{
get => (double)GetValue(HeaderHeightProperty);
set => SetValue(HeaderHeightProperty, value);
}
public bool UseDragSort
{
get => (bool)GetValue(UseDragSortProperty);
set => SetValue(UseDragSortProperty, value);
}
private static void ItemsChanged(BindableObject bindable, object oldValue, object newValue)
{
var section = bindable as BoxedSection;
if(section.ItemTemplate == null)
{
return;
}
if(oldValue is INotifyCollectionChanged oldObservableCollection)
{
oldObservableCollection.CollectionChanged -= section.OnItemsSourceCollectionChanged;
}
if(newValue is INotifyCollectionChanged newObservableCollection)
{
newObservableCollection.CollectionChanged += section.OnItemsSourceCollectionChanged;
}
section.Clear();
if(newValue is IList newValueAsEnumerable)
{
foreach(var item in newValueAsEnumerable)
{
var view = CreateChildViewFor(section.ItemTemplate, item, section);
section.Add(view);
}
}
}
private void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if(e.Action == NotifyCollectionChangedAction.Replace)
{
RemoveAt(e.OldStartingIndex);
var item = e.NewItems[e.NewStartingIndex];
var view = CreateChildViewFor(ItemTemplate, item, this);
Insert(e.NewStartingIndex, view);
}
else if(e.Action == NotifyCollectionChangedAction.Add)
{
if(e.NewItems != null)
{
for(var i = 0; i < e.NewItems.Count; ++i)
{
var item = e.NewItems[i];
var view = CreateChildViewFor(ItemTemplate, item, this);
Insert(i + e.NewStartingIndex, view);
}
}
}
else if(e.Action == NotifyCollectionChangedAction.Remove)
{
if(e.OldItems != null)
{
RemoveAt(e.OldStartingIndex);
}
}
else if(e.Action == NotifyCollectionChangedAction.Reset)
{
Clear();
}
}
private static Cell CreateChildViewFor(DataTemplate template, object item, BindableObject container)
{
if(template is DataTemplateSelector selector)
{
template = selector.SelectTemplate(item, container);
}
// Binding context
template.SetValue(BindingContextProperty, item);
return template.CreateContent() as Cell;
}
}
}

View file

@ -1,443 +0,0 @@
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using Xamarin.Forms;
namespace Bit.App.Controls.BoxedView
{
[ContentProperty("Root")]
public class BoxedView : TableView
{
public static new BindableProperty BackgroundColorProperty = BindableProperty.Create(
nameof(BackgroundColor), typeof(Color), typeof(BoxedView), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty SeparatorColorProperty = BindableProperty.Create(
nameof(SeparatorColor), typeof(Color), typeof(BoxedView), Color.FromRgb(199, 199, 204),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty SelectedColorProperty = BindableProperty.Create(
nameof(SelectedColor), typeof(Color), typeof(BoxedView), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty HeaderPaddingProperty = BindableProperty.Create(
nameof(HeaderPadding), typeof(Thickness), typeof(BoxedView), new Thickness(15, 8, 15, 8),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty HeaderTextColorProperty = BindableProperty.Create(
nameof(HeaderTextColor), typeof(Color), typeof(BoxedView), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty HeaderFontSizeProperty = BindableProperty.Create(
nameof(HeaderFontSize), typeof(double), typeof(BoxedView), 14.0,
defaultBindingMode: BindingMode.OneWay,
defaultValueCreator: bindable => Device.GetNamedSize(NamedSize.Small, (BoxedView)bindable));
public static BindableProperty HeaderTextVerticalAlignProperty = BindableProperty.Create(
nameof(HeaderTextVerticalAlign), typeof(LayoutAlignment), typeof(BoxedView), LayoutAlignment.End,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty HeaderBackgroundColorProperty = BindableProperty.Create(
nameof(HeaderBackgroundColor), typeof(Color), typeof(BoxedView), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty HeaderHeightProperty = BindableProperty.Create(
nameof(HeaderHeight), typeof(double), typeof(BoxedView), -1d, defaultBindingMode: BindingMode.OneWay);
public static BindableProperty FooterTextColorProperty = BindableProperty.Create(
nameof(FooterTextColor), typeof(Color), typeof(BoxedView), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty FooterFontSizeProperty = BindableProperty.Create(
nameof(FooterFontSize), typeof(double), typeof(BoxedView), 14.0,
defaultBindingMode: BindingMode.OneWay,
defaultValueCreator: bindable => Device.GetNamedSize(NamedSize.Small, (BoxedView)bindable));
public static BindableProperty FooterBackgroundColorProperty = BindableProperty.Create(
nameof(FooterBackgroundColor), typeof(Color), typeof(BoxedView), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty FooterPaddingProperty = BindableProperty.Create(
nameof(FooterPadding), typeof(Thickness), typeof(BoxedView), new Thickness(15, 8, 15, 8),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty CellTitleColorProperty = BindableProperty.Create(
nameof(CellTitleColor), typeof(Color), typeof(BoxedView), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty CellTitleFontSizeProperty = BindableProperty.Create(
nameof(CellTitleFontSize), typeof(double), typeof(BoxedView), -1.0,
defaultBindingMode: BindingMode.OneWay,
defaultValueCreator: bindable => Device.GetNamedSize(NamedSize.Default, (BoxedView)bindable));
public static BindableProperty CellValueTextColorProperty = BindableProperty.Create(
nameof(CellValueTextColor), typeof(Color), typeof(BoxedView), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty CellValueTextFontSizeProperty = BindableProperty.Create(
nameof(CellValueTextFontSize), typeof(double), typeof(BoxedView), -1.0d,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty CellBackgroundColorProperty = BindableProperty.Create(
nameof(CellBackgroundColor), typeof(Color), typeof(BoxedView), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty CellAccentColorProperty = BindableProperty.Create(
nameof(CellAccentColor), typeof(Color), typeof(BoxedView), Color.Accent,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ShowSectionTopBottomBorderProperty = BindableProperty.Create(
nameof(ShowSectionTopBottomBorder), typeof(bool), typeof(BoxedView), true,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ScrollToBottomProperty = BindableProperty.Create(
nameof(ScrollToBottom), typeof(bool), typeof(BoxedView), default(bool),
defaultBindingMode: BindingMode.TwoWay);
public static BindableProperty ScrollToTopProperty = BindableProperty.Create(
nameof(ScrollToTop), typeof(bool), typeof(BoxedView), default(bool),
defaultBindingMode: BindingMode.TwoWay);
public static BindableProperty VisibleContentHeightProperty = BindableProperty.Create(
nameof(VisibleContentHeight), typeof(double), typeof(BoxedView), -1d,
defaultBindingMode: BindingMode.OneWayToSource);
public static BindableProperty ItemsSourceProperty = BindableProperty.Create(
nameof(ItemsSource), typeof(IEnumerable), typeof(BoxedView), default(IEnumerable),
defaultBindingMode: BindingMode.OneWay, propertyChanged: ItemsChanged);
public static BindableProperty ItemTemplateProperty = BindableProperty.Create(
nameof(ItemTemplate), typeof(DataTemplate), typeof(BoxedView), default(DataTemplate),
defaultBindingMode: BindingMode.OneWay);
private BoxedRoot _root;
public BoxedView()
{
VerticalOptions = HorizontalOptions = LayoutOptions.FillAndExpand;
Root = new BoxedRoot();
Model = new BoxedModel(Root);
}
public new BoxedModel Model { get; set; }
public new BoxedRoot Root
{
get => _root;
set
{
if(_root != null)
{
_root.PropertyChanged -= RootOnPropertyChanged;
_root.CollectionChanged -= OnCollectionChanged;
_root.SectionCollectionChanged -= OnSectionCollectionChanged;
}
_root = value;
// Transfer binding context to the children (maybe...)
SetInheritedBindingContext(_root, BindingContext);
_root.PropertyChanged += RootOnPropertyChanged;
_root.CollectionChanged += OnCollectionChanged;
_root.SectionCollectionChanged += OnSectionCollectionChanged;
}
}
// Make the unnecessary property existing at TableView sealed.
private new int Intent { get; set; }
public new Color BackgroundColor
{
get => (Color)GetValue(BackgroundColorProperty);
set => SetValue(BackgroundColorProperty, value);
}
public Color SeparatorColor
{
get => (Color)GetValue(SeparatorColorProperty);
set => SetValue(SeparatorColorProperty, value);
}
public Color SelectedColor
{
get => (Color)GetValue(SelectedColorProperty);
set => SetValue(SelectedColorProperty, value);
}
public Thickness HeaderPadding
{
get => (Thickness)GetValue(HeaderPaddingProperty);
set => SetValue(HeaderPaddingProperty, value);
}
public Color HeaderTextColor
{
get => (Color)GetValue(HeaderTextColorProperty);
set => SetValue(HeaderTextColorProperty, value);
}
[TypeConverter(typeof(FontSizeConverter))]
public double HeaderFontSize
{
get => (double)GetValue(HeaderFontSizeProperty);
set => SetValue(HeaderFontSizeProperty, value);
}
public LayoutAlignment HeaderTextVerticalAlign
{
get => (LayoutAlignment)GetValue(HeaderTextVerticalAlignProperty);
set => SetValue(HeaderTextVerticalAlignProperty, value);
}
public Color HeaderBackgroundColor
{
get => (Color)GetValue(HeaderBackgroundColorProperty);
set => SetValue(HeaderBackgroundColorProperty, value);
}
public double HeaderHeight
{
get => (double)GetValue(HeaderHeightProperty);
set => SetValue(HeaderHeightProperty, value);
}
public Color FooterTextColor
{
get => (Color)GetValue(FooterTextColorProperty);
set => SetValue(FooterTextColorProperty, value);
}
[TypeConverter(typeof(FontSizeConverter))]
public double FooterFontSize
{
get => (double)GetValue(FooterFontSizeProperty);
set => SetValue(FooterFontSizeProperty, value);
}
public Color FooterBackgroundColor
{
get => (Color)GetValue(FooterBackgroundColorProperty);
set => SetValue(FooterBackgroundColorProperty, value);
}
public Thickness FooterPadding
{
get => (Thickness)GetValue(FooterPaddingProperty);
set => SetValue(FooterPaddingProperty, value);
}
public Color CellTitleColor
{
get => (Color)GetValue(CellTitleColorProperty);
set => SetValue(CellTitleColorProperty, value);
}
[TypeConverter(typeof(FontSizeConverter))]
public double CellTitleFontSize
{
get => (double)GetValue(CellTitleFontSizeProperty);
set => SetValue(CellTitleFontSizeProperty, value);
}
public Color CellValueTextColor
{
get => (Color)GetValue(CellValueTextColorProperty);
set => SetValue(CellValueTextColorProperty, value);
}
[TypeConverter(typeof(FontSizeConverter))]
public double CellValueTextFontSize
{
get => (double)GetValue(CellValueTextFontSizeProperty);
set => SetValue(CellValueTextFontSizeProperty, value);
}
public Color CellBackgroundColor
{
get => (Color)GetValue(CellBackgroundColorProperty);
set => SetValue(CellBackgroundColorProperty, value);
}
public Color CellAccentColor
{
get => (Color)GetValue(CellAccentColorProperty);
set => SetValue(CellAccentColorProperty, value);
}
public bool ShowSectionTopBottomBorder
{
get => (bool)GetValue(ShowSectionTopBottomBorderProperty);
set => SetValue(ShowSectionTopBottomBorderProperty, value);
}
public bool ScrollToBottom
{
get => (bool)GetValue(ScrollToBottomProperty);
set => SetValue(ScrollToBottomProperty, value);
}
public bool ScrollToTop
{
get => (bool)GetValue(ScrollToTopProperty);
set => SetValue(ScrollToTopProperty, value);
}
public double VisibleContentHeight
{
get => (double)GetValue(VisibleContentHeightProperty);
set => SetValue(VisibleContentHeightProperty, value);
}
public IEnumerable ItemsSource
{
get => (IEnumerable)GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
public DataTemplate ItemTemplate
{
get => (DataTemplate)GetValue(ItemTemplateProperty);
set => SetValue(ItemTemplateProperty, value);
}
public new event EventHandler ModelChanged;
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
if(Root != null)
{
SetInheritedBindingContext(Root, BindingContext);
}
}
private void RootOnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
var changed = e.PropertyName == TableSectionBase.TitleProperty.PropertyName ||
e.PropertyName == BoxedSection.FooterTextProperty.PropertyName ||
e.PropertyName == BoxedSection.IsVisibleProperty.PropertyName;
if(changed)
{
OnModelChanged();
}
}
protected override void OnPropertyChanged(string propertyName = null)
{
base.OnPropertyChanged(propertyName);
var changed = propertyName == HasUnevenRowsProperty.PropertyName ||
propertyName == HeaderHeightProperty.PropertyName ||
propertyName == HeaderFontSizeProperty.PropertyName ||
propertyName == HeaderTextColorProperty.PropertyName ||
propertyName == HeaderBackgroundColorProperty.PropertyName ||
propertyName == HeaderTextVerticalAlignProperty.PropertyName ||
propertyName == HeaderPaddingProperty.PropertyName ||
propertyName == FooterFontSizeProperty.PropertyName ||
propertyName == FooterTextColorProperty.PropertyName ||
propertyName == FooterBackgroundColorProperty.PropertyName ||
propertyName == FooterPaddingProperty.PropertyName;
if(changed)
{
OnModelChanged();
}
}
public void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
OnModelChanged();
}
public void OnSectionCollectionChanged(object sender, EventArgs childCollectionChangedEventArgs)
{
OnModelChanged();
}
protected new void OnModelChanged()
{
var cells = Root?.SelectMany(r => r);
if(cells == null)
{
return;
}
foreach(var cell in cells)
{
cell.Parent = this;
}
ModelChanged?.Invoke(this, EventArgs.Empty);
}
private static void ItemsChanged(BindableObject bindable, object oldValue, object newValue)
{
var boxedView = bindable as BoxedView;
if(boxedView.ItemTemplate == null)
{
return;
}
if(oldValue is INotifyCollectionChanged oldObservableCollection)
{
oldObservableCollection.CollectionChanged -= boxedView.OnItemsSourceCollectionChanged;
}
if(newValue is INotifyCollectionChanged newObservableCollection)
{
newObservableCollection.CollectionChanged += boxedView.OnItemsSourceCollectionChanged;
}
boxedView.Root.Clear();
if(newValue is IList newValueAsEnumerable)
{
foreach(var item in newValueAsEnumerable)
{
var view = CreateChildViewFor(boxedView.ItemTemplate, item, boxedView);
boxedView.Root.Add(view);
}
}
}
private void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if(e.Action == NotifyCollectionChangedAction.Replace)
{
Root.RemoveAt(e.OldStartingIndex);
var item = e.NewItems[e.NewStartingIndex];
var view = CreateChildViewFor(ItemTemplate, item, this);
Root.Insert(e.NewStartingIndex, view);
}
else if(e.Action == NotifyCollectionChangedAction.Add)
{
if(e.NewItems != null)
{
for(var i = 0; i < e.NewItems.Count; ++i)
{
var item = e.NewItems[i];
var view = CreateChildViewFor(ItemTemplate, item, this);
Root.Insert(i + e.NewStartingIndex, view);
}
}
}
else if(e.Action == NotifyCollectionChangedAction.Remove)
{
if(e.OldItems != null)
{
Root.RemoveAt(e.OldStartingIndex);
}
}
else if(e.Action == NotifyCollectionChangedAction.Reset)
{
Root.Clear();
}
}
private static BoxedSection CreateChildViewFor(DataTemplate template, object item, BindableObject container)
{
if(template is DataTemplateSelector selector)
{
template = selector.SelectTemplate(item, container);
}
template.SetValue(BindingContextProperty, item);
return template.CreateContent() as BoxedSection;
}
}
}

View file

@ -1,147 +0,0 @@
using System;
using System.Windows.Input;
using Xamarin.Forms;
namespace Bit.App.Controls.BoxedView
{
public class BaseCell : Cell
{
public static BindableProperty TitleProperty = BindableProperty.Create(
nameof(Title), typeof(string), typeof(BaseCell), default(string), defaultBindingMode: BindingMode.OneWay);
public static BindableProperty TitleColorProperty = BindableProperty.Create(
nameof(TitleColor), typeof(Color), typeof(BaseCell), Color.Gray,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty TitleFontSizeProperty = BindableProperty.Create(
nameof(TitleFontSize), typeof(double), typeof(BaseCell), 14.0, defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button1IconProperty = BindableProperty.Create(
nameof(Button1Icon), typeof(string), typeof(BaseCell), default(string),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button1CommandProperty = BindableProperty.Create(
nameof(Button1Command), typeof(ICommand), typeof(BaseCell), default(ICommand),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button1CommandParameterProperty = BindableProperty.Create(
nameof(Button1CommandParameter), typeof(object), typeof(BaseCell), default(object),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button2IconProperty = BindableProperty.Create(
nameof(Button2Icon), typeof(string), typeof(BaseCell), default(string),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button2CommandProperty = BindableProperty.Create(
nameof(Button2Command), typeof(ICommand), typeof(BaseCell), default(ICommand),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button2CommandParameterProperty = BindableProperty.Create(
nameof(Button2CommandParameter), typeof(object), typeof(BaseCell), default(object),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button3IconProperty = BindableProperty.Create(
nameof(Button3Icon), typeof(string), typeof(BaseCell), default(string),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button3CommandProperty = BindableProperty.Create(
nameof(Button3Command), typeof(ICommand), typeof(BaseCell), default(ICommand),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty Button3CommandParameterProperty = BindableProperty.Create(
nameof(Button3CommandParameter), typeof(object), typeof(BaseCell), default(object),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty BackgroundColorProperty = BindableProperty.Create(
nameof(BackgroundColor), typeof(Color), typeof(BaseCell), default(Color),
defaultBindingMode: BindingMode.OneWay);
public string Title
{
get => (string)GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
public Color TitleColor
{
get => (Color)GetValue(TitleColorProperty);
set => SetValue(TitleColorProperty, value);
}
[TypeConverter(typeof(FontSizeConverter))]
public double TitleFontSize
{
get => (double)GetValue(TitleFontSizeProperty);
set => SetValue(TitleFontSizeProperty, value);
}
public string Button1Icon
{
get => (string)GetValue(Button1IconProperty);
set => SetValue(Button1IconProperty, value);
}
public ICommand Button1Command
{
get => (ICommand)GetValue(Button1CommandProperty);
set => SetValue(Button1CommandProperty, value);
}
public object Button1CommandParameter
{
get => GetValue(Button1CommandParameterProperty);
set => SetValue(Button1CommandParameterProperty, value);
}
public string Button2Icon
{
get => (string)GetValue(Button2IconProperty);
set => SetValue(Button2IconProperty, value);
}
public ICommand Button2Command
{
get => (ICommand)GetValue(Button2CommandProperty);
set => SetValue(Button2CommandProperty, value);
}
public object Button2CommandParameter
{
get => GetValue(Button2CommandParameterProperty);
set => SetValue(Button2CommandParameterProperty, value);
}
public string Button3Icon
{
get => (string)GetValue(Button3IconProperty);
set => SetValue(Button3IconProperty, value);
}
public ICommand Button3Command
{
get => (ICommand)GetValue(Button3CommandProperty);
set => SetValue(Button3CommandProperty, value);
}
public object Button3CommandParameter
{
get => GetValue(Button3CommandParameterProperty);
set => SetValue(Button3CommandParameterProperty, value);
}
public Color BackgroundColor
{
get => (Color)GetValue(BackgroundColorProperty);
set => SetValue(BackgroundColorProperty, value);
}
public BoxedSection Section { get; set; }
public new event EventHandler Tapped;
protected internal new void OnTapped()
{
Tapped?.Invoke(this, EventArgs.Empty);
}
}
}

View file

@ -1,102 +0,0 @@
using System;
using Xamarin.Forms;
namespace Bit.App.Controls.BoxedView
{
public class EntryCell : BaseCell, IEntryCellController
{
public static BindableProperty ValueTextProperty = BindableProperty.Create(
nameof(ValueText), typeof(string), typeof(EntryCell), default(string),
defaultBindingMode: BindingMode.TwoWay);
// propertyChanging: ValueTextPropertyChanging);
public static BindableProperty ValueTextColorProperty = BindableProperty.Create(
nameof(ValueTextColor), typeof(Color), typeof(EntryCell), Color.Black,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ValueTextFontSizeProperty = BindableProperty.Create(
nameof(ValueTextFontSize), typeof(double), typeof(EntryCell), 18.0,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty KeyboardProperty = BindableProperty.Create(
nameof(Keyboard), typeof(Keyboard), typeof(EntryCell), Keyboard.Default,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty PlaceholderProperty = BindableProperty.Create(
nameof(Placeholder), typeof(string), typeof(EntryCell), default(string),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty TextAlignmentProperty = BindableProperty.Create(
nameof(TextAlignment), typeof(TextAlignment), typeof(EntryCell), TextAlignment.Start,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty AccentColorProperty = BindableProperty.Create(
nameof(AccentColor), typeof(Color), typeof(EntryCell), default(Color),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty IsPasswordProperty = BindableProperty.Create(
nameof(IsPassword), typeof(bool), typeof(EntryCell), default(bool),
defaultBindingMode: BindingMode.OneWay);
public string ValueText
{
get => (string)GetValue(ValueTextProperty);
set => SetValue(ValueTextProperty, value);
}
public Color ValueTextColor
{
get => (Color)GetValue(ValueTextColorProperty);
set => SetValue(ValueTextColorProperty, value);
}
[TypeConverter(typeof(FontSizeConverter))]
public double ValueTextFontSize
{
get => (double)GetValue(ValueTextFontSizeProperty);
set => SetValue(ValueTextFontSizeProperty, value);
}
public Keyboard Keyboard
{
get => (Keyboard)GetValue(KeyboardProperty);
set => SetValue(KeyboardProperty, value);
}
public string Placeholder
{
get => (string)GetValue(PlaceholderProperty);
set => SetValue(PlaceholderProperty, value);
}
public TextAlignment TextAlignment
{
get => (TextAlignment)GetValue(TextAlignmentProperty);
set => SetValue(TextAlignmentProperty, value);
}
public Color AccentColor
{
get => (Color)GetValue(AccentColorProperty);
set => SetValue(AccentColorProperty, value);
}
public bool IsPassword
{
get => (bool)GetValue(IsPasswordProperty);
set => SetValue(IsPasswordProperty, value);
}
public event EventHandler Completed;
public void SendCompleted()
{
Completed?.Invoke(this, EventArgs.Empty);
}
private static void ValueTextPropertyChanging(BindableObject bindable, object oldValue, object newValue)
{
// Check changes
}
}
}

View file

@ -1,38 +0,0 @@
using Xamarin.Forms;
namespace Bit.App.Controls.BoxedView
{
public class LabelCell : BaseCell
{
public static BindableProperty ValueTextProperty = BindableProperty.Create(
nameof(ValueText), typeof(string), typeof(LabelCell), default(string),
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ValueTextColorProperty = BindableProperty.Create(
nameof(ValueTextColor), typeof(Color), typeof(LabelCell), Color.Black,
defaultBindingMode: BindingMode.OneWay);
public static BindableProperty ValueTextFontSizeProperty = BindableProperty.Create(
nameof(ValueTextFontSize), typeof(double), typeof(LabelCell), 18.0,
defaultBindingMode: BindingMode.OneWay);
public string ValueText
{
get => (string)GetValue(ValueTextProperty);
set => SetValue(ValueTextProperty, value);
}
public Color ValueTextColor
{
get => (Color)GetValue(ValueTextColorProperty);
set => SetValue(ValueTextColorProperty, value);
}
[TypeConverter(typeof(FontSizeConverter))]
public double ValueTextFontSize
{
get => (double)GetValue(ValueTextFontSizeProperty);
set => SetValue(ValueTextFontSizeProperty, value);
}
}
}