home_component.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. new Padding(
  25. padding: new EdgeInsets.only(top: 65.0, left: 60.0, right: 60.0),
  26. child: new Center(
  27. child: new ConstrainedBox(
  28. constraints: new BoxConstraints.tightFor(height: 50.0),
  29. child: new FlatButton(
  30. onPressed: () {
  31. },
  32. child: new Text(
  33. "Try going to fluro://deeplink?path=/message&text=fluro%20rocks%21%21",
  34. textAlign: TextAlign.center,
  35. style: new TextStyle(
  36. fontSize: 10.0,
  37. color: const Color(0xFFFFFFFF),
  38. ),
  39. ),
  40. ),
  41. ),
  42. ),
  43. ),
  44. ];
  45. return new Material(
  46. color: const Color(0xFF00D6F7),
  47. child: new Column(
  48. mainAxisAlignment: MainAxisAlignment.center,
  49. children: menuWidgets,
  50. ),
  51. );
  52. }
  53. // helpers
  54. Widget menuButton(BuildContext context, String title, String key) {
  55. return new Padding(
  56. padding: new EdgeInsets.all(4.0),
  57. child: new ConstrainedBox(
  58. constraints: new BoxConstraints(minHeight: 32.0),
  59. child: new FlatButton(
  60. child: new Text(
  61. title,
  62. style: new TextStyle(
  63. color: const Color(0xFF004F8F),
  64. ),
  65. ),
  66. onPressed: () {
  67. tappedMenuButton(context, key);
  68. },
  69. ),
  70. ),
  71. );
  72. }
  73. // actions
  74. void tappedMenuButton(BuildContext context, String key) {
  75. String message = "";
  76. String hexCode = "#FFFFFF";
  77. TransitionType transitionType = TransitionType.native;
  78. if (key != "custom" && key != "function-call") {
  79. if (key == "native") {
  80. hexCode = "#F76F00";
  81. message = "This screen should have appeared using the default flutter animation for the current OS";
  82. } else if (key == "preset-from-left") {
  83. hexCode = "#5BF700";
  84. message = "This screen should have appeared with a slide in from left transition";
  85. transitionType = TransitionType.inFromLeft;
  86. } else if (key == "preset-fade") {
  87. hexCode = "#F700D2";
  88. message = "This screen should have appeared with a fade in transition";
  89. transitionType = TransitionType.fadeIn;
  90. }
  91. Application.router.navigateTo(context, "/demo?message=$message&color_hex=$hexCode", transition: transitionType);
  92. } else if (key == "custom") {
  93. hexCode = "#DFF700";
  94. message = "This screen should have appeared with a crazy custom transition";
  95. var transition =
  96. (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child) {
  97. return new ScaleTransition(
  98. scale: animation,
  99. child: new RotationTransition(
  100. turns: animation,
  101. child: child,
  102. ),
  103. );
  104. };
  105. Application.router.navigateTo(
  106. context,
  107. "/demo?message=$message&color_hex=$hexCode",
  108. transition: TransitionType.custom,
  109. transitionBuilder: transition,
  110. transitionDuration: const Duration(milliseconds: 600),
  111. );
  112. } else {
  113. message = "You tapped the function button!";
  114. Application.router.navigateTo(context, "/demo/func?message=$message");
  115. }
  116. }
  117. }