Esempio n. 1
0
        void _handlePressed(bool isExpanded, int index)
        {
            if (this.widget.expansionCallback != null)
            {
                this.widget.expansionCallback(index, isExpanded);
            }

            if (this.widget._allowOnlyOnePanelOpen)
            {
                ExpansionPanelRadio pressedChild = (ExpansionPanelRadio)this.widget.children[index];

                for (int childIndex = 0; childIndex < this.widget.children.Count; childIndex++)
                {
                    ExpansionPanelRadio child = (ExpansionPanelRadio)this.widget.children[childIndex];
                    if (this.widget.expansionCallback != null && childIndex != index &&
                        child.value == this._currentOpenPanel?.value)
                    {
                        this.widget.expansionCallback(childIndex, false);
                    }
                }

                this._currentOpenPanel = isExpanded ? null : pressedChild;
            }

            this.setState(() => { });
        }
Esempio n. 2
0
        bool _isChildExpanded(int index)
        {
            if (this.widget._allowOnlyOnePanelOpen)
            {
                ExpansionPanelRadio radioWidget = (ExpansionPanelRadio)this.widget.children[index];
                return(this._currentOpenPanel?.value == radioWidget.value);
            }

            return(this.widget.children[index].isExpanded);
        }
Esempio n. 3
0
 public override void initState()
 {
     base.initState();
     if (this.widget._allowOnlyOnePanelOpen)
     {
         D.assert(this._allIdentifierUnique(), "All object identifiers are not unique!");
         foreach (ExpansionPanelRadio child in this.widget.children)
         {
             if (this.widget.initialOpenPanelValue != null &&
                 child.value == this.widget.initialOpenPanelValue)
             {
                 this._currentOpenPanel = child;
             }
         }
     }
 }
Esempio n. 4
0
 public override void initState()
 {
     base.initState();
     if (widget._allowOnlyOnePanelOpen)
     {
         D.assert(_allIdentifierUnique(), () => "All ExpansionPanelRadio identifier values must be unique.");
         foreach (ExpansionPanelRadio child in widget.children)
         {
             if (widget.initialOpenPanelValue != null)
             {
                 _currentOpenPanel =
                     searchPanelByValue(widget.children.Cast <ExpansionPanelRadio>().ToList(),
                                        widget.initialOpenPanelValue);
             }
         }
     }
 }
Esempio n. 5
0
        public override void didUpdateWidget(StatefulWidget oldWidget)
        {
            base.didUpdateWidget(oldWidget);
            ExpansionPanelList _oldWidget = (ExpansionPanelList)oldWidget;

            if (widget._allowOnlyOnePanelOpen)
            {
                D.assert(_allIdentifierUnique(), () => "All ExpansionPanelRadio identifier values must be unique.");
                if (!_oldWidget._allowOnlyOnePanelOpen)
                {
                    _currentOpenPanel =
                        searchPanelByValue(widget.children.Cast <ExpansionPanelRadio>().ToList(),
                                           widget.initialOpenPanelValue);
                }
            }
            else
            {
                _currentOpenPanel = null;
            }
        }
Esempio n. 6
0
        public override void didUpdateWidget(StatefulWidget oldWidget)
        {
            base.didUpdateWidget(oldWidget);
            ExpansionPanelList _oldWidget = (ExpansionPanelList)oldWidget;

            if (this.widget._allowOnlyOnePanelOpen)
            {
                D.assert(this._allIdentifierUnique(), "All object identifiers are not unique!");
                foreach (ExpansionPanelRadio newChild in this.widget.children)
                {
                    if (this.widget.initialOpenPanelValue != null &&
                        newChild.value == this.widget.initialOpenPanelValue)
                    {
                        this._currentOpenPanel = newChild;
                    }
                }
            }
            else if (_oldWidget._allowOnlyOnePanelOpen)
            {
                this._currentOpenPanel = null;
            }
        }