/// <summary>
        /// processing when row is selected.
        /// </summary>
        /// <param name="tableView">Table view.</param>
        /// <param name="indexPath">Index path.</param>
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.CellAt(indexPath);

            _settingsView.Model.RowSelected(indexPath.Section, indexPath.Row);

            if (cell is CommandCellView)
            {
                var cmdCell = cell as CommandCellView;
                cmdCell?.Execute?.Invoke();
                if (!(cmdCell.Cell as CommandCell).KeepSelectedUntilBack)
                {
                    tableView.DeselectRow(indexPath, true);
                }
            }
            else if (cell is ButtonCellView)
            {
                var buttonCell = cell as ButtonCellView;
                buttonCell?.Execute?.Invoke();
                tableView.DeselectRow(indexPath, true);
            }
            else if (cell is PickerCellView)
            {
                var pickerCell = (cell as PickerCellView).Cell as PickerCell;

                if (pickerCell.ItemsSource == null)
                {
                    tableView.DeselectRow(indexPath, true);
                    return;
                }

                //var naviCtrl = GetUINavigationController(UIApplication.SharedApplication.Windows[0].RootViewController);
                var naviCtrl = GetUINavigationController(UIApplication.SharedApplication.KeyWindow.RootViewController);
                _pickerVC?.Dispose();
                _pickerVC = new PickerTableViewController((PickerCellView)cell, tableView);
                BeginInvokeOnMainThread(() => naviCtrl.PushViewController(_pickerVC, true));

                if (!pickerCell.KeepSelectedUntilBack)
                {
                    tableView.DeselectRow(indexPath, true);
                }
            }
            else if (cell is IPickerCell)
            {
                tableView.DeselectRow(indexPath, true);
                var pCell = cell as IPickerCell;
                pCell.DummyField.BecomeFirstResponder();
            }
            else if (cell is EntryCellView)
            {
                var eCell = cell as EntryCellView;
                eCell.ValueField.BecomeFirstResponder();
            }
        }
        /// <summary>
        /// Dispose the specified disposing.
        /// </summary>
        /// <returns>The dispose.</returns>
        /// <param name="disposing">If set to <c>true</c> disposing.</param>
        protected override void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                _settingsView = null;
                _tableView    = null;
                _pickerVC?.Dispose();
                _pickerVC = null;
            }

            _disposed = true;

            base.Dispose(disposing);
        }
Example #3
0
        /// <summary>
        /// Rows the selected.
        /// </summary>
        /// <param name="tableView">Table view.</param>
        /// <param name="indexPath">Index path.</param>
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            if (_PickerCell.ItemsSource == null)
            {
                tableView.DeselectRow(indexPath, true);
                return;
            }

            _pickerVC?.Dispose();

            var naviCtrl = GetUINavigationController(UIApplication.SharedApplication.KeyWindow.RootViewController);

            if (naviCtrl is ShellSectionRenderer shell)
            {
                // When use Shell, the NativeView is wrapped in a Forms.ContentPage.
                _pickerVC = new PickerTableViewController(this, tableView, shell.ShellSection.Navigation);
                // Fix height broken. For some reason, TableView ContentSize is broken.
                _pickerVC.TableView.ContentInset = new UIEdgeInsets(44, 0, 44, 0);
                var page = new ContentPage();
                page.Content = _pickerVC.TableView.ToView();;
                page.Title   = _PickerCell.PageTitle;

                // Fire manually because INavigation.PushAsync does not work ViewDidAppear and ViewWillAppear.
                _pickerVC.ViewDidAppear(false);
                _pickerVC.InitializeView();
                BeginInvokeOnMainThread(async() => {
                    await shell.ShellSection.Navigation.PushAsync(page, true);
                    _pickerVC.InitializeScroll();
                });
            }
            else
            {
                // When use traditional navigation.
                _pickerVC = new PickerTableViewController(this, tableView);
                BeginInvokeOnMainThread(() => naviCtrl.PushViewController(_pickerVC, true));
            }


            if (!_PickerCell.KeepSelectedUntilBack)
            {
                tableView.DeselectRow(indexPath, true);
            }
        }
        /// <summary>
        /// Rows the selected.
        /// </summary>
        /// <param name="tableView">Table view.</param>
        /// <param name="indexPath">Index path.</param>
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            if (_PickerCell.ItemsSource == null)
            {
                tableView.DeselectRow(indexPath, true);
                return;
            }

            var naviCtrl = GetUINavigationController(UIApplication.SharedApplication.KeyWindow.RootViewController);

            _pickerVC?.Dispose();
            _pickerVC = new PickerTableViewController(this, tableView);
            BeginInvokeOnMainThread(() => naviCtrl.PushViewController(_pickerVC, true));

            if (!_PickerCell.KeepSelectedUntilBack)
            {
                tableView.DeselectRow(indexPath, true);
            }
        }
Example #5
0
        /// <summary>
        /// Dispose the specified disposing.
        /// </summary>
        /// <returns>The dispose.</returns>
        /// <param name="disposing">If set to <c>true</c> disposing.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _pickerVC?.Dispose();
                _pickerVC = null;

                if (_notifyCollection != null)
                {
                    _notifyCollection.CollectionChanged -= ItemsSourceCollectionChanged;
                    _notifyCollection = null;
                }
                if (_selectedCollection != null)
                {
                    _selectedCollection.CollectionChanged -= SelectedItems_CollectionChanged;
                    _selectedCollection = null;
                }
            }
            base.Dispose(disposing);
        }