fzhangtj 6 年前
当前提交
3ede87e3
共有 7 个文件被更改,包括 113 次插入16 次删除
  1. 10
      Runtime/engine/WidgetCanvas.cs
  2. 2
      Runtime/gestures/binding.cs
  3. 9
      Runtime/rendering/proxy_box.cs
  4. 10
      Runtime/widgets/app.cs
  5. 1
      Runtime/widgets/modal_barrier.cs
  6. 35
      Runtime/widgets/routes.cs
  7. 62
      Samples/UIWidgetSample/NavigationCanvas.cs

10
Runtime/engine/WidgetCanvas.cs


this._windowAdapter = new UIWidgetWindowAdapter(this);
this._windowAdapter.OnEnable();
var root = new WidgetsApp(home: this.getWidget(),
var root = new WidgetsApp(
home: this.getWidget(),
textStyle: this.textStyle,
pageRouteBuilder: this.pageRouteBuilder,
onGenerateRoute: this.onGenerateRoute,
onUnknownRoute: this.onUnknownRoute);

protected virtual RouteFactory onGenerateRoute => null;
protected virtual RouteFactory onUnknownRoute => null;
protected virtual painting.TextStyle textStyle => null;
protected virtual PageRouteFactory pageRouteBuilder => (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(

}
if (this._mouseEntered && (this._lastMouseMove.x != Input.mousePosition.x ||
this._lastMouseMove.y != Input.mousePosition.y)) {
this.OnMouseOver();
this.handleMouseMove();
}
this._lastMouseMove = Input.mousePosition;

}
}
void OnMouseOver() {
void handleMouseMove() {
var pos = this.getPointPosition(Input.mousePosition);
this._windowAdapter.postPointerEvent(new PointerData(
timeStamp: Timer.timespanSinceStartup,

2
Runtime/gestures/binding.cs


public readonly HashSet<HitTestTarget> lastMoveTargets = new HashSet<HitTestTarget>();
void _handlePointerEvent(PointerEvent evt) {
if (evt is PointerHoverEvent || evt is PointerMoveEvent) {
if (evt is PointerHoverEvent) {
this._handlePointerHoverEvent(evt);
}

9
Runtime/rendering/proxy_box.cs


return (opacity * 255).round();
}
double _opacity;
public double opacity {
get { return this._opacity; }
set {

this.markNeedsPaint();
}
}
double _opacity;
public override void paint(PaintingContext context, Offset offset) {
if (this.child != null) {

}
}
public override void applyPaintTransform(RenderObject child, ref Matrix3 transform) {
transform = Matrix3.makeTrans((float)(this.translation.dx * this.size.width),
(float)(this.translation.dy * this.size.height)) * transform;
public override void applyPaintTransform(RenderObject child, Matrix3 transform) {
transform.preTranslate((float)(this.translation.dx * this.size.width),
(float)(this.translation.dy * this.size.height));
}

10
Runtime/widgets/app.cs


public readonly RouteFactory onUnknownRoute;
public readonly PageRouteFactory pageRouteBuilder;
public readonly Dictionary<string, WidgetBuilder> routes;
public readonly TextStyle textStyle;
public readonly Window window;
public WidgetsApp(

Dictionary<string, WidgetBuilder> routes = null,
TransitionBuilder builder = null,
Window window = null,
TextStyle textStyle = null,
Widget home = null
) : base(key) {
D.assert(window != null);

this.navigatorObservers = navigatorObservers ?? new List<NavigatorObserver>();
this.initialRoute = initialRoute;
this.builder = builder;
this.textStyle = textStyle;
D.assert(
home == null ||

else {
D.assert(navigator != null);
result = navigator;
}
if (this.widget.textStyle != null) {
result = new DefaultTextStyle(
style: this.widget.textStyle,
child: result
);
}
D.assert(() => {

1
Runtime/widgets/modal_barrier.cs


}
public override Widget build(BuildContext context) {
//retur
return new GestureDetector(
onTapDown: details => {

35
Runtime/widgets/routes.cs


Animation<double> secondaryAnimation) {
return this._pageBuilder(context, animation, secondaryAnimation);
}
public override Widget buildTransitions(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation, Widget child) {
if (this._transitionBuilder == null) {
return new FadeTransition(
opacity: new CurvedAnimation(
parent: animation,
curve: Curves.linear
),
child: child);
}
return this._transitionBuilder(context, animation, secondaryAnimation, child);
}
public static class DialogUtils {
public static Promise<object> showGeneralDialog(
BuildContext context = null,
RoutePageBuilder pageBuilder = null,
bool barrierDismissible = false,
string barrierLabel = null,
Color barrierColor = null,
TimeSpan? transitionDuration = null,
RouteTransitionsBuilder transitionBuilder = null
) {
D.assert(pageBuilder != null);
D.assert(!barrierDismissible || barrierLabel != null);
return Navigator.of(context, rootNavigator: true).push(new _DialogRoute(
pageBuilder: pageBuilder,
barrierDismissible: barrierDismissible,
barrierLabel: barrierLabel,
barrierColor: barrierColor,
transitionDuration: transitionDuration,
transitionBuilder: transitionBuilder
));
}
}
public delegate Widget RoutePageBuilder(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation);

62
Samples/UIWidgetSample/NavigationCanvas.cs


using System;
using System.Collections.Generic;
using Unity.UIWidgets.animation;
using Unity.UIWidgets.engine;

using Color = Unity.UIWidgets.ui.Color;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
namespace UIWidgetsSample {

{"/detail", (context) => new DetailScreen()}
};
protected override Widget getWidget() {
return null;
}
protected override TextStyle textStyle => new TextStyle(fontSize: 24);
protected override PageRouteFactory pageRouteBuilder => (RouteSettings settings, WidgetBuilder builder) =>
new PageRouteBuilder(

public override Widget build(BuildContext context) {
return new Container(
color: new Color(0xFF1389FD),
child: new Center(child: new CustomButton(onPressed: () => {
Navigator.pop(context);
}, child: new Text("Back"))
child: new Center(
child: new Column(
children: new List<Widget>() {
new CustomButton(onPressed: () => {
Navigator.pop(context);
}, child: new Text("Back")),
new CustomButton(onPressed: () => {
_Dialog.showDialog(context, builder: (BuildContext c) => new Dialog());
}, child: new Text("Show Dialog"))
}
)
class Dialog : StatelessWidget {
public override Widget build(BuildContext context) {
return new Center(child:new Container(
color: new Color(0xFFFF0000),
width: 100,
height: 80,
child: new Center(
child: new Text("Hello Dialog")
)));
}
}
class _FadeUpwardsPageTransition : StatelessWidget {

opacity: this._opacityAnimation,
child: this.child
)
);
}
}
static class _Dialog {
public static void showDialog(BuildContext context,
bool barrierDismissible = true, WidgetBuilder builder = null) {
DialogUtils.showGeneralDialog(
context: context,
pageBuilder: (BuildContext buildContext, Animation<double> animation,
Animation<double> secondaryAnimation) => {
return builder(buildContext);
},
barrierDismissible: barrierDismissible,
barrierLabel: "",
barrierColor: new Color(0x8A000000),
transitionDuration: TimeSpan.FromMilliseconds(150),
transitionBuilder: _buildMaterialDialogTransitions
);
}
static Widget _buildMaterialDialogTransitions(BuildContext context,
Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
return new FadeTransition(
opacity: new CurvedAnimation(
parent: animation,
curve: Curves.easeOut
),
child: child
);
}
}
正在加载...
取消
保存