Пример #1
0
        public override Widget build(BuildContext context)
        {
            ThemeData       theme       = Theme.of(context);
            ButtonThemeData buttonTheme = ButtonTheme.of(context);

            return(new RawMaterialButton(
                       onPressed: onPressed,
                       onLongPress: () => onLongPress?.Invoke(),
                       onHighlightChanged: onHighlightChanged,
                       fillColor: buttonTheme.getFillColor(this),
                       textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)),
                       focusColor: buttonTheme.getFocusColor(this),
                       hoverColor: buttonTheme.getHoverColor(this),
                       highlightColor: buttonTheme.getHighlightColor(this),
                       splashColor: buttonTheme.getSplashColor(this),
                       elevation: buttonTheme.getElevation(this),
                       focusElevation: buttonTheme.getFocusElevation(this),
                       hoverElevation: buttonTheme.getHoverElevation(this),
                       highlightElevation: buttonTheme.getHighlightElevation(this),
                       disabledElevation: buttonTheme.getDisabledElevation(this),
                       padding: buttonTheme.getPadding(this),
                       visualDensity: visualDensity ?? theme.visualDensity,
                       constraints: buttonTheme.getConstraints(this),
                       shape: buttonTheme.getShape(this),
                       clipBehavior: clipBehavior ?? Clip.none,
                       focusNode: focusNode,
                       autofocus: autofocus ?? false,
                       materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this),
                       animationDuration: buttonTheme.getAnimationDuration(this),
                       child: child
                       ));
        }
        public override Widget build(BuildContext context)
        {
            ButtonThemeData buttonTheme = ButtonTheme.of(context);

            return(new _OutlineButton(
                       onPressed: onPressed,
                       onLongPress: onLongPress,
                       brightness: buttonTheme.getBrightness(this),
                       textTheme: textTheme,
                       textColor: buttonTheme.getTextColor(this),
                       disabledTextColor: buttonTheme.getDisabledTextColor(this),
                       color: color,
                       focusColor: buttonTheme.getFocusColor(this),
                       hoverColor: buttonTheme.getHoverColor(this),
                       highlightColor: buttonTheme.getHighlightColor(this),
                       splashColor: buttonTheme.getSplashColor(this),
                       highlightElevation: buttonTheme.getHighlightElevation(this),
                       borderSide: borderSide,
                       disabledBorderColor: disabledBorderColor,
                       highlightedBorderColor: highlightedBorderColor ?? buttonTheme.colorScheme.primary,
                       padding: buttonTheme.getPadding(this),
                       visualDensity: visualDensity,
                       shape: buttonTheme.getShape(this),
                       clipBehavior: clipBehavior,
                       focusNode: focusNode,
                       child: child
                       ));
        }
Пример #3
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);
                }
            });
        }
Пример #4
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();
            }
        }
Пример #5
0
        public override Widget wrap(BuildContext context, Widget child)
        {
            ButtonTheme ancestorTheme = context.findAncestorWidgetOfExactType <ButtonTheme>();

            return(ReferenceEquals(this, ancestorTheme)
                ? child
                : ButtonTheme.fromButtonThemeData(data: data, child: child));
        }
Пример #6
0
        public override Widget build(BuildContext context)
        {
            // D.assert(debugCheckHasMaterialLocalizations(context));

            ThemeData   theme       = Theme.of(context);
            DialogTheme dialogTheme = DialogTheme.of(context);

            List <Widget> children = new List <Widget>();

            if (this.title != null)
            {
                children.Add(new Padding(
                                 padding: this.titlePadding ??
                                 EdgeInsets.fromLTRB(24.0f, 24.0f, 24.0f, this.content == null ? 20.0f : 0.0f),
                                 child: new DefaultTextStyle(
                                     style: this.titleTextStyle ?? dialogTheme.titleTextStyle ?? theme.textTheme.title,
                                     child: this.title
                                     )
                                 ));
            }

            if (this.content != null)
            {
                children.Add(new Flexible(
                                 child: new Padding(
                                     padding: this.contentPadding,
                                     child: new DefaultTextStyle(
                                         style: this.contentTextStyle ?? dialogTheme.contentTextStyle ?? theme.textTheme.subhead,
                                         child: this.content
                                         )
                                     )
                                 ));
            }

            if (this.actions != null)
            {
                children.Add(ButtonTheme.bar(
                                 child: new ButtonBar(
                                     children: this.actions
                                     )
                                 ));
            }

            Widget dialogChild = new IntrinsicWidth(
                child: new Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.stretch,
                    children: children
                    )
                );

            return(new Dialog(
                       backgroundColor: this.backgroundColor,
                       elevation: this.elevation,
                       shape: this.shape,
                       child: dialogChild
                       ));
        }
Пример #7
0
        public override Widget build(BuildContext context)
        {
            ButtonThemeData    parentButtonTheme = ButtonTheme.of(context);
            ButtonBarThemeData barTheme          = ButtonBarTheme.of(context);

            ButtonThemeData buttonTheme = parentButtonTheme.copyWith(
                textTheme: buttonTextTheme ?? barTheme?.buttonTextTheme ?? ButtonTextTheme.primary,
                minWidth: buttonMinWidth ?? barTheme?.buttonMinWidth ?? 64.0f,
                height: buttonHeight ?? barTheme?.buttonHeight ?? 36.0f,
                padding: buttonPadding ?? barTheme?.buttonPadding ?? EdgeInsets.symmetric(horizontal: 8.0f),
                alignedDropdown: buttonAlignedDropdown ?? barTheme?.buttonAlignedDropdown ?? false,
                layoutBehavior: layoutBehavior ?? barTheme?.layoutBehavior ?? ButtonBarLayoutBehavior.padded
                );

            float  paddingUnit = buttonTheme.padding.horizontal / 4.0f;
            Widget child       = ButtonTheme.fromButtonThemeData(
                data: buttonTheme,
                child: new _ButtonBarRow(
                    mainAxisAlignment: alignment ?? barTheme?.alignment ?? MainAxisAlignment.end,
                    mainAxisSize: mainAxisSize ?? barTheme?.mainAxisSize ?? MainAxisSize.max,
                    overflowDirection: overflowDirection ?? barTheme?.overflowDirection ?? VerticalDirection.down,
                    children: LinqUtils <Widget> .SelectList(children, ((Widget childWidget) => {
                return((Widget) new Padding(
                           padding: EdgeInsets.symmetric(horizontal: paddingUnit),
                           child: childWidget
                           ));
            })),
                    overflowButtonSpacing: overflowButtonSpacing
                    )
                );

            switch (buttonTheme.layoutBehavior)
            {
            case ButtonBarLayoutBehavior.padded:
                return(new Padding(
                           padding: EdgeInsets.symmetric(
                               vertical: 2.0f * paddingUnit,
                               horizontal: paddingUnit
                               ),
                           child: child
                           ));

            case ButtonBarLayoutBehavior.constrained:
                return(new Container(
                           padding: EdgeInsets.symmetric(horizontal: paddingUnit),
                           constraints: new BoxConstraints(minHeight: 52.0f),
                           alignment: Alignment.center,
                           child: child
                           ));
            }

            D.assert(false);
            return(null);
        }
Пример #8
0
        public override Widget build(BuildContext context)
        {
            ButtonThemeData buttonTheme = ButtonTheme.of(context);
            double          paddingUnit = buttonTheme.padding.horizontal / 4.0;
            List <Widget>   _children   = new List <Widget>();

            foreach (Widget _child in this.children)
            {
                _children.Add(
                    new Padding(
                        padding: EdgeInsets.symmetric(horizontal: paddingUnit),
                        child: _child
                        )
                    );
            }

            Widget child = new Row(
                mainAxisAlignment: this.alignment,
                mainAxisSize: this.mainAxisSize,
                children: _children
                );

            switch (buttonTheme.layoutBehavior)
            {
            case ButtonBarLayoutBehavior.padded:
                return(new Padding(
                           padding: EdgeInsets.symmetric(
                               vertical: 2.0 * paddingUnit,
                               horizontal: paddingUnit
                               ),
                           child: child
                           ));

            case ButtonBarLayoutBehavior.constrained:
                return(new Container(
                           padding: EdgeInsets.symmetric(horizontal: paddingUnit),
                           constraints: new BoxConstraints(minHeight: 52.0),
                           alignment: Alignment.center,
                           child: child
                           ));
            }

            D.assert(false);
            return(null);
        }
Пример #9
0
        public static ButtonThemeData of(BuildContext context)
        {
            ButtonTheme     inheritedButtonTheme = (ButtonTheme)context.dependOnInheritedWidgetOfExactType <ButtonTheme>();
            ButtonThemeData buttonTheme          = inheritedButtonTheme?.data;

            if (buttonTheme?.colorScheme == null)
            {
                ThemeData theme = Theme.of(context);
                buttonTheme = buttonTheme ?? theme.buttonTheme;
                if (buttonTheme.colorScheme == null)
                {
                    buttonTheme = buttonTheme.copyWith(
                        colorScheme: theme.buttonTheme.colorScheme ?? theme.colorScheme);
                    D.assert(buttonTheme.colorScheme != null);
                }
            }

            return(buttonTheme);
        }
Пример #10
0
        public override Widget build(BuildContext context)
        {
            ButtonThemeData buttonTheme = ButtonTheme.of(context);

            return(new _OutlineButton(
                       onPressed: this.onPressed,
                       brightness: buttonTheme.getBrightness(this),
                       textTheme: this.textTheme,
                       textColor: buttonTheme.getTextColor(this),
                       disabledTextColor: buttonTheme.getDisabledTextColor(this),
                       color: this.color,
                       highlightColor: buttonTheme.getHighlightColor(this),
                       splashColor: buttonTheme.getSplashColor(this),
                       highlightElevation: buttonTheme.getHighlightElevation(this),
                       borderSide: this.borderSide,
                       disabledBorderColor: this.disabledBorderColor,
                       highlightedBorderColor: this.highlightedBorderColor ?? buttonTheme.colorScheme.primary,
                       padding: buttonTheme.getPadding(this),
                       shape: buttonTheme.getShape(this),
                       clipBehavior: this.clipBehavior,
                       child: this.child
                       ));
        }
Пример #11
0
        public override Widget build(BuildContext context)
        {
            ThemeData       theme       = Theme.of(context);
            ButtonThemeData buttonTheme = ButtonTheme.of(context);

            return(new RawMaterialButton(
                       onPressed: this.onPressed,
                       fillColor: this.color,
                       textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)),
                       highlightColor: this.highlightColor ?? theme.highlightColor,
                       splashColor: this.splashColor ?? theme.splashColor,
                       elevation: buttonTheme.getElevation(this),
                       highlightElevation: buttonTheme.getHighlightElevation(this),
                       padding: buttonTheme.getPadding(this),
                       constraints: buttonTheme.getConstraints(this).copyWith(
                           minWidth: this.minWidth,
                           minHeight: this.height),
                       shape: buttonTheme.shape,
                       clipBehavior: this.clipBehavior ?? Clip.none,
                       animationDuration: buttonTheme.getAnimationDuration(this),
                       child: this.child,
                       materialTapTargetSize: this.materialTapTargetSize ?? theme.materialTapTargetSize));
        }
Пример #12
0
        public override Widget build(BuildContext context)
        {
            ThemeData       theme       = Theme.of(context);
            ButtonThemeData buttonTheme = ButtonTheme.of(context);

            return(new RawMaterialButton(
                       onPressed: this.onPressed,
                       onHighlightChanged: this.onHighlightChanged,
                       clipBehavior: this.clipBehavior ?? Clip.none,
                       fillColor: buttonTheme.getFillColor(this),
                       textStyle: theme.textTheme.button.copyWith(color: buttonTheme.getTextColor(this)),
                       highlightColor: buttonTheme.getHighlightColor(this),
                       splashColor: buttonTheme.getSplashColor(this),
                       elevation: buttonTheme.getElevation(this),
                       highlightElevation: buttonTheme.getHighlightElevation(this),
                       disabledElevation: buttonTheme.getDisabledElevation(this),
                       padding: buttonTheme.getPadding(this),
                       constraints: buttonTheme.getConstraints(this),
                       shape: buttonTheme.getShape(this),
                       animationDuration: buttonTheme.getAnimationDuration(this),
                       materialTapTargetSize: buttonTheme.getMaterialTapTargetSize(this),
                       child: this.child
                       ));
        }
Пример #13
0
        public override Widget build(BuildContext context)
        {
            D.assert(material_.debugCheckHasMaterial(context));
            D.assert(material_.debugCheckHasMaterialLocalizations(context));
            Orientation?newOrientation = _getOrientation(context);

            _lastOrientation = _lastOrientation ?? newOrientation;
            if (newOrientation != _lastOrientation)
            {
                _removeDropdownRoute();
                _lastOrientation = newOrientation;
            }

            List <Widget> items = null;

            if (_enabled)
            {
                items = widget.selectedItemBuilder == null
                    ? new List <Widget>(widget.items)
                    : widget.selectedItemBuilder(context);
            }
            else
            {
                items = widget.selectedItemBuilder == null
                    ? new List <Widget>()
                    : widget.selectedItemBuilder(context);
            }

            int hintIndex = 0;

            if (widget.hint != null || (!_enabled && widget.disabledHint != null))
            {
                Widget displayedHint = _enabled ? widget.hint : widget.disabledHint ?? widget.hint;
                if (widget.selectedItemBuilder == null)
                {
                    displayedHint = new _DropdownMenuItemContainer(child: displayedHint);
                }

                hintIndex = items.Count;
                items.Add(new DefaultTextStyle(
                              style: _textStyle.copyWith(color: Theme.of(context).hintColor),
                              child: new IgnorePointer(
                                  child: displayedHint
                                  )
                              ));
            }

            EdgeInsetsGeometry padding = ButtonTheme.of(context).alignedDropdown
                ? material_._kAlignedButtonPadding
                : material_._kUnalignedButtonPadding;

            int    index            = _enabled ? (_selectedIndex ?? hintIndex) : hintIndex;
            Widget innerItemsWidget = null;

            if (items.isEmpty())
            {
                innerItemsWidget = new Container();
            }
            else
            {
                innerItemsWidget = new IndexedStack(
                    index: index,
                    alignment: AlignmentDirectional.centerStart,
                    children: widget.isDense
                        ? items
                        : LinqUtils <Widget> .SelectList(items, (Widget item) => {
                    return(widget.itemHeight != null
                                ? new SizedBox(height: widget.itemHeight, child: item)
                                : (Widget) new Column(mainAxisSize: MainAxisSize.min,
                                                      children: new List <Widget>()
                    {
                        item
                    }));
                }));
            }

            Icon   defaultIcon = new Icon(Icons.arrow_drop_down);
            Widget result      = new DefaultTextStyle(
                style: _textStyle,
                child: new Container(
                    decoration: _showHighlight ?? false
                        ? new BoxDecoration(
                        color: widget.focusColor ?? Theme.of(context).focusColor,
                        borderRadius: BorderRadius.all(Radius.circular(4.0f))
                        )
                        : null,
                    padding: padding,
                    height: widget.isDense ? _denseButtonHeight : null,
                    child: new Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        mainAxisSize: MainAxisSize.min,
                        children: new List <Widget> {
                widget.isExpanded ? new Expanded(child: innerItemsWidget) : (Widget)innerItemsWidget,
                new IconTheme(
                    data: new IconThemeData(
                        color: _iconColor,
                        size: widget.iconSize
                        ),
                    child: widget.icon ?? defaultIcon
                    )
            }
                        )
                    )
                );

            if (!DropdownButtonHideUnderline.at(context))
            {
                float bottom = widget.isDense || widget.itemHeight == null ? 0.0f : 8.0f;
                result = new Stack(
                    children: new List <Widget> {
                    result,
                    new Positioned(
                        left: 0.0f,
                        right: 0.0f,
                        bottom: bottom,
                        child: widget.underline ?? new Container(
                            height: 1.0f,
                            decoration: new BoxDecoration(
                                border: new Border(
                                    bottom: new BorderSide(color: new Color(0xFFBDBDBD), width: 0.0f))
                                )
                            )
                        )
                }
                    );
            }

            return(new Focus(
                       canRequestFocus: _enabled,
                       focusNode: focusNode,
                       autofocus: widget.autofocus,
                       child: new GestureDetector(
                           onTap: _enabled ? (GestureTapCallback)_handleTap : null,
                           behavior: HitTestBehavior.opaque,
                           child: result
                           )
                       ));
        }
Пример #14
0
        public override Widget build(BuildContext context)
        {
            ThemeData theme  = Theme.of(context);
            Widget    picker = new Flexible(
                child: new SizedBox(
                    height: DatePickerUtils._kMaxDayPickerHeight,
                    child: this._buildPicker()
                    )
                );
            Widget actions = ButtonTheme.bar(
                child: new ButtonBar(
                    children: new List <Widget> {
                new FlatButton(
                    child: new Text(this.localizations.cancelButtonLabel),
                    onPressed: this._handleCancel
                    ),
                new FlatButton(
                    child: new Text(this.localizations.okButtonLabel),
                    onPressed: this._handleOk
                    )
            }
                    )
                );
            Dialog dialog = new Dialog(
                child: new OrientationBuilder(
                    builder: (BuildContext _context, Orientation orientation) => {
                Widget header = new _DatePickerHeader(
                    selectedDate: this._selectedDate,
                    mode: this._mode,
                    onModeChanged: this._handleModeChanged,
                    orientation: orientation
                    );

                switch (orientation)
                {
                case Orientation.portrait:
                    return(new SizedBox(
                               width: DatePickerUtils._kMonthPickerPortraitWidth,
                               child: new Column(
                                   mainAxisSize: MainAxisSize.min,
                                   crossAxisAlignment: CrossAxisAlignment.stretch,
                                   children: new List <Widget> {
                        header,
                        new Container(
                            color: theme.dialogBackgroundColor,
                            child: new Column(
                                mainAxisSize: MainAxisSize.min,
                                crossAxisAlignment: CrossAxisAlignment.stretch,
                                children: new List <Widget> {
                            picker,
                            actions,
                        }
                                )
                            )
                    }
                                   )
                               ));

                case Orientation.landscape:
                    return(new SizedBox(
                               height: DatePickerUtils._kDatePickerLandscapeHeight,
                               child: new Row(
                                   mainAxisSize: MainAxisSize.min,
                                   crossAxisAlignment: CrossAxisAlignment.stretch,
                                   children: new List <Widget> {
                        header,
                        new Flexible(
                            child: new Container(
                                width: DatePickerUtils._kMonthPickerLandscapeWidth,
                                color: theme.dialogBackgroundColor,
                                child: new Column(
                                    mainAxisSize: MainAxisSize.min,
                                    crossAxisAlignment: CrossAxisAlignment.stretch,
                                    children: new List <Widget> {
                            picker, actions
                        }
                                    )
                                )
                            )
                    }
                                   )
                               ));
                }

                return(null);
            }
                    )
                );

            return(new Theme(
                       data: theme.copyWith(
                           dialogBackgroundColor: Colors.transparent
                           ),
                       child: dialog
                       ));
        }
Пример #15
0
        public override Widget build(BuildContext context)
        {
            D.assert(MaterialD.debugCheckHasMaterial(context));
            D.assert(MaterialD.debugCheckHasMaterialLocalizations(context));

            List <Widget> items     = this._enabled ? new List <Widget>(this.widget.items) : new List <Widget>();
            int           hintIndex = 0;

            if (this.widget.hint != null || (!this._enabled && this.widget.disabledHint != null))
            {
                Widget emplacedHint =
                    this._enabled
                        ? this.widget.hint
                        : new DropdownMenuItem <Widget>(child: this.widget.disabledHint ?? this.widget.hint);
                hintIndex = items.Count;
                items.Add(new DefaultTextStyle(
                              style: this._textStyle.copyWith(color: Theme.of(context).hintColor),
                              child: new IgnorePointer(
                                  child: emplacedHint
                                  )
                              ));
            }

            EdgeInsets padding = ButtonTheme.of(context).alignedDropdown
                ? DropdownConstants._kAlignedButtonPadding
                : DropdownConstants._kUnalignedButtonPadding;

            IndexedStack innerItemsWidget = new IndexedStack(
                index: this._enabled ? (this._selectedIndex ?? hintIndex) : hintIndex,
                alignment: Alignment.centerLeft,
                children: items
                );

            Widget result = new DefaultTextStyle(
                style: this._textStyle,
                child: new Container(
                    padding: padding,
                    height: this.widget.isDense ? this._denseButtonHeight : null,
                    child: new Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        mainAxisSize: MainAxisSize.min,
                        children: new List <Widget> {
                this.widget.isExpanded ? new Expanded(child: innerItemsWidget) : (Widget)innerItemsWidget,
                new Icon(Icons.arrow_drop_down,
                         size: this.widget.iconSize,
                         color: this._downArrowColor
                         )
            }
                        )
                    )
                );

            if (!DropdownButtonHideUnderline.at(context))
            {
                float bottom = this.widget.isDense ? 0.0f : 8.0f;
                result = new Stack(
                    children: new List <Widget> {
                    result,
                    new Positioned(
                        left: 0.0f,
                        right: 0.0f,
                        bottom: bottom,
                        child: new Container(
                            height: 1.0f,
                            decoration: new BoxDecoration(
                                border: new Border(
                                    bottom: new BorderSide(color: new Color(0xFFBDBDBD), width: 0.0f))
                                )
                            )
                        )
                }
                    );
            }

            return(new GestureDetector(
                       onTap: this._enabled ? (GestureTapCallback)this._handleTap : null,
                       behavior: HitTestBehavior.opaque,
                       child: result
                       ));
        }
Пример #16
0
        public override Widget build(BuildContext context)
        {
            MediaQueryData mediaQueryData = MediaQuery.of(context);

            D.assert(this.animation != null);

            ThemeData theme     = Theme.of(context);
            ThemeData darkTheme = new ThemeData(
                brightness: Brightness.dark,
                accentColor: theme.accentColor,
                accentColorBrightness: theme.accentColorBrightness
                );

            List <Widget> children = new List <Widget> {
                new SizedBox(width: SnackBarUtils._kSnackBarPadding),
                new Expanded(
                    child: new Container(
                        padding: EdgeInsets.symmetric(vertical: SnackBarUtils._kSingleLineVerticalPadding),
                        child: new DefaultTextStyle(
                            style: darkTheme.textTheme.subhead,
                            child: this.content)
                        )
                    )
            };

            if (this.action != null)
            {
                children.Add(ButtonTheme.bar(
                                 padding: EdgeInsets.symmetric(horizontal: SnackBarUtils._kSnackBarPadding),
                                 textTheme: ButtonTextTheme.accent,
                                 child: this.action
                                 ));
            }
            else
            {
                children.Add(new SizedBox(width: SnackBarUtils._kSnackBarPadding));
            }

            CurvedAnimation heightAnimation =
                new CurvedAnimation(parent: this.animation, curve: SnackBarUtils._snackBarHeightCurve);
            CurvedAnimation fadeAnimation = new CurvedAnimation(parent: this.animation,
                                                                curve: SnackBarUtils._snackBarFadeCurve, reverseCurve: new Threshold(0.0f));
            Widget snackbar = new SafeArea(
                top: false,
                child: new Row(
                    children: children,
                    crossAxisAlignment: CrossAxisAlignment.center
                    )
                );

            snackbar = new Dismissible(
                key: Key.key("dismissible"),
                direction: DismissDirection.down,
                resizeDuration: null,
                onDismissed: (DismissDirection? direction) => {
                Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.swipe);
            },
                child: new Material(
                    elevation: 6.0f,
                    color: this.backgroundColor ?? SnackBarUtils._kSnackBackground,
                    child: new Theme(
                        data: darkTheme,
                        child: mediaQueryData.accessibleNavigation
                            ? snackbar
                            : new FadeTransition(
                            opacity: fadeAnimation,
                            child: snackbar
                            )
                        )
                    )
                );

            return(new ClipRect(
                       child: mediaQueryData.accessibleNavigation
                    ? snackbar
                    : new AnimatedBuilder(
                           animation: heightAnimation,
                           builder: (BuildContext subContext, Widget child) => {
                return new Align(
                    alignment: Alignment.topLeft,
                    heightFactor: heightAnimation.value,
                    child: child
                    );
            },
                           child: snackbar
                           )
                       ));
        }