public override void debugFillProperties(DiagnosticPropertiesBuilder properties)
        {
            base.debugFillProperties(properties);
            FloatingActionButtonThemeData defaultData = new FloatingActionButtonThemeData();

            properties.add(new DiagnosticsProperty <Color>("backgroundColor", this.backgroundColor,
                                                           defaultValue: defaultData.backgroundColor));
            properties.add(new DiagnosticsProperty <Color>("foregroundColor", this.foregroundColor,
                                                           defaultValue: defaultData.foregroundColor));
            properties.add(new DiagnosticsProperty <float?>("elevation", this.elevation,
                                                            defaultValue: defaultData.elevation));
            properties.add(new DiagnosticsProperty <float?>("disabledElevation", this.disabledElevation,
                                                            defaultValue: defaultData.disabledElevation));
            properties.add(new DiagnosticsProperty <float?>("highlightElevation", this.highlightElevation,
                                                            defaultValue: defaultData.highlightElevation));
            properties.add(new DiagnosticsProperty <ShapeBorder>("shape", this.shape, defaultValue: defaultData.shape));
        }
        public static FloatingActionButtonThemeData lerp(FloatingActionButtonThemeData a, FloatingActionButtonThemeData b,
                                                         float t)
        {
            if (a == null && b == null)
            {
                return(null);
            }

            return(new FloatingActionButtonThemeData(
                       backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
                       foregroundColor: Color.lerp(a?.foregroundColor, b?.foregroundColor, t),
                       elevation: MathUtils.lerpFloat(a?.elevation ?? 0, b?.elevation ?? 0, t),
                       disabledElevation: MathUtils.lerpFloat(a?.disabledElevation ?? 0, b?.disabledElevation ?? 0, t),
                       highlightElevation: MathUtils.lerpFloat(a?.highlightElevation ?? 0, b?.highlightElevation ?? 0, t),
                       shape: ShapeBorder.lerp(a?.shape, b?.shape, t)
                       ));
        }
        public bool Equals(FloatingActionButtonThemeData other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(Equals(this.backgroundColor, other.backgroundColor) &&
                   Equals(this.elevation, other.elevation) &&
                   Equals(this.shape, other.shape) &&
                   Equals(this.foregroundColor, other.foregroundColor) &&
                   Equals(this.disabledElevation, other.disabledElevation) &&
                   Equals(this.highlightElevation, other.highlightElevation));
        }
Beispiel #4
0
        public override Widget build(BuildContext context)
        {
            ThemeData theme = Theme.of(context);
            FloatingActionButtonThemeData floatingActionButtonTheme = theme.floatingActionButtonTheme;

            if (this.foregroundColor == null && floatingActionButtonTheme.foregroundColor == null)
            {
                bool  accentIsDark = theme.accentColorBrightness == Brightness.dark;
                Color defaultAccentIconThemeColor = accentIsDark ? Colors.white : Colors.black;
                if (theme.accentIconTheme.color != defaultAccentIconThemeColor)
                {
                    Debug.Log(
                        "Warning: " +
                        "The support for configuring the foreground color of " +
                        "FloatingActionButtons using ThemeData.accentIconTheme " +
                        "has been deprecated. Please use ThemeData.floatingActionButtonTheme " +
                        "instead. "
                        );
                }
            }


            Color foregroundColor = this.foregroundColor
                                    ?? floatingActionButtonTheme.foregroundColor
                                    ?? theme.colorScheme.onSecondary;
            Color backgroundColor = this.backgroundColor
                                    ?? floatingActionButtonTheme.backgroundColor
                                    ?? theme.colorScheme.secondary;
            float elevation = this.elevation
                              ?? floatingActionButtonTheme.elevation
                              ?? _defaultElevation;
            Color focusColor = this.focusColor
                               ?? floatingActionButtonTheme.focusColor
                               ?? theme.focusColor;
            Color hoverColor = this.hoverColor
                               ?? floatingActionButtonTheme.hoverColor
                               ?? theme.hoverColor;
            Color splashColor = this.splashColor
                                ?? floatingActionButtonTheme.splashColor
                                ?? theme.splashColor;
            float disabledElevation = this.disabledElevation
                                      ?? floatingActionButtonTheme.disabledElevation
                                      ?? elevation;
            float focusElevation = this.focusElevation
                                   ?? floatingActionButtonTheme.focusElevation
                                   ?? _defaultFocusElevation;
            float hoverElevation = this.hoverElevation
                                   ?? floatingActionButtonTheme.hoverElevation
                                   ?? _defaultHoverElevation;
            float highlightElevation = this.highlightElevation
                                       ?? floatingActionButtonTheme.highlightElevation
                                       ?? _defaultHighlightElevation;
            MaterialTapTargetSize materialTapTargetSize = this.materialTapTargetSize
                                                          ?? theme.materialTapTargetSize;
            TextStyle textStyle = theme.textTheme.button.copyWith(
                color: foregroundColor,
                letterSpacing: 1.2f
                );
            ShapeBorder shape = this.shape
                                ?? floatingActionButtonTheme.shape
                                ?? (isExtended ? _defaultExtendedShape : _defaultShape);

            Widget result = new RawMaterialButton(
                onPressed: onPressed,
                elevation: elevation,
                focusElevation: focusElevation,
                hoverElevation: hoverElevation,
                highlightElevation: highlightElevation,
                disabledElevation: disabledElevation,
                constraints: _sizeConstraints,
                materialTapTargetSize: materialTapTargetSize,
                fillColor: backgroundColor,
                focusColor: focusColor,
                hoverColor: hoverColor,
                splashColor: splashColor,
                textStyle: textStyle,
                shape: shape,
                clipBehavior: clipBehavior,
                focusNode: focusNode,
                autofocus: autofocus,
                child: child
                );

            if (tooltip != null)
            {
                result = new Tooltip(
                    message: tooltip,
                    child: result
                    );
            }

            if (heroTag != null)
            {
                result = new Hero(
                    tag: heroTag,
                    child: result
                    );
            }

            return(result);
        }
        public override Widget build(BuildContext context)
        {
            ThemeData theme = Theme.of(context);
            FloatingActionButtonThemeData floatingActionButtonTheme = theme.floatingActionButtonTheme;
            Color backgroundColor = this.backgroundColor
                                    ?? floatingActionButtonTheme.backgroundColor
                                    ?? theme.colorScheme.secondary;
            Color foregroundColor = this.foregroundColor
                                    ?? floatingActionButtonTheme.foregroundColor
                                    ?? theme.accentIconTheme.color
                                    ?? theme.colorScheme.onSecondary;

            float elevation = this.elevation
                              ?? floatingActionButtonTheme.elevation
                              ?? _defaultElevation;
            float disabledElevation = this.disabledElevation
                                      ?? floatingActionButtonTheme.disabledElevation
                                      ?? elevation;
            float highlightElevation = this.highlightElevation
                                       ?? floatingActionButtonTheme.highlightElevation
                                       ?? _defaultHighlightElevation;
            MaterialTapTargetSize materialTapTargetSize = this.materialTapTargetSize
                                                          ?? theme.materialTapTargetSize;
            TextStyle textStyle = theme.accentTextTheme.button.copyWith(
                color: foregroundColor,
                letterSpacing: 1.2f
                );
            ShapeBorder shape = this.shape
                                ?? floatingActionButtonTheme.shape
                                ?? (this.isExtended ? this._defaultExtendedShape : this._defaultShape);

            Widget result = null;

            if (this.child != null)
            {
                result = IconTheme.merge(
                    data: new IconThemeData(
                        color: foregroundColor),
                    child: this.child
                    );
            }

            result = new RawMaterialButton(
                onPressed: this.onPressed,
                elevation: elevation,
                highlightElevation: highlightElevation,
                disabledElevation: disabledElevation,
                constraints: this._sizeConstraints,
                materialTapTargetSize: materialTapTargetSize,
                fillColor: backgroundColor,
                textStyle: textStyle,
                shape: shape,
                clipBehavior: this.clipBehavior,
                child: result);

            if (this.tooltip != null)
            {
                result = new Tooltip(
                    message: this.tooltip,
                    child: result);
            }

            if (this.heroTag != null)
            {
                result = new Hero(
                    tag: this.heroTag,
                    child: result);
            }

            return(result);
        }