home_component.dart 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * fluro
  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 '../../config/application.dart';
  9. import 'package:fluro/fluro.dart';
  10. import 'package:flutter/material.dart';
  11. class HomeComponent extends StatelessWidget {
  12. @override
  13. Widget build(BuildContext context) {
  14. var menuWidgets = <Widget>[
  15. new Padding(
  16. padding: new EdgeInsets.only(bottom: 25.0),
  17. child: new Image(image: new AssetImage("assets/images/logo_fluro.png"), width: 200.0),
  18. ),
  19. menuButton(context, "Native Animation", "native"),
  20. menuButton(context, "Preset (In from Left)", "preset-from-left"),
  21. menuButton(context, "Preset (Fade In)", "preset-fade"),
  22. menuButton(context, "Custom Transition", "custom"),
  23. menuButton(context, "Function Call", "function-call"),
  24. menuButton(context, "Navigator Result", "pop-result"),
  25. new Padding(
  26. padding: new EdgeInsets.only(top: 65.0, left: 60.0, right: 60.0),
  27. child: new Center(
  28. child: new ConstrainedBox(
  29. constraints: new BoxConstraints.tightFor(height: 50.0),
  30. child: new FlatButton(
  31. onPressed: () {
  32. },
  33. child: new Text(
  34. "Try going to fluro://deeplink?path=/message&text=fluro%20rocks%21%21",
  35. textAlign: TextAlign.center,
  36. style: new TextStyle(
  37. fontSize: 10.0,
  38. color: const Color(0xFFFFFFFF),
  39. ),
  40. ),
  41. ),
  42. ),
  43. ),
  44. ),
  45. ];
  46. return new Material(
  47. color: const Color(0xFF00D6F7),
  48. child: new Column(
  49. mainAxisAlignment: MainAxisAlignment.center,
  50. children: menuWidgets,
  51. ),
  52. );
  53. }
  54. // helpers
  55. Widget menuButton(BuildContext context, String title, String key) {
  56. return new Padding(
  57. padding: new EdgeInsets.all(4.0),
  58. child: new ConstrainedBox(
  59. constraints: new BoxConstraints(minHeight: 32.0),
  60. child: new FlatButton(
  61. child: new Text(
  62. title,
  63. style: new TextStyle(
  64. color: const Color(0xFF004F8F),
  65. ),
  66. ),
  67. onPressed: () {
  68. tappedMenuButton(context, key);
  69. },
  70. ),
  71. ),
  72. );
  73. }
  74. // actions
  75. void tappedMenuButton(BuildContext context, String key) {
  76. String message = "";
  77. String hexCode = "#FFFFFF";
  78. String result;
  79. TransitionType transitionType = TransitionType.native;
  80. if (key != "custom" && key != "function-call") {
  81. if (key == "native") {
  82. hexCode = "#F76F00";
  83. message = "This screen should have appeared using the default flutter animation for the current OS";
  84. } else if (key == "preset-from-left") {
  85. hexCode = "#5BF700";
  86. message = "This screen should have appeared with a slide in from left transition";
  87. transitionType = TransitionType.inFromLeft;
  88. } else if (key == "preset-fade") {
  89. hexCode = "#F700D2";
  90. message = "This screen should have appeared with a fade in transition";
  91. transitionType = TransitionType.fadeIn;
  92. } else if (key == "pop-result") {
  93. transitionType = TransitionType.native;
  94. hexCode = "#407F7F";
  95. message = "This screen should return the current weekday";
  96. result = new DateTime.now().weekday.toString();
  97. }
  98. String route = "/demo?message=$message&color_hex=$hexCode";
  99. if (result != null) {
  100. route = "$route&result=$result";
  101. }
  102. Application.router.navigateTo(
  103. context, route,
  104. transition: transitionType).then((result) {
  105. if (key == "pop-result") {
  106. Application.router.navigateTo(context, "/demo/func?message=$result");
  107. }
  108. });
  109. } else if (key == "custom") {
  110. hexCode = "#DFF700";
  111. message = "This screen should have appeared with a crazy custom transition";
  112. var transition =
  113. (BuildContext context, Animation<double> animation,
  114. Animation<double> secondaryAnimation, Widget child) {
  115. return new ScaleTransition(
  116. scale: animation,
  117. child: new RotationTransition(
  118. turns: animation,
  119. child: child,
  120. ),
  121. );
  122. };
  123. Application.router.navigateTo(
  124. context,
  125. "/demo?message=$message&color_hex=$hexCode",
  126. transition: TransitionType.custom,
  127. transitionBuilder: transition,
  128. transitionDuration: const Duration(milliseconds: 600),
  129. );
  130. } else {
  131. message = "You tapped the function button!";
  132. Application.router.navigateTo(context, "/demo/func?message=$message");
  133. }
  134. }
  135. }