Exemplo n.º 1
0
        public void UpdatePullToRefreshEnabled(bool isPullToRequestEnabled)
        {
            IsPullToRequestEnabled = isPullToRequestEnabled;

            if (_refreshHeader == null)
            {
                return;
            }

            if (IsPullToRequestEnabled)
            {
                _root.RemoveFromContainer(_refreshHeader);
                _root.PackStart(_refreshHeader, false, false, 0);
                _root.ReorderChild(_refreshHeader, 0);
            }
            else
            {
                _root.RemoveFromContainer(_refreshHeader);
            }
        }
Exemplo n.º 2
0
        private void ClearList()
        {
            _selectedCell = null;

            if (_list != null)
            {
                foreach (var child in _list.Children)
                {
                    _list.RemoveFromContainer(child);
                }
            }

            if (_separators != null)
            {
                _separators.Clear();
            }
        }
Exemplo n.º 3
0
        void RefreshSource(TableRoot source)
        {
            // Clear
            _cells.Clear();

            foreach (var child in _root.AllChildren)
            {
                _root.RemoveFromContainer((Widget)child);
            }

            // Add Title
            if (!string.IsNullOrEmpty(source.Title))
            {
                var titleSpan = new Span()
                {
                    FontSize = 16,
                    Text     = source.Title ?? string.Empty
                };

                Gtk.Label title = new Gtk.Label();
                title.SetAlignment(0, 0);
                title.SetTextFromSpan(titleSpan);
                _root.PackStart(title, false, false, 0);
            }

            // Add Table Section
            for (int i = 0; i < source.Count; i++)
            {
                if (source[i] is TableSection tableSection)
                {
                    var tableSectionSpan = new Span()
                    {
                        FontSize  = 12,
                        Text      = tableSection.Title ?? string.Empty,
                        TextColor = tableSection.TextColor
                    };

                    // Table Section Title
                    Gtk.Label sectionTitle = new Gtk.Label();
                    sectionTitle.SetAlignment(0, 0);
                    sectionTitle.SetTextFromSpan(tableSectionSpan);
                    _root.PackStart(sectionTitle, false, false, 0);

                    // Table Section Separator
                    EventBox separator = new EventBox
                    {
                        HeightRequest = 1
                    };

                    separator.ModifyBg(StateType.Normal, Color.Black.ToGtkColor());
                    _root.PackStart(separator, false, false, 0);

                    // Cells
                    _cells.Clear();

                    for (int j = 0; j < tableSection.Count; j++)
                    {
                        var cell = tableSection[j];

                        var renderer =
                            (Cells.CellRenderer)Internals.Registrar.Registered.GetHandlerForObject <IRegisterable>(cell);
                        var nativeCell = renderer.GetCell(cell, null, null);

                        if (nativeCell != null)
                        {
                            nativeCell.ButtonPressEvent += (sender, args) =>
                            {
                                if (sender is CellBase gtkCell && gtkCell.Cell != null)
                                {
                                    var selectedCell = gtkCell.Cell;

                                    OnItemTapped?.Invoke(this, new ItemTappedEventArgs(selectedCell));
                                }
                            };
                            _cells.Add(nativeCell);
                        }
                    }

                    foreach (var cell in _cells)
                    {
                        _root.PackStart(cell, false, false, 0);
                    }
                }

                // Refresh
                _root.ShowAll();
            }
        }