|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public class FloatingActionButton : StatefulWidget { |
|
|
|
public class FloatingActionButton : StatelessWidget { |
|
|
|
FloatingActionButton( |
|
|
|
Key key = null, |
|
|
|
Widget child = null, |
|
|
|
|
|
|
object heroTag = null, |
|
|
|
float elevation = 6.0f, |
|
|
|
float highlightElevation = 12.0f, |
|
|
|
float? disabledElevation = null, |
|
|
|
VoidCallback onPressed = null, |
|
|
|
bool mini = false, |
|
|
|
ShapeBorder shape = null, |
|
|
|
|
|
|
BoxConstraints _sizeConstraints = null |
|
|
|
) : base(key: key) { |
|
|
|
D.assert(elevation >= 0.0f); |
|
|
|
D.assert(highlightElevation >= 0.0f); |
|
|
|
D.assert(disabledElevation == null || disabledElevation >= 0.0f); |
|
|
|
heroTag = heroTag ?? new _DefaultHeroTag(); |
|
|
|
shape = shape ?? new CircleBorder(); |
|
|
|
this.child = child; |
|
|
|
|
|
|
this.clipBehavior = clipBehavior; |
|
|
|
this.materialTapTargetSize = materialTapTargetSize; |
|
|
|
this.isExtended = isExtended; |
|
|
|
this._sizeConstraints = _sizeConstraints ?? |
|
|
|
(mini |
|
|
|
this.disabledElevation = disabledElevation; |
|
|
|
this._sizeConstraints = _sizeConstraints ?? (mini |
|
|
|
? FloatActionButtonUtils._kMiniSizeConstraints |
|
|
|
: FloatActionButtonUtils._kSizeConstraints); |
|
|
|
} |
|
|
|
|
|
|
object heroTag = null, |
|
|
|
float elevation = 6.0f, |
|
|
|
float highlightElevation = 12.0f, |
|
|
|
float? disabledElevation = null, |
|
|
|
VoidCallback onPressed = null, |
|
|
|
ShapeBorder shape = null, |
|
|
|
bool isExtended = true, |
|
|
|
|
|
|
Widget label = null |
|
|
|
) { |
|
|
|
D.assert(elevation >= 0.0f); |
|
|
|
D.assert(highlightElevation >= 0.0f); |
|
|
|
D.assert(disabledElevation != null && disabledElevation >= 0.0f); |
|
|
|
D.assert(icon != null); |
|
|
|
D.assert(label != null); |
|
|
|
D.assert(icon != null); |
|
|
|
D.assert(label != null); |
|
|
|
|
|
|
|
BoxConstraints _sizeConstraints = FloatActionButtonUtils._kExtendedSizeConstraints; |
|
|
|
bool mini = false; |
|
|
|
|
|
|
heroTag: heroTag, |
|
|
|
elevation: elevation, |
|
|
|
highlightElevation: highlightElevation, |
|
|
|
disabledElevation: disabledElevation ?? elevation, |
|
|
|
onPressed: onPressed, |
|
|
|
mini: mini, |
|
|
|
shape: shape, |
|
|
|
|
|
|
|
|
|
|
public readonly float highlightElevation; |
|
|
|
|
|
|
|
public readonly float? disabledElevation; |
|
|
|
|
|
|
|
public readonly bool mini; |
|
|
|
|
|
|
|
public readonly ShapeBorder shape; |
|
|
|
|
|
|
|
|
|
|
public readonly BoxConstraints _sizeConstraints; |
|
|
|
|
|
|
|
public override State createState() { |
|
|
|
return new _FloatingActionButtonState(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public class _FloatingActionButtonState : State<FloatingActionButton> { |
|
|
|
bool _highlight = false; |
|
|
|
|
|
|
|
void _handleHighlightChanged(bool value) { |
|
|
|
this.setState(() => { this._highlight = value; }); |
|
|
|
} |
|
|
|
|
|
|
|
Color foregroundColor = this.widget.foregroundColor ?? theme.accentIconTheme.color; |
|
|
|
Color foregroundColor = this.foregroundColor ?? theme.accentIconTheme.color; |
|
|
|
if (this.widget.child != null) { |
|
|
|
if (this.child != null) { |
|
|
|
child: this.widget.child |
|
|
|
child: this.child |
|
|
|
onPressed: this.widget.onPressed, |
|
|
|
onHighlightChanged: this._handleHighlightChanged, |
|
|
|
elevation: this._highlight ? this.widget.highlightElevation : this.widget.elevation, |
|
|
|
constraints: this.widget._sizeConstraints, |
|
|
|
materialTapTargetSize: this.widget.materialTapTargetSize ?? theme.materialTapTargetSize, |
|
|
|
fillColor: this.widget.backgroundColor ?? theme.accentColor, |
|
|
|
onPressed: this.onPressed, |
|
|
|
elevation: this.elevation, |
|
|
|
highlightElevation: this.highlightElevation, |
|
|
|
disabledElevation: this.disabledElevation ?? this.elevation, |
|
|
|
constraints: this._sizeConstraints, |
|
|
|
materialTapTargetSize: this.materialTapTargetSize ?? theme.materialTapTargetSize, |
|
|
|
fillColor: this.backgroundColor ?? theme.accentColor, |
|
|
|
shape: this.widget.shape, |
|
|
|
clipBehavior: this.widget.clipBehavior, |
|
|
|
shape: this.shape, |
|
|
|
clipBehavior: this.clipBehavior, |
|
|
|
if (this.widget.tooltip != null) { |
|
|
|
if (this.tooltip != null) { |
|
|
|
message: this.widget.tooltip, |
|
|
|
message: this.tooltip, |
|
|
|
//todo: xingwei.zhu: Hero widget
|
|
|
|
// if (this.widget.heroTag != null) {
|
|
|
|
// result = new Hero(
|
|
|
|
// tag: this.widget.heroTag,
|
|
|
|
// child: result);
|
|
|
|
// }
|
|
|
|
if (this.heroTag != null) { |
|
|
|
result = new Hero( |
|
|
|
tag: this.heroTag, |
|
|
|
child: result); |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|