Esempio n. 1
0
        protected override void UpdateView()
        {
            TitleLabel.Text          = Item.Title;
            DetailLabel.Text         = "";
            Accessory                = UITableViewCellAccessory.None;
            RightConstraint.Constant = 16;
            AccessoryView            = null;

            switch (Item)
            {
            case ButtonRow button:
                break;

            case ToggleRow toggle:
                var switchControl = new UISwitch();
                switchControl.On = toggle.Value;
                switchControl.Rx().Changed()
                .Delay(TimeSpan.FromSeconds(0.5))         // This is so the switch animation has time to finish before refresh
                .Subscribe(_ => toggle.Action.Execute())
                .DisposedBy(disposeBag);

                AccessoryView = switchControl;
                break;

            case NavigationRow navigation:
                DetailLabel.Text         = navigation.Detail;
                Accessory                = UITableViewCellAccessory.DisclosureIndicator;
                RightConstraint.Constant = 0;
                break;

            case InfoRow info:
                DetailLabel.Text = info.Detail;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            SetNeedsLayout();
        }