|
|
|
|
|
|
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 |
|
|
|
); |
|
|
|
} |
|
|
|
} |