浏览代码

Merge branch 'dev_1.17.5' into siyaoH/1.17/keyboard

/siyaoH-1.17-PlatformMessage
siyao 4 年前
当前提交
fd79d96f
共有 13 个文件被更改,包括 342 次插入38 次删除
  1. 8
      com.unity.uiwidgets/Runtime/material/banner.cs
  2. 6
      com.unity.uiwidgets/Runtime/material/bottom_app_bar.cs
  3. 8
      com.unity.uiwidgets/Runtime/material/bottom_sheet.cs
  4. 7
      com.unity.uiwidgets/Runtime/material/button.cs
  5. 12
      com.unity.uiwidgets/Runtime/material/divider.cs
  6. 2
      com.unity.uiwidgets/Runtime/material/ink_well.cs
  7. 20
      com.unity.uiwidgets/Runtime/material/tooltip.cs
  8. 14
      com.unity.uiwidgets/Runtime/widgets/automatic_keep_alive.cs
  9. 4
      com.unity.uiwidgets/Runtime/widgets/framework.cs
  10. 204
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs
  11. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs.meta
  12. 73
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs
  13. 11
      Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs.meta

8
com.unity.uiwidgets/Runtime/material/banner.cs


MaterialBannerThemeData bannerTheme = MaterialBannerTheme.of(context);
bool isSingleRow = actions.Count == 1 && !forceActionsBelow;
EdgeInsetsGeometry padding = this.padding ?? bannerTheme.padding ?? (isSingleRow
EdgeInsetsGeometry padding = this.padding ?? bannerTheme?.padding ?? (isSingleRow
?? bannerTheme.padding
?? bannerTheme?.padding
?? EdgeInsetsDirectional.only(end: 16.0f);
Widget buttonBar = new ButtonBar(

Color backgroundColor = this.backgroundColor
?? bannerTheme.backgroundColor
?? bannerTheme?.backgroundColor
?? bannerTheme.contentTextStyle
?? bannerTheme?.contentTextStyle
?? theme.textTheme.bodyText2;
var rowList = new List<Widget>();

6
com.unity.uiwidgets/Runtime/material/bottom_app_bar.cs


public override Widget build(BuildContext context) {
BottomAppBarTheme babTheme = BottomAppBarTheme.of(context);
NotchedShape notchedShape = widget.shape ?? babTheme.shape;
NotchedShape notchedShape = widget.shape ?? babTheme?.shape;
CustomClipper<Path> clipper = notchedShape != null
? (CustomClipper<Path>) new _BottomAppBarClipper(
geometry: geometryListenable,

: new ShapeBorderClipper(shape: new RoundedRectangleBorder());
float elevation = widget.elevation ?? babTheme.elevation ?? _defaultElevation;
Color color = widget.color ?? babTheme.color ?? Theme.of(context).bottomAppBarColor;
float elevation = widget.elevation ?? babTheme?.elevation ?? _defaultElevation;
Color color = widget.color ?? babTheme?.color ?? Theme.of(context).bottomAppBarColor;
Color effectiveColor = ElevationOverlay.applyOverlay(context, color, elevation);
return new PhysicalShape(
clipper: clipper,

8
com.unity.uiwidgets/Runtime/material/bottom_sheet.cs


public override Widget build(BuildContext context) {
BottomSheetThemeData bottomSheetTheme = Theme.of(context).bottomSheetTheme;
Color color = widget.backgroundColor ?? bottomSheetTheme.backgroundColor;
float elevation = widget.elevation ?? bottomSheetTheme.elevation ?? 0;
ShapeBorder shape = widget.shape ?? bottomSheetTheme.shape;
Clip clipBehavior = widget.clipBehavior ?? bottomSheetTheme.clipBehavior ?? Clip.none;
Color color = widget.backgroundColor ?? bottomSheetTheme?.backgroundColor;
float elevation = widget.elevation ?? bottomSheetTheme?.elevation ?? 0;
ShapeBorder shape = widget.shape ?? bottomSheetTheme?.shape;
Clip clipBehavior = widget.clipBehavior ?? bottomSheetTheme?.clipBehavior ?? Clip.none;
Widget bottomSheet = new Material(
key: _childKey,

7
com.unity.uiwidgets/Runtime/material/button.cs


position: center,
hitTest: (BoxHitTestResult boxHitTest, Offset offsetPosition) => {
D.assert(offsetPosition == center);
return child.hitTest(boxHitTest, position: center);
//WARNING: inconsistent with flutter (zxw): I believe that there is a bug here in flutter
//in flutter, the following line is "return child.hitTest(boxHitTest, position: center); ". This is nonsense since it will always return true regardless of the value of the input parameter: position.
//we have tested a bit in flutter and found that, since an inputPadding has a Semantics as it parent which shares the same size, the Semantics's hitTest can hide this bug in flutter
//Therefore this bug only occurs in UIWidgets
//We are not very clear whether this is the best fix though. Please feel free to optimize it
return child.hitTest(boxHitTest, position: position);
}
);
}

12
com.unity.uiwidgets/Runtime/material/divider.cs


public static BorderSide createBorderSide(BuildContext context, Color color = null, float? width = null) {
Color effectiveColor = color
?? (context != null
? (DividerTheme.of(context).color ?? Theme.of(context).dividerColor)
? (DividerTheme.of(context)?.color ?? Theme.of(context).dividerColor)
?? (context != null ? DividerTheme.of(context).thickness : null)
?? (context != null ? DividerTheme.of(context)?.thickness : null)
?? 0.0f;
// Prevent assertion since it is possible that context is null and no color

public override Widget build(BuildContext context) {
DividerThemeData dividerTheme = DividerTheme.of(context);
float height = this.height ?? dividerTheme.space ?? 16.0f;
float thickness = this.thickness ?? dividerTheme.thickness ?? 0.0f;
float indent = this.indent ?? dividerTheme.indent ?? 0.0f;
float endIndent = this.endIndent ?? dividerTheme.endIndent ?? 0.0f;
float height = this.height ?? dividerTheme?.space ?? 16.0f;
float thickness = this.thickness ?? dividerTheme?.thickness ?? 0.0f;
float indent = this.indent ?? dividerTheme?.indent ?? 0.0f;
float endIndent = this.endIndent ?? dividerTheme?.endIndent ?? 0.0f;
return new SizedBox(
height: height,

2
com.unity.uiwidgets/Runtime/material/ink_well.cs


}
D.assert(_currentSplash == null);
foreach (_HighlightType highlight in _highlights.Keys) {
foreach (_HighlightType highlight in _highlights.Keys.ToList()) {
_highlights[highlight]?.dispose();
_highlights[highlight] = null;
}

20
com.unity.uiwidgets/Runtime/material/tooltip.cs


);
}
height = widget.height ?? tooltipTheme.height ?? _defaultTooltipHeight;
padding = widget.padding ?? tooltipTheme.padding ?? _defaultPadding;
margin = widget.margin ?? tooltipTheme.margin ?? _defaultMargin;
verticalOffset = widget.verticalOffset ?? tooltipTheme.verticalOffset ?? _defaultVerticalOffset;
preferBelow = widget.preferBelow ?? tooltipTheme.preferBelow ?? _defaultPreferBelow;
excludeFromSemantics = widget.excludeFromSemantics ?? tooltipTheme.excludeFromSemantics ?? _defaultExcludeFromSemantics;
decoration = widget.decoration ?? tooltipTheme.decoration ?? defaultDecoration;
textStyle = widget.textStyle ?? tooltipTheme.textStyle ?? defaultTextStyle;
waitDuration = widget.waitDuration ?? tooltipTheme.waitDuration ?? _defaultWaitDuration;
showDuration = widget.showDuration ?? tooltipTheme.showDuration ?? _defaultShowDuration;
height = widget.height ?? tooltipTheme?.height ?? _defaultTooltipHeight;
padding = widget.padding ?? tooltipTheme?.padding ?? _defaultPadding;
margin = widget.margin ?? tooltipTheme?.margin ?? _defaultMargin;
verticalOffset = widget.verticalOffset ?? tooltipTheme?.verticalOffset ?? _defaultVerticalOffset;
preferBelow = widget.preferBelow ?? tooltipTheme?.preferBelow ?? _defaultPreferBelow;
excludeFromSemantics = widget.excludeFromSemantics ?? tooltipTheme?.excludeFromSemantics ?? _defaultExcludeFromSemantics;
decoration = widget.decoration ?? tooltipTheme?.decoration ?? defaultDecoration;
textStyle = widget.textStyle ?? tooltipTheme?.textStyle ?? defaultTextStyle;
waitDuration = widget.waitDuration ?? tooltipTheme?.waitDuration ?? _defaultWaitDuration;
showDuration = widget.showDuration ?? tooltipTheme?.showDuration ?? _defaultShowDuration;
Widget result = new GestureDetector(
behavior: HitTestBehavior.opaque,

14
com.unity.uiwidgets/Runtime/widgets/automatic_keep_alive.cs


handle.addListener(_handles[handle]);
if (!_keepingAlive) {
_keepingAlive = true;
ParentDataElement<KeepAliveParentDataMixin> childElement = _getChildElement();
ParentDataElement childElement = _getChildElement();
if (childElement != null) {
_updateParentDataOfChild(childElement);
}

return;
}
ParentDataElement<KeepAliveParentDataMixin> childElement1 = _getChildElement();
ParentDataElement childElement1 = _getChildElement();
D.assert(childElement1 != null);
_updateParentDataOfChild(childElement1);
});

return false;
}
ParentDataElement<KeepAliveParentDataMixin> _getChildElement() {
ParentDataElement _getChildElement() {
D.assert(childElement == null || childElement is ParentDataElement<KeepAliveParentDataMixin>);
return (ParentDataElement<KeepAliveParentDataMixin>) childElement;
D.assert(childElement == null || childElement is ParentDataElement);
return (ParentDataElement) childElement;
void _updateParentDataOfChild(ParentDataElement<KeepAliveParentDataMixin> childElement) {
childElement.applyWidgetOutOfTurn((ParentDataWidget<KeepAliveParentDataMixin>) build(context));
void _updateParentDataOfChild(ParentDataElement childElement) {
childElement.applyWidgetOutOfTurn((ParentDataWidget) build(context));
}
VoidCallback _createCallback(Listenable handle) {

4
com.unity.uiwidgets/Runtime/widgets/framework.cs


}
}
public class ParentDataElement<T> : ParentDataElement where T : ParentData {
public class ParentDataElement<T> : ParentDataElement where T : IParentData {
public ParentDataElement(ParentDataWidget<T> widget) : base(widget)
{
}

((RenderObjectElement) child)._updateParentData(widget);
}
else {
D.assert(!(child is ParentDataElement<ParentData>));
D.assert(!(child is ParentDataElement<IParentData>));
child.visitChildren(applyParentDataToChild);
}
};

204
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs


using System.Collections.Generic;
using uiwidgets;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.rendering;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class MaterialAppBarSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new MaterialAppBarWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class MaterialAppBarWidget : StatefulWidget {
public MaterialAppBarWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialAppBarWidgetState();
}
}
public class MaterialAppBarWidgetState : State<MaterialAppBarWidget> {
Choice _selectedChoice = Choice.choices[0];
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>.key();
VoidCallback _showBottomSheetCallback;
public override void initState() {
base.initState();
this._showBottomSheetCallback = this._showBottomSheet;
}
void _showBottomSheet() {
this.setState(() => { this._showBottomSheetCallback = null; });
this._scaffoldKey.currentState.showBottomSheet((BuildContext subContext) => {
ThemeData themeData = Theme.of(subContext);
return new Container(
decoration: new BoxDecoration(
border: new Border(
top: new BorderSide(
color: themeData.disabledColor))),
child: new Padding(
padding: EdgeInsets.all(32.0f),
child: new Text("This is a Material persistent bottom sheet. Drag downwards to dismiss it.",
textAlign: TextAlign.center,
style: new TextStyle(
color: themeData.accentColor,
fontSize: 16.0f))
)
);
}).closed.then((object obj) => {
if (this.mounted) {
this.setState(() => { this._showBottomSheetCallback = this._showBottomSheet; });
}
});
}
void _select(Choice choice) {
this.setState(() => { this._selectedChoice = choice; });
}
public override Widget build(BuildContext context) {
return new Scaffold(
key: this._scaffoldKey,
appBar: new AppBar(
title: new Text("Basic AppBar"),
actions: new List<Widget> {
new IconButton(
icon: new Icon(Choice.choices[0].icon),
//color: Colors.blue,
onPressed: () => { this._select((Choice.choices[0])); }
),
new IconButton(
icon: new Icon(Choice.choices[1].icon),
//color: Colors.blue,
onPressed: () => { this._select((Choice.choices[1])); }
),
new PopupMenuButton<Choice>(
onSelected: this._select,
itemBuilder: (BuildContext subContext) => {
List<PopupMenuEntry<Choice>> popupItems = new List<PopupMenuEntry<Choice>>();
for (int i = 2; i < Choice.choices.Count; i++) {
popupItems.Add(new PopupMenuItem<Choice>(
value: Choice.choices[i],
child: new Text(Choice.choices[i].title)));
}
return popupItems;
}
)
}
),
body: new Padding(
padding: EdgeInsets.all(16.0f),
child: new ChoiceCard(choice: this._selectedChoice)
),
floatingActionButton: new FloatingActionButton(
backgroundColor: Colors.redAccent,
child: new Icon(Unity.UIWidgets.material.Icons.add_alert),
onPressed: this._showBottomSheetCallback
),
drawer: new Drawer(
child: new ListView(
padding: EdgeInsets.zero,
children: new List<Widget> {
new ListTile(
leading: new Icon(Unity.UIWidgets.material.Icons.account_circle),
title: new Text("Login"),
onTap: () => { }
),
new Divider(
height: 2.0f),
new ListTile(
leading: new Icon(Unity.UIWidgets.material.Icons.account_balance_wallet),
title: new Text("Wallet"),
onTap: () => { }
),
new Divider(
height: 2.0f),
new ListTile(
leading: new Icon(Unity.UIWidgets.material.Icons.accessibility),
title: new Text("Balance"),
onTap: () => { }
)
}
)
)
);
}
}
class Choice {
public Choice(string title, IconData icon) {
this.title = title;
this.icon = icon;
}
public readonly string title;
public readonly IconData icon;
public static List<Choice> choices = new List<Choice> {
new Choice("Car", Unity.UIWidgets.material.Icons.directions_car),
new Choice("Bicycle", Unity.UIWidgets.material.Icons.directions_bike),
new Choice("Boat", Unity.UIWidgets.material.Icons.directions_boat),
new Choice("Bus", Unity.UIWidgets.material.Icons.directions_bus),
new Choice("Train", Unity.UIWidgets.material.Icons.directions_railway),
new Choice("Walk", Unity.UIWidgets.material.Icons.directions_walk)
};
}
class ChoiceCard : StatelessWidget {
public ChoiceCard(Key key = null, Choice choice = null) : base(key: key) {
this.choice = choice;
}
public readonly Choice choice;
public override Widget build(BuildContext context) {
TextStyle textStyle = Theme.of(context).textTheme.display1;
return new Card(
color: Colors.white,
child: new Center(
child: new Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: new List<Widget> {
new Icon(this.choice.icon, size: 128.0f, color: textStyle.color),
new RaisedButton(
child: new Text(this.choice.title, style: textStyle),
onPressed: () => {
SnackBar snackBar = new SnackBar(
content: new Text(this.choice.title + " is chosen !"),
action: new SnackBarAction(
label: "Ok",
onPressed: () => { }));
Scaffold.of(context).showSnackBar(snackBar);
})
}
)
)
);
}
}
}

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialAppBarSample.cs.meta


fileFormatVersion: 2
guid: 684439e8285b14ebc894b328936d06dd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

73
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs


using System.Collections.Generic;
using Unity.UIWidgets.engine2;
using Unity.UIWidgets.foundation;
using Unity.UIWidgets.material;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;
using UnityEngine;
using Color = Unity.UIWidgets.ui.Color;
using Material = Unity.UIWidgets.material.Material;
using ui_ = Unity.UIWidgets.widgets.ui_;
namespace UIWidgetsSample {
public class MaterialButtonSample : UIWidgetsPanel {
protected override void main() {
ui_.runApp(new MaterialApp(
showPerformanceOverlay: false,
home: new MaterialButtonWidget()));
}
protected new void OnEnable() {
base.OnEnable();
}
}
public class MaterialButtonWidget : StatefulWidget {
public MaterialButtonWidget(Key key = null) : base(key) {
}
public override State createState() {
return new MaterialButtonWidgetState();
}
}
public class MaterialButtonWidgetState : State<MaterialButtonWidget> {
public override Widget build(BuildContext context) {
return new Stack(
children: new List<Widget> {
new Material(
child: new Center(
child: new Column(
children: new List<Widget> {
new Padding(padding: EdgeInsets.only(top: 30f)),
new MaterialButton(
shape: new RoundedRectangleBorder(borderRadius: BorderRadius.all(20.0f)),
color: new Color(0xFF00FF00),
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88FF0011),
child: new Text("Click Me"),
onPressed: () => { Debug.Log("pressed flat button"); }
),
new Padding(padding: EdgeInsets.only(top: 30f)),
new MaterialButton(
shape: new RoundedRectangleBorder(borderRadius: BorderRadius.all(20.0f)),
color: new Color(0xFFFF00FF),
splashColor: new Color(0xFFFF0011),
highlightColor: new Color(0x88FF0011),
elevation: 4.0f,
child: new Text("Click Me"),
onPressed: () => { Debug.Log("pressed raised button"); }
)
}
)
)
)
}
);
}
}
}

11
Samples/UIWidgetsSamples_2019_4/Assets/MaterialSample/MaterialButtonSample.cs.meta


fileFormatVersion: 2
guid: 347e0378e419f46f2af69e1214f1ae5b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存