Exemple #1
0
        protected override AView GetCellCore(Cell item, AView convertView, ViewGroup parent, Context context)
        {
            var cell = (SwitchCell)Cell;

            if ((_view = convertView as SwitchCellView) == null)
            {
                _view = new SwitchCellView(context, item);
            }

            _view.Cell = cell;

            var aSwitch = _view.AccessoryView as ASwitch;

            if (aSwitch != null)
            {
                _defaultTrackDrawable = aSwitch.TrackDrawable;
            }

            UpdateText();
            UpdateChecked();
            UpdateHeight();
            UpdateIsEnabled(_view, cell);
            UpdateFlowDirection();
            UpdateOnColor(_view, cell);

            return(_view);
        }
Exemple #2
0
        void UpdateOnColor(SwitchCellView cell, SwitchCell switchCell)
        {
            var aSwitch = cell.AccessoryView as ASwitch;

            if (aSwitch != null)
            {
                if (switchCell.On)
                {
                    if (switchCell.OnColor == Color.Default)
                    {
                        aSwitch.TrackDrawable = _defaultTrackDrawable;
                    }
                    else
                    {
                        if (System.Maui.Maui.SdkInt >= BuildVersionCodes.JellyBean)
                        {
                            aSwitch.TrackDrawable.SetColorFilter(switchCell.OnColor, FilterMode.Multiply);
                        }
                    }
                }
                else
                {
                    aSwitch.TrackDrawable.ClearColorFilter();
                }
            }
        }
Exemple #3
0
        void UpdateIsEnabled(SwitchCellView cell, SwitchCell switchCell)
        {
            cell.Enabled = switchCell.IsEnabled;
            var aSwitch = cell.AccessoryView as ASwitch;

            if (aSwitch != null)
            {
                aSwitch.Enabled = switchCell.IsEnabled;
            }
        }