public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv) { var entryCell = (EntryCell)item; var tvc = reusableCell as EntryCellTableViewCell; if (tvc == null) tvc = new EntryCellTableViewCell(item.GetType().FullName); else { tvc.Cell.PropertyChanged -= OnCellPropertyChanged; tvc.TextFieldTextChanged -= OnTextFieldTextChanged; tvc.KeyboardDoneButtonPressed -= OnKeyBoardDoneButtonPressed; } SetRealCell(item, tvc); tvc.Cell = item; tvc.Cell.PropertyChanged += OnCellPropertyChanged; tvc.TextFieldTextChanged += OnTextFieldTextChanged; tvc.KeyboardDoneButtonPressed += OnKeyBoardDoneButtonPressed; WireUpForceUpdateSizeRequested(item, tvc, tv); UpdateBackground(tvc, entryCell); UpdateLabel(tvc, entryCell); UpdateText(tvc, entryCell); UpdateKeyboard(tvc, entryCell); UpdatePlaceholder(tvc, entryCell); UpdateLabelColor(tvc, entryCell); UpdateHorizontalTextAlignment(tvc, entryCell); UpdateIsEnabled(tvc, entryCell); return tvc; }
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv) { EntryCell entryCell = (EntryCell)item; EntryCellTableViewCell entryCellTableViewCell = reusableCell as EntryCellTableViewCell; if (entryCellTableViewCell != null) { entryCellTableViewCell.Cell.PropertyChanged -= OnCellPropertyChanged; entryCellTableViewCell.TextFieldTextChanged -= OnTextFieldTextChanged; entryCellTableViewCell.KeyboardDoneButtonPressed -= OnKeyBoardDoneButtonPressed; } else { entryCellTableViewCell = new EntryCellTableViewCell(item.GetType().FullName); } SetMyRealCell(item, entryCellTableViewCell); entryCellTableViewCell.Cell = item; entryCellTableViewCell.Cell.PropertyChanged += OnCellPropertyChanged; entryCellTableViewCell.TextFieldTextChanged += OnTextFieldTextChanged; entryCellTableViewCell.KeyboardDoneButtonPressed += OnKeyBoardDoneButtonPressed; base.WireUpForceUpdateSizeRequested(item, entryCellTableViewCell, tv); base.UpdateBackground(entryCellTableViewCell, entryCell); UpdateLabel(entryCellTableViewCell, entryCell); UpdateText(entryCellTableViewCell, entryCell); UpdateKeyboard(entryCellTableViewCell, entryCell); UpdatePlaceholder(entryCellTableViewCell, entryCell); UpdateLabelColor(entryCellTableViewCell, entryCell); UpdateHorizontalTextAlignment(entryCellTableViewCell, entryCell); UpdateIsEnabled(entryCellTableViewCell, entryCell); return(entryCellTableViewCell); }
static void UpdateIsEnabled(EntryCellTableViewCell cell, EntryCell entryCell) { cell.UserInteractionEnabled = entryCell.IsEnabled; cell.TextLabel.Enabled = entryCell.IsEnabled; cell.DetailTextLabel.Enabled = entryCell.IsEnabled; cell.TextField.Enabled = entryCell.IsEnabled; }
private static void UpdateText(EntryCellTableViewCell cell, EntryCell entryCell) { if (cell.TextField.Text == entryCell.Text) { return; } cell.TextField.Text = entryCell.Text; }
static void UpdateText(EntryCellTableViewCell cell, EntryCell entryCell) { if (cell.TextField.Text == entryCell.Text) { return; } // double sets side effect on iOS, YAY cell.TextField.Text = entryCell.Text; }
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv) { EntryCellEx entryCell = (EntryCellEx)item; EntryCellTableViewCell entryCellTableViewCell = reusableCell as EntryCellTableViewCell; if (entryCellTableViewCell != null) { entryCellTableViewCell.Cell.PropertyChanged -= OnCellPropertyChanged; entryCellTableViewCell.TextFieldTextChanged -= OnTextFieldTextChanged; entryCellTableViewCell.KeyboardDoneButtonPressed -= OnKeyBoardDoneButtonPressed; var oldCell = entryCellTableViewCell.Cell as EntryCellEx; if (oldCell != null) { oldCell.FocusRequested -= EntryCell_FocusRequested; } } else { entryCellTableViewCell = new EntryCellTableViewCell(item.GetType().FullName); } SetMyRealCell(item, entryCellTableViewCell); entryCellTableViewCell.Cell = item; entryCellTableViewCell.Cell.PropertyChanged += OnCellPropertyChanged; entryCell.FocusRequested += EntryCell_FocusRequested; entryCellTableViewCell.TextFieldTextChanged += OnTextFieldTextChanged; entryCellTableViewCell.KeyboardDoneButtonPressed += OnKeyBoardDoneButtonPressed; base.UpdateBackground(entryCellTableViewCell, entryCell); UpdateLabel(entryCellTableViewCell, entryCell); UpdateText(entryCellTableViewCell, entryCell); UpdateKeyboard(entryCellTableViewCell, entryCell); UpdatePlaceholder(entryCellTableViewCell, entryCell); UpdateLabelColor(entryCellTableViewCell, entryCell); UpdateXAlign(entryCellTableViewCell, entryCell); UpdateIsEnabled(entryCellTableViewCell, entryCell); if (entryCell.RequestInitialFocus) { entryCellTableViewCell.TextField.BecomeFirstResponder(); entryCell.RequestInitialFocus = false; } return entryCellTableViewCell; }
private static void OnCellPropertyChanged(object sender, PropertyChangedEventArgs e) { EntryCell entryCell = (EntryCell)sender; EntryCellTableViewCell realCell = (EntryCellTableViewCell)GetMyRealCell(entryCell); if (e.PropertyName == EntryCell.LabelProperty.PropertyName) { UpdateLabel(realCell, entryCell); return; } if (e.PropertyName == EntryCell.TextProperty.PropertyName) { UpdateText(realCell, entryCell); return; } if (e.PropertyName == EntryCell.PlaceholderProperty.PropertyName) { UpdatePlaceholder(realCell, entryCell); return; } if (e.PropertyName == EntryCell.KeyboardProperty.PropertyName) { UpdateKeyboard(realCell, entryCell); return; } if (e.PropertyName == EntryCell.LabelColorProperty.PropertyName) { UpdateLabelColor(realCell, entryCell); return; } if (e.PropertyName == EntryCell.HorizontalTextAlignmentProperty.PropertyName) { UpdateHorizontalTextAlignment(realCell, entryCell); return; } if (e.PropertyName == Cell.IsEnabledProperty.PropertyName) { UpdateIsEnabled(realCell, entryCell); } }
public override UITableViewCell GetCell(Cell item, UITableViewCell reusableCell, UITableView tv) { var entryCell = (EntryCell)item; var tvc = reusableCell as EntryCellTableViewCell; if (tvc == null) { tvc = new EntryCellTableViewCell(item.GetType().FullName); } else { tvc.PropertyChanged -= HandlePropertyChanged; tvc.TextFieldTextChanged -= OnTextFieldTextChanged; tvc.KeyboardDoneButtonPressed -= OnKeyBoardDoneButtonPressed; } SetRealCell(item, tvc); tvc.Cell = item; tvc.PropertyChanged += HandlePropertyChanged; tvc.TextFieldTextChanged += OnTextFieldTextChanged; tvc.KeyboardDoneButtonPressed += OnKeyBoardDoneButtonPressed; WireUpForceUpdateSizeRequested(item, tvc, tv); UpdateBackground(tvc, entryCell); UpdateLabel(tvc, entryCell); UpdateText(tvc, entryCell); UpdateKeyboard(tvc, entryCell); UpdatePlaceholder(tvc, entryCell); UpdateLabelColor(tvc, entryCell); UpdateHorizontalTextAlignment(tvc, entryCell); UpdateIsEnabled(tvc, entryCell); return(tvc); }
static void UpdateHorizontalTextAlignment(EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextField.TextAlignment = entryCell.HorizontalTextAlignment.ToNativeTextAlignment(); }
static void UpdateHorizontalTextAlignment(EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextField.UpdateHorizontalTextAlignment(entryCell); }
static void UpdateText(EntryCellTableViewCell cell, EntryCell entryCell) { if (cell.TextField.Text == entryCell.Text) return; // double sets side effect on iOS, YAY cell.TextField.Text = entryCell.Text; }
private static void UpdateXAlign(EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextField.TextAlignment = entryCell.XAlign.ToUITextAlignment(); }
static void UpdatePlaceholder(EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextField.Placeholder = entryCell.Placeholder; }
static void UpdateLabelColor(EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextLabel.TextColor = entryCell.LabelColor?.ToPlatform() ?? DefaultTextColor.ToPlatform(); }
static void UpdateKeyboard(EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextField.ApplyKeyboard(entryCell.Keyboard); }
static void UpdateLabelColor(EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextLabel.TextColor = entryCell.LabelColor.ToUIColor(DefaultTextColor); }
static void UpdateHorizontalTextAlignment(EntryCellTableViewCell cell, EntryCell entryCell) { IViewController viewController = entryCell.Parent as View; cell.TextField.TextAlignment = entryCell.HorizontalTextAlignment.ToNativeTextAlignment(viewController?.EffectiveFlowDirection ?? default(EffectiveFlowDirection)); }
static void UpdateLabel(EntryCellTableViewCell cell, EntryCell entryCell) { cell.TextLabel.Text = entryCell.Label; }
private static void OnTextFieldTextChanged(object sender, EventArgs eventArgs) { EntryCellTableViewCell text = (EntryCellTableViewCell)sender; ((EntryCell)text.Cell).Text = text.TextField.Text; }