Exemplo n.º 1
0
        void _handleTap()
        {
            RenderBox  itemBox    = (RenderBox)this.context.findRenderObject();
            Rect       itemRect   = itemBox.localToGlobal(Offset.zero) & itemBox.size;
            EdgeInsets menuMargin = ButtonTheme.of(this.context).alignedDropdown
                ? DropdownConstants._kAlignedMenuMargin
                : DropdownConstants._kUnalignedMenuMargin;

            D.assert(this._dropdownRoute == null);
            this._dropdownRoute = new _DropdownRoute <T>(
                items: this.widget.items,
                buttonRect: menuMargin.inflateRect(itemRect),
                padding: DropdownConstants._kMenuItemPadding,
                selectedIndex: this._selectedIndex ?? 0,
                elevation: this.widget.elevation,
                theme: Theme.of(this.context, shadowThemeOnly: true),
                style: this._textStyle,
                barrierLabel: MaterialLocalizations.of(this.context).modalBarrierDismissLabel
                );

            Navigator.push(this.context, this._dropdownRoute).Then(newValue => {
                _DropdownRouteResult <T> value = newValue as _DropdownRouteResult <T>;
                this._dropdownRoute            = null;
                if (!this.mounted || newValue == null)
                {
                    return;
                }

                if (this.widget.onChanged != null)
                {
                    this.widget.onChanged(value.result);
                }
            });
        }
Exemplo n.º 2
0
        void _handleTap()
        {
            RenderBox          itemBox       = (RenderBox)context.findRenderObject();
            Rect               itemRect      = itemBox.localToGlobal(Offset.zero) & itemBox.size;
            TextDirection      textDirection = Directionality.of(context);
            EdgeInsetsGeometry menuMargin    = ButtonTheme.of(context).alignedDropdown
                ? material_._kAlignedMenuMargin
                : material_._kUnalignedMenuMargin;

            List <_MenuItem <T> > menuItems = new List <_MenuItem <T> >(new _MenuItem <T> [widget.items.Count]);

            for (int index = 0; index < widget.items.Count; index += 1)
            {
                var pindex = index;
                menuItems[pindex] = new _MenuItem <T>(
                    item: widget.items[pindex],
                    onLayout: (Size size) => {
                    if (_dropdownRoute == null)
                    {
                        return;
                    }

                    _dropdownRoute.itemHeights[pindex] = size.height;
                }
                    );
            }

            D.assert(_dropdownRoute == null);
            _dropdownRoute = new _DropdownRoute <T>(
                items: menuItems,
                buttonRect: menuMargin.resolve(textDirection).inflateRect(itemRect),
                padding: material_._kMenuItemPadding.resolve(textDirection),
                selectedIndex: _selectedIndex ?? 0,
                elevation: widget.elevation,
                theme: Theme.of(context, shadowThemeOnly: true),
                style: _textStyle,
                barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
                itemHeight: widget.itemHeight,
                dropdownColor: widget.dropdownColor
                );

            Navigator.push <T>(context, _dropdownRoute).then(newValue => {
                _DropdownRouteResult <T> value = newValue as _DropdownRouteResult <T>;
                _removeDropdownRoute();
                if (!mounted || newValue == null)
                {
                    return;
                }

                if (widget.onChanged != null)
                {
                    widget.onChanged(value.result);
                }
            });
            if (widget.onTap != null)
            {
                widget.onTap();
            }
        }
Exemplo n.º 3
0
 public bool Equals(_DropdownRouteResult <T> other)
 {
     return(result.Equals(other.result));
 }
Exemplo n.º 4
0
 public bool Equals(_DropdownRouteResult <T> other)
 {
     return(this.result == other.result);
 }