浏览代码

Update AppBarTheme, BottomAppBarTheme, CardTheme, Dialog, DialogTheme,

Drawer, GestureDetector.
/main
Yuncong Zhang 5 年前
当前提交
d1d12dca
共有 7 个文件被更改,包括 138 次插入32 次删除
  1. 3
      Runtime/material/app_bar_theme.cs
  2. 1
      Runtime/material/bottom_app_bar_theme.cs
  3. 3
      Runtime/material/card_theme.cs
  4. 74
      Runtime/material/dialog.cs
  5. 64
      Runtime/material/dialog_theme.cs
  6. 11
      Runtime/material/drawer.cs
  7. 14
      Runtime/widgets/gesture_detector.cs

3
Runtime/material/app_bar_theme.cs


}
public static AppBarTheme lerp(AppBarTheme a, AppBarTheme b, float t) {
D.assert(t != null);
return new AppBarTheme(
brightness: t < 0.5f ? a?.brightness : b?.brightness,
color: Color.lerp(a?.color, b?.color, t),

properties.add(new DiagnosticsProperty<TextTheme>("textTheme", this.textTheme, defaultValue: null));
}
}
}
}

1
Runtime/material/bottom_app_bar_theme.cs


}
public static BottomAppBarTheme lerp(BottomAppBarTheme a, BottomAppBarTheme b, float t) {
D.assert(t != null);
return new BottomAppBarTheme(
color: Color.lerp(a?.color, b?.color, t),
elevation: MathUtils.lerpFloat(a?.elevation ?? 0.0f, b?.elevation ?? 0.0f, t),

3
Runtime/material/card_theme.cs


}
public static CardTheme lerp(CardTheme a, CardTheme b, float t) {
D.assert(t != null);
return new CardTheme(
clipBehavior: t < 0.5f ? a?.clipBehavior : b?.clipBehavior,
color: Color.lerp(a?.color, b?.color, t),

properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape, defaultValue: null));
}
}
}
}

74
Runtime/material/dialog.cs


using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
Widget child = null,
Color backgroundColor = null,
float? elevation = null,
ShapeBorder shape = null
ShapeBorder shape = null,
Widget child = null
this.backgroundColor = backgroundColor;
this.elevation = elevation;
this.insetAnimationCurve = Curves.decelerate;
this.insetAnimationCurve = insetAnimationCurve ?? Curves.decelerate;
public readonly Widget child;
public readonly Color backgroundColor;
public readonly float? elevation;
public readonly TimeSpan insetAnimationDuration;

Color _getColor(BuildContext context) {
return Theme.of(context).dialogBackgroundColor;
}
public readonly Widget child;
const float _defaultElevation = 24.0f;
public override Widget build(BuildContext context) {
DialogTheme dialogTheme = DialogTheme.of(context);

child: new ConstrainedBox(
constraints: new BoxConstraints(minWidth: 280.0f),
child: new Material(
elevation: 24.0f,
color: this._getColor(context),
color: this.backgroundColor ?? dialogTheme.backgroundColor ??
Theme.of(context).dialogBackgroundColor,
elevation: this.elevation ?? dialogTheme.elevation ?? _defaultElevation,
shape: this.shape ?? dialogTheme.shape ?? _defaultDialogShape,
child: this.child,
shape: this.shape ?? dialogTheme.shape ?? _defaultDialogShape
child: this.child
)
)
)

Key key = null,
Widget title = null,
EdgeInsets titlePadding = null,
TextStyle titleTextStyle = null,
TextStyle contentTextStyle = null,
Color backgroundColor = null,
float? elevation = null,
this.titleTextStyle = titleTextStyle;
this.contentTextStyle = contentTextStyle;
this.backgroundColor = backgroundColor;
this.elevation = elevation;
public readonly TextStyle titleTextStyle;
public readonly TextStyle contentTextStyle;
public readonly Color backgroundColor;
public readonly float? elevation;
ThemeData theme = Theme.of(context);
DialogTheme dialogTheme = DialogTheme.of(context);
List<Widget> children = new List<Widget>();
if (this.title != null) {

child: new DefaultTextStyle(
style: Theme.of(context).textTheme.title,
style: this.titleTextStyle ?? dialogTheme.titleTextStyle ?? theme.textTheme.title,
child: this.title
)
));

child: new Padding(
padding: this.contentPadding,
child: new DefaultTextStyle(
style: Theme.of(context).textTheme.subhead,
style: this.contentTextStyle ?? dialogTheme.contentTextStyle ?? theme.textTheme.subhead,
child: this.content
)
)

)
);
return new Dialog(child: dialogChild, shape: this.shape);
return new Dialog(
backgroundColor: this.backgroundColor,
elevation: this.elevation,
shape: this.shape,
child: dialogChild
);
}
}

EdgeInsets titlePadding = null,
List<Widget> children = null,
EdgeInsets contentPadding = null,
Color backgroundColor = null,
float? elevation = null,
ShapeBorder shape = null
) : base(key: key) {
this.title = title;

this.backgroundColor = backgroundColor;
this.elevation = elevation;
this.shape = shape;
}

public readonly List<Widget> children;
public readonly EdgeInsets contentPadding;
public readonly Color backgroundColor;
public readonly float? elevation;
public readonly ShapeBorder shape;

)
);
return new Dialog(child: dialogChild, shape: this.shape);
return new Dialog(
backgroundColor: this.backgroundColor,
elevation: this.elevation,
shape: this.shape,
child: dialogChild
);
static Widget _buildMaterialDialogTransitions(BuildContext context, Animation<float> animation,
Animation<float> secondaryAnimation, Widget child) {
return new FadeTransition(

);
}
}
}
}

64
Runtime/material/dialog_theme.cs


using System;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
public DialogTheme(ShapeBorder shape = null) {
public DialogTheme(
Color backgroundColor = null,
float? elevation = null,
ShapeBorder shape = null,
TextStyle titleTextStyle = null,
TextStyle contentTextStyle = null
) {
this.backgroundColor = backgroundColor;
this.elevation = elevation;
this.titleTextStyle = titleTextStyle;
this.contentTextStyle = contentTextStyle;
public readonly Color backgroundColor;
public readonly float? elevation;
public DialogTheme copyWith(ShapeBorder shape = null) {
return new DialogTheme(shape: shape ?? this.shape);
public readonly TextStyle titleTextStyle;
public readonly TextStyle contentTextStyle;
DialogTheme copyWith(
Color backgroundColor = null,
float? elevation = null,
ShapeBorder shape = null,
TextStyle titleTextStyle = null,
TextStyle contentTextStyle = null
) {
return new DialogTheme(
backgroundColor: backgroundColor ?? this.backgroundColor,
elevation: elevation ?? this.elevation,
shape: shape ?? this.shape,
titleTextStyle: titleTextStyle ?? this.titleTextStyle,
contentTextStyle: contentTextStyle ?? this.contentTextStyle
);
}
public static DialogTheme of(BuildContext context) {

public static DialogTheme lerp(DialogTheme a, DialogTheme b, float t) {
return new DialogTheme(
shape: ShapeBorder.lerp(a?.shape, b?.shape, t)
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
elevation: MathUtils.lerpFloat(a?.elevation ?? 0.0f, b?.elevation ?? 0.0f, t),
shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
titleTextStyle: TextStyle.lerp(a?.titleTextStyle, b?.titleTextStyle, t),
contentTextStyle: TextStyle.lerp(a?.contentTextStyle, b?.contentTextStyle, t)
);
}

}
return Equals(this.shape, other.shape);
return Equals(this.backgroundColor, other.backgroundColor)
&& Equals(this.elevation, other.elevation)
&& Equals(this.shape, other.shape)
&& Equals(this.titleTextStyle, other.titleTextStyle)
&& Equals(this.contentTextStyle, other.contentTextStyle);
}
public override bool Equals(object obj) {

return this.Equals((DialogTheme) obj);
}

public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape,
defaultValue: Diagnostics.kNullDefaultValue));
properties.add(new DiagnosticsProperty<Color>("backgroundColor", this.backgroundColor));
properties.add(new DiagnosticsProperty<ShapeBorder>("shape", this.shape));
properties.add(new DiagnosticsProperty<float?>("elevation", this.elevation));
properties.add(new DiagnosticsProperty<TextStyle>("titleTextStyle", this.titleTextStyle));
properties.add(new DiagnosticsProperty<TextStyle>("contentTextStyle", this.contentTextStyle));
}
}

11
Runtime/material/drawer.cs


Key key = null,
float elevation = 16.0f,
Widget child = null) : base(key: key) {
D.assert(elevation >= 0.0f);
this.elevation = elevation;
this.child = child;
}

GlobalKey key = null,
Widget child = null,
DrawerAlignment? alignment = null,
DrawerCallback drawerCallback = null) : base(key: key) {
DrawerCallback drawerCallback = null,
DragStartBehavior? dragStartBehavior = null
) : base(key: key) {
D.assert(dragStartBehavior != null);
this.dragStartBehavior = dragStartBehavior;
public readonly DragStartBehavior? dragStartBehavior;
public readonly DrawerCallback drawerCallback;

onHorizontalDragUpdate: this._move,
onHorizontalDragEnd: this._settle,
behavior: HitTestBehavior.translucent,
dragStartBehavior: this.widget.dragStartBehavior ?? DragStartBehavior.down,
child: new Container(width: dragAreaWidth)
)
);

onHorizontalDragUpdate: this._move,
onHorizontalDragEnd: this._settle,
onHorizontalDragCancel: this._handleDragCancel,
dragStartBehavior: this.widget.dragStartBehavior ?? DragStartBehavior.down,
child: new RepaintBoundary(
child: new Stack(
children: new List<Widget> {

14
Runtime/widgets/gesture_detector.cs


GestureDragUpdateCallback onPanUpdate = null,
GestureDragEndCallback onPanEnd = null,
GestureDragCancelCallback onPanCancel = null,
HitTestBehavior behavior = HitTestBehavior.deferToChild) : base(key) {
HitTestBehavior behavior = HitTestBehavior.deferToChild,
DragStartBehavior dragStartBehavior = DragStartBehavior.down
) : base(key) {
D.assert(() => {
bool haveVerticalDrag =
onVerticalDragStart != null || onVerticalDragUpdate != null ||

this.onPanEnd = onPanEnd;
this.onPanCancel = onPanCancel;
this.behavior = behavior;
this.dragStartBehavior = dragStartBehavior;
}
public readonly Widget child;

public readonly GestureDragEndCallback onPanEnd;
public readonly GestureDragCancelCallback onPanCancel;
public readonly HitTestBehavior behavior;
public readonly DragStartBehavior dragStartBehavior;
public override Widget build(BuildContext context) {
var gestures = new Dictionary<Type, GestureRecognizerFactory>();

instance.onUpdate = this.onVerticalDragUpdate;
instance.onEnd = this.onVerticalDragEnd;
instance.onCancel = this.onVerticalDragCancel;
instance.dragStartBehavior = this.dragStartBehavior;
}
);
}

instance.onUpdate = this.onHorizontalDragUpdate;
instance.onEnd = this.onHorizontalDragEnd;
instance.onCancel = this.onHorizontalDragCancel;
instance.dragStartBehavior = this.dragStartBehavior;
}
);
}

instance.onUpdate = this.onPanUpdate;
instance.onEnd = this.onPanEnd;
instance.onCancel = this.onPanCancel;
instance.dragStartBehavior = this.dragStartBehavior;
}
);
}

behavior: this.behavior,
child: this.child
);
}
public override void debugFillProperties(DiagnosticPropertiesBuilder properties) {
base.debugFillProperties(properties);
properties.add(new EnumProperty<DragStartBehavior>("startBehavior", this.dragStartBehavior));
}
}

正在加载...
取消
保存