route_handlers.dart 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * fluro
  3. * A Posse Production
  4. * http://goposse.com
  5. * Copyright (c) 2018 Posse Productions LLC. All rights reserved.
  6. * See LICENSE for distribution and usage details.
  7. */
  8. import '../helpers/color_helpers.dart';
  9. import '../components/demo/demo_simple_component.dart';
  10. import '../components/home/home_component.dart';
  11. import 'package:flutter/painting.dart';
  12. import 'package:fluro/fluro.dart';
  13. import 'package:flutter/material.dart';
  14. var rootHandler = new Handler(
  15. handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  16. return new HomeComponent();
  17. });
  18. var demoRouteHandler = new Handler(
  19. handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  20. String message = params["message"]?.first;
  21. String colorHex = params["color_hex"]?.first;
  22. String result = params["result"]?.first;
  23. Color color = new Color(0xFFFFFFFF);
  24. if (colorHex != null && colorHex.length > 0) {
  25. color = new Color(ColorHelpers.fromHexString(colorHex));
  26. }
  27. return new DemoSimpleComponent(
  28. message: message, color: color, result: result);
  29. });
  30. var demoFunctionHandler = new Handler(
  31. type: HandlerType.function,
  32. handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  33. String message = params["message"]?.first;
  34. showDialog(
  35. context: context,
  36. builder: (context) {
  37. return new AlertDialog(
  38. title: new Text(
  39. "Hey Hey!",
  40. style: new TextStyle(
  41. color: const Color(0xFF00D6F7),
  42. fontFamily: "Lazer84",
  43. fontSize: 22.0,
  44. ),
  45. ),
  46. content: new Text("$message"),
  47. actions: <Widget>[
  48. new Padding(
  49. padding: new EdgeInsets.only(bottom: 8.0, right: 8.0),
  50. child: new FlatButton(
  51. onPressed: () {
  52. Navigator.of(context).pop(true);
  53. },
  54. child: new Text("OK"),
  55. ),
  56. ),
  57. ],
  58. );
  59. },
  60. );
  61. });
  62. /// Handles deep links into the app
  63. /// To test on Android:
  64. ///
  65. /// `adb shell am start -W -a android.intent.action.VIEW -d "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21" com.goposse.fluro`
  66. var deepLinkHandler = new Handler(
  67. handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  68. String colorHex = params["color_hex"]?.first;
  69. String result = params["result"]?.first;
  70. Color color = new Color(0xFFFFFFFF);
  71. if (colorHex != null && colorHex.length > 0) {
  72. color = new Color(ColorHelpers.fromHexString(colorHex));
  73. }
  74. return new DemoSimpleComponent(
  75. message: "DEEEEEP LINK!!!", color: color, result: result);
  76. });