home_screen.dart 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * router
  3. * A Posse Production
  4. * http://goposse.com
  5. * Copyright (c) 2017 Posse Productions LLC. All rights reserved.
  6. * See LICENSE for distribution and usage details.
  7. */
  8. import 'package:flutter/material.dart';
  9. import 'package:router/fluro.dart';
  10. import 'package:router_example/config/application.dart';
  11. class HomeScreen extends StatelessWidget {
  12. BuildContext context;
  13. @override
  14. Widget build(BuildContext context) {
  15. this.context = context;
  16. var menuWidgets = <Widget>[
  17. new Padding(
  18. padding: new EdgeInsets.only(bottom: 15.0),
  19. child: new Image(image: new AssetImage("assets/images/logo_fluro.png"), width: 200.0),
  20. ),
  21. menuButton("Native Animation", "native"),
  22. menuButton("Preset (In from Left)", "preset-from-left"),
  23. menuButton("Preset (Fade In)", "preset-fade"),
  24. menuButton("Custom", "custom"),
  25. ];
  26. return new Material(
  27. color: new Color(0xFF00D6F7),
  28. child: new Column(
  29. mainAxisAlignment: MainAxisAlignment.center,
  30. children: menuWidgets,
  31. ),
  32. );
  33. }
  34. // helpers
  35. Widget menuButton(String title, String key) {
  36. return new Padding(
  37. padding: new EdgeInsets.all(4.0),
  38. child: new ConstrainedBox(
  39. constraints: new BoxConstraints(minHeight: 42.0),
  40. child: new FlatButton(
  41. child: new Text(
  42. title,
  43. style: new TextStyle(
  44. color: new Color(0xFF004F8F),
  45. ),
  46. ),
  47. onPressed: () {
  48. tappedMenuButton(key);
  49. },
  50. ),
  51. ),
  52. );
  53. }
  54. // actions
  55. void tappedMenuButton(String key) {
  56. String message = "";
  57. String hexCode = "#FFFFFF";
  58. TransitionType transitionType = TransitionType.native;
  59. if (key != "custom") {
  60. if (key == "native") {
  61. hexCode = "#F76F00";
  62. message = "This screen should have appeared using the default flutter animation for the current OS";
  63. } else if (key == "preset-from-left") {
  64. hexCode = "#5BF700";
  65. message = "This screen should have appeared with a slide in from left transition";
  66. transitionType = TransitionType.inFromLeft;
  67. } else if (key == "preset-fade") {
  68. hexCode = "#F700D2";
  69. message = "This screen should have appeared with a fade in transition";
  70. transitionType = TransitionType.fadeIn;
  71. }
  72. Application.router.navigateTo(this.context, "/demo?message=$message&color_hex=$hexCode",
  73. transition: transitionType);
  74. } else {
  75. hexCode = "#DFF700";
  76. message = "This screen should have appeared with a crazy custom transition";
  77. var transition = (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation,
  78. Widget child) {
  79. return new ScaleTransition(
  80. scale: animation,
  81. child: new RotationTransition(
  82. turns: animation,
  83. child: child,
  84. ),
  85. );
  86. };
  87. Application.router.navigateTo(this.context, "/demo?message=$message&color_hex=$hexCode",
  88. transition: TransitionType.fadeIn, transitionBuilder: transition,
  89. transitionDuration: const Duration(milliseconds: 600),
  90. );
  91. }
  92. }
  93. }