public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { var cell = View.Model.GetCell(indexPath.Section, indexPath.Row); var nativeCell = CellTableViewCell.GetNativeCell(tableView, cell); return(nativeCell); }
async void SetImage(ImageCell cell, CellTableViewCell target) { var source = cell.ImageSource; #pragma warning disable CA1416 // TODO: 'UITableViewCell.ImageView' is unsupported on: 'ios' 14.0 and later target.ImageView.Image = null; var uiimage = await source.GetNativeImageAsync().ConfigureAwait(false); if (uiimage != null) { NSRunLoop.Main.BeginInvokeOnMainThread(() => { if (target.Cell != null) { target.ImageView.Image = uiimage; target.SetNeedsLayout(); } else { uiimage?.Dispose(); } }); } #pragma warning restore CA1416 }
void UpdateFlowDirection(CellTableViewCell cell, SwitchCell switchCell) { IVisualElementController controller = switchCell.Parent as View; var uiSwitch = cell.AccessoryView as UISwitch; uiSwitch.UpdateFlowDirection(controller); }
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv) { var textCell = (TextCell)item; if (!(reusableCell is CellTableViewCell tvc)) { tvc = new CellTableViewCell(UITableViewCellStyle.Subtitle, item.GetType().FullName); }
void UpdateIsEnabled(CellTableViewCell cell, SwitchCell switchCell) { cell.UserInteractionEnabled = switchCell.IsEnabled; cell.TextLabel.Enabled = switchCell.IsEnabled; cell.DetailTextLabel.Enabled = switchCell.IsEnabled; var uiSwitch = cell.AccessoryView as UISwitch; if (uiSwitch != null) { uiSwitch.Enabled = switchCell.IsEnabled; } }
void UpdateOnColor(CellTableViewCell cell, SwitchCell switchCell) { var uiSwitch = cell.AccessoryView as UISwitch; if (uiSwitch != null) { if (switchCell.OnColor == null) { uiSwitch.OnTintColor = _defaultOnColor; } else { uiSwitch.OnTintColor = switchCell.OnColor.ToUIColor(); } } }
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv) { var tvc = reusableCell as CellTableViewCell; UISwitch uiSwitch = null; if (tvc == null) { tvc = new CellTableViewCell(UITableViewCellStyle.Value1, CellName); } else { uiSwitch = tvc.AccessoryView as UISwitch; tvc.PropertyChanged -= HandlePropertyChanged; } SetRealCell(item, tvc); if (uiSwitch == null) { uiSwitch = new UISwitch(new RectangleF()); uiSwitch.ValueChanged += OnSwitchValueChanged; tvc.AccessoryView = uiSwitch; } var boolCell = (SwitchCell)item; _defaultOnColor = UISwitch.Appearance.OnTintColor; tvc.Cell = item; tvc.PropertyChanged += HandlePropertyChanged; tvc.AccessoryView = uiSwitch; #pragma warning disable CA1416 // TODO: 'UITableViewCell.TextLabel' is unsupported on: 'ios' 14.0 and later tvc.TextLabel.Text = boolCell.Text; uiSwitch.On = boolCell.On; WireUpForceUpdateSizeRequested(item, tvc, tv); UpdateBackground(tvc, item); UpdateIsEnabled(tvc, boolCell); UpdateFlowDirection(tvc, boolCell); UpdateOnColor(tvc, boolCell); return(tvc); }
static void OnSwitchValueChanged(object sender, EventArgs eventArgs) { var view = (UIView)sender; var sw = (UISwitch)view; CellTableViewCell realCell = null; while (view.Superview != null && realCell == null) { view = view.Superview; realCell = view as CellTableViewCell; } if (realCell != null) { ((SwitchCell)realCell.Cell).On = sw.On; } }
async void SetImage(ImageCell cell, CellTableViewCell target) { var source = cell.ImageSource; target.ImageView.Image = null; var uiimage = await source.GetNativeImageAsync().ConfigureAwait(false); if (uiimage != null) { NSRunLoop.Main.BeginInvokeOnMainThread(() => { if (target.Cell != null) { target.ImageView.Image = uiimage; target.SetNeedsLayout(); } else { uiimage?.Dispose(); } }); } }