GitHub
5 年前
当前提交
7b90a814
共有 47 个文件被更改,包括 2272 次插入 和 925 次删除
-
36Runtime/gestures/converter.cs
-
755Runtime/gestures/events.cs
-
8Runtime/gestures/mouse_tracking.cs
-
2Runtime/material/app.cs
-
39Runtime/material/app_bar.cs
-
10Runtime/material/app_bar_theme.cs
-
407Runtime/material/bottom_navigation_bar.cs
-
2Runtime/material/button_theme.cs
-
106Runtime/material/chip.cs
-
22Runtime/material/chip_theme.cs
-
2Runtime/material/dialog.cs
-
3Runtime/material/drawer.cs
-
131Runtime/material/dropdown.cs
-
32Runtime/material/expansion_panel.cs
-
4Runtime/material/ink_well.cs
-
4Runtime/material/input_border.cs
-
279Runtime/material/input_decorator.cs
-
16Runtime/material/list_tile.cs
-
6Runtime/material/material.cs
-
4Runtime/material/material_button.cs
-
1Runtime/material/popup_menu.cs
-
16Runtime/material/progress_indicator.cs
-
3Runtime/material/radio.cs
-
113Runtime/material/scaffold.cs
-
10Runtime/material/slider.cs
-
4Runtime/material/switch.cs
-
9Runtime/material/tab_bar_theme.cs
-
41Runtime/material/tabs.cs
-
75Runtime/material/text_field.cs
-
12Runtime/material/text_form_field.cs
-
16Runtime/material/theme_data.cs
-
7Runtime/material/user_accounts_drawer_header.cs
-
2Runtime/material/floating_action_button_location.cs.meta
-
2Runtime/material/floating_action_button.cs.meta
-
2Runtime/painting/continuous_rectangle_border.cs
-
4Runtime/painting/text_painter.cs
-
2Runtime/rendering/editable.cs
-
87Runtime/ui/pointer.cs
-
174Runtime/widgets/editable_text.cs
-
14Runtime/widgets/scrollable.cs
-
314Runtime/material/floating_action_button.cs
-
130Runtime/material/floatting_action_button_theme.cs
-
11Runtime/material/floatting_action_button_theme.cs.meta
-
280Runtime/material/float_action_button.cs
-
0/Runtime/material/floating_action_button_location.cs.meta
-
0/Runtime/material/floating_action_button_location.cs
-
0/Runtime/material/floating_action_button.cs.meta
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
using TextStyle = Unity.UIWidgets.painting.TextStyle; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class FloatActionButtonUtils { |
|||
public static readonly BoxConstraints _kSizeConstraints = BoxConstraints.tightFor(width: 56.0f, height: 56.0f); |
|||
|
|||
public static readonly BoxConstraints _kMiniSizeConstraints = |
|||
BoxConstraints.tightFor(width: 40.0f, height: 40.0f); |
|||
|
|||
public static readonly BoxConstraints _kExtendedSizeConstraints = |
|||
new BoxConstraints(minHeight: 48.0f, maxHeight: 48.0f); |
|||
} |
|||
|
|||
|
|||
class _DefaultHeroTag { |
|||
public _DefaultHeroTag() { |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return "<default FloatingActionButton tag>"; |
|||
} |
|||
} |
|||
|
|||
public class FloatingActionButton : StatelessWidget { |
|||
FloatingActionButton( |
|||
Key key = null, |
|||
Widget child = null, |
|||
string tooltip = null, |
|||
Color foregroundColor = null, |
|||
Color backgroundColor = null, |
|||
object heroTag = null, |
|||
float? elevation = null, |
|||
float? highlightElevation = null, |
|||
float? disabledElevation = null, |
|||
VoidCallback onPressed = null, |
|||
bool mini = false, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
bool isExtended = false, |
|||
BoxConstraints _sizeConstraints = null |
|||
) : base(key: key) { |
|||
D.assert(elevation == null || elevation >= 0.0f); |
|||
D.assert(highlightElevation == null || highlightElevation >= 0.0f); |
|||
D.assert(disabledElevation == null || disabledElevation >= 0.0f); |
|||
heroTag = heroTag ?? new _DefaultHeroTag(); |
|||
this.child = child; |
|||
this.tooltip = tooltip; |
|||
this.foregroundColor = foregroundColor; |
|||
this.backgroundColor = backgroundColor; |
|||
this.heroTag = heroTag; |
|||
this.elevation = elevation; |
|||
this.highlightElevation = highlightElevation; |
|||
this.onPressed = onPressed; |
|||
this.mini = mini; |
|||
this.shape = shape; |
|||
this.clipBehavior = clipBehavior; |
|||
this.materialTapTargetSize = materialTapTargetSize; |
|||
this.isExtended = isExtended; |
|||
this.disabledElevation = disabledElevation; |
|||
this._sizeConstraints = _sizeConstraints ?? (mini |
|||
? FloatActionButtonUtils._kMiniSizeConstraints |
|||
: FloatActionButtonUtils._kSizeConstraints); |
|||
} |
|||
|
|||
public FloatingActionButton( |
|||
Key key = null, |
|||
Widget child = null, |
|||
string tooltip = null, |
|||
Color foregroundColor = null, |
|||
Color backgroundColor = null, |
|||
object heroTag = null, |
|||
float elevation = 6.0f, |
|||
float highlightElevation = 12.0f, |
|||
VoidCallback onPressed = null, |
|||
bool mini = false, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
bool isExtended = false |
|||
) : this(key: key, |
|||
child: child, |
|||
tooltip: tooltip, |
|||
foregroundColor: foregroundColor, |
|||
backgroundColor: backgroundColor, |
|||
heroTag: heroTag, |
|||
elevation: elevation, |
|||
highlightElevation: highlightElevation, |
|||
onPressed: onPressed, |
|||
mini: mini, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
isExtended: isExtended, |
|||
_sizeConstraints: null) { |
|||
} |
|||
|
|||
public static FloatingActionButton extended( |
|||
Key key = null, |
|||
string tooltip = null, |
|||
Color foregroundColor = null, |
|||
Color backgroundColor = null, |
|||
object heroTag = null, |
|||
float? elevation = null, |
|||
float? highlightElevation = null, |
|||
float? disabledElevation = null, |
|||
VoidCallback onPressed = null, |
|||
ShapeBorder shape = null, |
|||
bool isExtended = true, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Clip clipBehavior = Clip.none, |
|||
Widget icon = null, |
|||
Widget label = null |
|||
) { |
|||
D.assert(elevation == null || elevation >= 0.0f); |
|||
D.assert(highlightElevation == null || highlightElevation >= 0.0f); |
|||
D.assert(disabledElevation == null || disabledElevation >= 0.0f); |
|||
D.assert(label != null); |
|||
heroTag = heroTag ?? new _DefaultHeroTag(); |
|||
|
|||
BoxConstraints _sizeConstraints = FloatActionButtonUtils._kExtendedSizeConstraints; |
|||
bool mini = false; |
|||
Widget child = new _ChildOverflowBox( |
|||
child: new Row( |
|||
mainAxisSize: MainAxisSize.min, |
|||
children: icon == null |
|||
? new List<Widget> { |
|||
new SizedBox(width: 20.0f), |
|||
label, |
|||
new SizedBox(width: 20.0f), |
|||
} |
|||
: new List<Widget> { |
|||
new SizedBox(width: 16.0f), |
|||
icon, |
|||
new SizedBox(width: 8.0f), |
|||
label, |
|||
new SizedBox(width: 20.0f) |
|||
})); |
|||
|
|||
return new FloatingActionButton( |
|||
key: key, |
|||
child: child, |
|||
tooltip: tooltip, |
|||
foregroundColor: foregroundColor, |
|||
backgroundColor: backgroundColor, |
|||
heroTag: heroTag, |
|||
elevation: elevation, |
|||
highlightElevation: highlightElevation, |
|||
disabledElevation: disabledElevation, |
|||
onPressed: onPressed, |
|||
mini: mini, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
isExtended: isExtended, |
|||
_sizeConstraints: _sizeConstraints |
|||
); |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly string tooltip; |
|||
|
|||
public readonly Color foregroundColor; |
|||
|
|||
public readonly Color backgroundColor; |
|||
|
|||
public readonly object heroTag; |
|||
|
|||
public readonly VoidCallback onPressed; |
|||
|
|||
public readonly float? elevation; |
|||
|
|||
public readonly float? highlightElevation; |
|||
|
|||
public readonly float? disabledElevation; |
|||
|
|||
public readonly bool mini; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public readonly Clip clipBehavior; |
|||
|
|||
public readonly bool isExtended; |
|||
|
|||
public readonly MaterialTapTargetSize? materialTapTargetSize; |
|||
|
|||
readonly BoxConstraints _sizeConstraints; |
|||
|
|||
const float _defaultElevation = 6; |
|||
const float _defaultHighlightElevation = 12; |
|||
readonly ShapeBorder _defaultShape = new CircleBorder(); |
|||
readonly ShapeBorder _defaultExtendedShape = new StadiumBorder(); |
|||
|
|||
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; |
|||
} |
|||
} |
|||
|
|||
class _ChildOverflowBox : SingleChildRenderObjectWidget { |
|||
public _ChildOverflowBox( |
|||
Key key = null, |
|||
Widget child = null) : base(key: key, child: child) { |
|||
} |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new _RenderChildOverflowBox(); |
|||
} |
|||
|
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
} |
|||
} |
|||
|
|||
|
|||
class _RenderChildOverflowBox : RenderAligningShiftedBox { |
|||
public _RenderChildOverflowBox( |
|||
RenderBox child = null) : base(child: child, alignment: Alignment.center) { |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicWidth(float height) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicHeight(float width) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
if (this.child != null) { |
|||
this.child.layout(new BoxConstraints(), parentUsesSize: true); |
|||
this.size = new Size( |
|||
Mathf.Max(this.constraints.minWidth, Mathf.Min(this.constraints.maxWidth, this.child.size.width)), |
|||
Mathf.Max(this.constraints.minHeight, Mathf.Min(this.constraints.maxHeight, this.child.size.height)) |
|||
); |
|||
this.alignChild(); |
|||
} |
|||
else { |
|||
this.size = this.constraints.biggest; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.ui; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
public class FloatingActionButtonThemeData : Diagnosticable { |
|||
public FloatingActionButtonThemeData( |
|||
Color backgroundColor = null, |
|||
Color foregroundColor = null, |
|||
float? elevation = null, |
|||
float? disabledElevation = null, |
|||
float? highlightElevation = null, |
|||
ShapeBorder shape = null |
|||
) { |
|||
this.backgroundColor = backgroundColor; |
|||
this.foregroundColor = foregroundColor; |
|||
this.elevation = elevation; |
|||
this.disabledElevation = disabledElevation; |
|||
this.highlightElevation = highlightElevation; |
|||
this.shape = shape; |
|||
} |
|||
|
|||
public readonly Color backgroundColor; |
|||
|
|||
public readonly Color foregroundColor; |
|||
|
|||
public readonly float? elevation; |
|||
|
|||
public readonly float? disabledElevation; |
|||
|
|||
public readonly float? highlightElevation; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public FloatingActionButtonThemeData copyWith( |
|||
Color backgroundColor, |
|||
Color foregroundColor, |
|||
float? elevation, |
|||
float? disabledElevation, |
|||
float? highlightElevation, |
|||
ShapeBorder shape |
|||
) { |
|||
return new FloatingActionButtonThemeData( |
|||
backgroundColor: backgroundColor ?? this.backgroundColor, |
|||
foregroundColor: foregroundColor ?? this.foregroundColor, |
|||
elevation: elevation ?? this.elevation, |
|||
disabledElevation: disabledElevation ?? this.disabledElevation, |
|||
highlightElevation: highlightElevation ?? this.highlightElevation, |
|||
shape: shape ?? this.shape |
|||
); |
|||
} |
|||
|
|||
public static FloatingActionButtonThemeData lerp(FloatingActionButtonThemeData a, FloatingActionButtonThemeData b, |
|||
float t) { |
|||
D.assert(t != null); |
|||
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 override int GetHashCode() { |
|||
var hashCode = this.backgroundColor?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ this.foregroundColor?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ this.elevation?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ this.disabledElevation?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ this.highlightElevation?.GetHashCode() ?? 0; |
|||
hashCode = (hashCode * 397) ^ this.shape?.GetHashCode() ?? 0; |
|||
return hashCode; |
|||
} |
|||
|
|||
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); |
|||
} |
|||
|
|||
public override bool Equals(object obj) { |
|||
if (ReferenceEquals(null, obj)) { |
|||
return false; |
|||
} |
|||
|
|||
if (ReferenceEquals(this, obj)) { |
|||
return true; |
|||
} |
|||
|
|||
if (obj.GetType() != this.GetType()) { |
|||
return false; |
|||
} |
|||
|
|||
return this.Equals((FloatingActionButtonThemeData) obj); |
|||
} |
|||
|
|||
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)); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f2f4277e1c02b5b4281b4fc2b7ac3e21 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using Unity.UIWidgets.foundation; |
|||
using Unity.UIWidgets.painting; |
|||
using Unity.UIWidgets.rendering; |
|||
using Unity.UIWidgets.ui; |
|||
using Unity.UIWidgets.widgets; |
|||
using UnityEngine; |
|||
using Color = Unity.UIWidgets.ui.Color; |
|||
|
|||
namespace Unity.UIWidgets.material { |
|||
static class FloatActionButtonUtils { |
|||
public static readonly BoxConstraints _kSizeConstraints = BoxConstraints.tightFor(width: 56.0f, height: 56.0f); |
|||
|
|||
public static readonly BoxConstraints _kMiniSizeConstraints = |
|||
BoxConstraints.tightFor(width: 40.0f, height: 40.0f); |
|||
|
|||
public static readonly BoxConstraints _kExtendedSizeConstraints = |
|||
new BoxConstraints(minHeight: 48.0f, maxHeight: 48.0f); |
|||
} |
|||
|
|||
|
|||
class _DefaultHeroTag { |
|||
public _DefaultHeroTag() { |
|||
} |
|||
|
|||
public override string ToString() { |
|||
return "<default FloatingActionButton tag>"; |
|||
} |
|||
} |
|||
|
|||
public class FloatingActionButton : StatelessWidget { |
|||
FloatingActionButton( |
|||
Key key = null, |
|||
Widget child = null, |
|||
string tooltip = null, |
|||
Color foregroundColor = null, |
|||
Color backgroundColor = null, |
|||
object heroTag = null, |
|||
float elevation = 6.0f, |
|||
float highlightElevation = 12.0f, |
|||
float? disabledElevation = null, |
|||
VoidCallback onPressed = null, |
|||
bool mini = false, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
bool isExtended = false, |
|||
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.tooltip = tooltip; |
|||
this.foregroundColor = foregroundColor; |
|||
this.backgroundColor = backgroundColor; |
|||
this.heroTag = heroTag; |
|||
this.elevation = elevation; |
|||
this.highlightElevation = highlightElevation; |
|||
this.onPressed = onPressed; |
|||
this.mini = mini; |
|||
this.shape = shape; |
|||
this.clipBehavior = clipBehavior; |
|||
this.materialTapTargetSize = materialTapTargetSize; |
|||
this.isExtended = isExtended; |
|||
this.disabledElevation = disabledElevation; |
|||
this._sizeConstraints = _sizeConstraints ?? (mini |
|||
? FloatActionButtonUtils._kMiniSizeConstraints |
|||
: FloatActionButtonUtils._kSizeConstraints); |
|||
} |
|||
|
|||
public FloatingActionButton( |
|||
Key key = null, |
|||
Widget child = null, |
|||
string tooltip = null, |
|||
Color foregroundColor = null, |
|||
Color backgroundColor = null, |
|||
object heroTag = null, |
|||
float elevation = 6.0f, |
|||
float highlightElevation = 12.0f, |
|||
VoidCallback onPressed = null, |
|||
bool mini = false, |
|||
ShapeBorder shape = null, |
|||
Clip clipBehavior = Clip.none, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
bool isExtended = false |
|||
) : this(key: key, |
|||
child: child, |
|||
tooltip: tooltip, |
|||
foregroundColor: foregroundColor, |
|||
backgroundColor: backgroundColor, |
|||
heroTag: heroTag, |
|||
elevation: elevation, |
|||
highlightElevation: highlightElevation, |
|||
onPressed: onPressed, |
|||
mini: mini, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
isExtended: isExtended, |
|||
_sizeConstraints: null) { |
|||
} |
|||
|
|||
public static FloatingActionButton extended( |
|||
Key key = null, |
|||
string tooltip = null, |
|||
Color foregroundColor = null, |
|||
Color backgroundColor = null, |
|||
object heroTag = null, |
|||
float elevation = 6.0f, |
|||
float highlightElevation = 12.0f, |
|||
float? disabledElevation = null, |
|||
VoidCallback onPressed = null, |
|||
ShapeBorder shape = null, |
|||
bool isExtended = true, |
|||
MaterialTapTargetSize? materialTapTargetSize = null, |
|||
Clip clipBehavior = Clip.none, |
|||
Widget icon = null, |
|||
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); |
|||
heroTag = heroTag ?? new _DefaultHeroTag(); |
|||
shape = shape ?? new StadiumBorder(); |
|||
|
|||
BoxConstraints _sizeConstraints = FloatActionButtonUtils._kExtendedSizeConstraints; |
|||
bool mini = false; |
|||
Widget child = new _ChildOverflowBox( |
|||
child: new Row( |
|||
mainAxisSize: MainAxisSize.min, |
|||
children: new List<Widget> { |
|||
new SizedBox(width: 16.0f), |
|||
icon, |
|||
new SizedBox(width: 8.0f), |
|||
label, |
|||
new SizedBox(width: 20.0f) |
|||
})); |
|||
|
|||
return new FloatingActionButton( |
|||
key: key, |
|||
child: child, |
|||
tooltip: tooltip, |
|||
foregroundColor: foregroundColor, |
|||
backgroundColor: backgroundColor, |
|||
heroTag: heroTag, |
|||
elevation: elevation, |
|||
highlightElevation: highlightElevation, |
|||
disabledElevation: disabledElevation ?? elevation, |
|||
onPressed: onPressed, |
|||
mini: mini, |
|||
shape: shape, |
|||
clipBehavior: clipBehavior, |
|||
materialTapTargetSize: materialTapTargetSize, |
|||
isExtended: isExtended, |
|||
_sizeConstraints: _sizeConstraints |
|||
); |
|||
} |
|||
|
|||
public readonly Widget child; |
|||
|
|||
public readonly string tooltip; |
|||
|
|||
public readonly Color foregroundColor; |
|||
|
|||
public readonly Color backgroundColor; |
|||
|
|||
public readonly object heroTag; |
|||
|
|||
public readonly VoidCallback onPressed; |
|||
|
|||
public readonly float elevation; |
|||
|
|||
public readonly float highlightElevation; |
|||
|
|||
public readonly float? disabledElevation; |
|||
|
|||
public readonly bool mini; |
|||
|
|||
public readonly ShapeBorder shape; |
|||
|
|||
public readonly Clip clipBehavior; |
|||
|
|||
public readonly bool isExtended; |
|||
|
|||
public readonly MaterialTapTargetSize? materialTapTargetSize; |
|||
|
|||
public readonly BoxConstraints _sizeConstraints; |
|||
|
|||
public override Widget build(BuildContext context) { |
|||
ThemeData theme = Theme.of(context); |
|||
Color foregroundColor = this.foregroundColor ?? theme.accentIconTheme.color; |
|||
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: this.elevation, |
|||
highlightElevation: this.highlightElevation, |
|||
disabledElevation: this.disabledElevation ?? this.elevation, |
|||
constraints: this._sizeConstraints, |
|||
materialTapTargetSize: this.materialTapTargetSize ?? theme.materialTapTargetSize, |
|||
fillColor: this.backgroundColor ?? theme.accentColor, |
|||
textStyle: theme.accentTextTheme.button.copyWith( |
|||
color: foregroundColor, |
|||
letterSpacing: 1.2f), |
|||
shape: this.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; |
|||
} |
|||
} |
|||
|
|||
class _ChildOverflowBox : SingleChildRenderObjectWidget { |
|||
public _ChildOverflowBox( |
|||
Key key = null, |
|||
Widget child = null) : base(key: key, child: child) { |
|||
} |
|||
|
|||
public override RenderObject createRenderObject(BuildContext context) { |
|||
return new _RenderChildOverflowBox(); |
|||
} |
|||
|
|||
public override void updateRenderObject(BuildContext context, RenderObject renderObject) { |
|||
} |
|||
} |
|||
|
|||
|
|||
class _RenderChildOverflowBox : RenderAligningShiftedBox { |
|||
public _RenderChildOverflowBox( |
|||
RenderBox child = null) : base(child: child, alignment: Alignment.center) { |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicWidth(float height) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
protected override float computeMinIntrinsicHeight(float width) { |
|||
return 0.0f; |
|||
} |
|||
|
|||
protected override void performLayout() { |
|||
if (this.child != null) { |
|||
this.child.layout(new BoxConstraints(), parentUsesSize: true); |
|||
this.size = new Size( |
|||
Mathf.Max(this.constraints.minWidth, Mathf.Min(this.constraints.maxWidth, this.child.size.width)), |
|||
Mathf.Max(this.constraints.minHeight, Mathf.Min(this.constraints.maxHeight, this.child.size.height)) |
|||
); |
|||
this.alignChild(); |
|||
} |
|||
else { |
|||
this.size = this.constraints.biggest; |
|||
} |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue