route_handlers.dart 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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(handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  15. return new HomeComponent();
  16. });
  17. var demoRouteHandler = new Handler(handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  18. String message = params["message"]?.first;
  19. String colorHex = params["color_hex"]?.first;
  20. String result = params["result"]?.first;
  21. Color color = new Color(0xFFFFFFFF);
  22. if (colorHex != null && colorHex.length > 0) {
  23. color = new Color(ColorHelpers.fromHexString(colorHex));
  24. }
  25. return new DemoSimpleComponent(message: message, color: color, result: result);
  26. });
  27. var demoFunctionHandler = new Handler(
  28. type: HandlerType.function,
  29. handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  30. String message = params["message"]?.first;
  31. showDialog(
  32. context: context,
  33. child: new AlertDialog(
  34. title: new Text(
  35. "Hey Hey!",
  36. style: new TextStyle(
  37. color: const Color(0xFF00D6F7),
  38. fontFamily: "Lazer84",
  39. fontSize: 22.0,
  40. ),
  41. ),
  42. content: new Text("$message"),
  43. actions: <Widget>[
  44. new Padding(
  45. padding: new EdgeInsets.only(bottom: 8.0, right: 8.0),
  46. child: new FlatButton(
  47. onPressed: () {
  48. Navigator.of(context).pop(true);
  49. },
  50. child: new Text("OK"),
  51. ),
  52. ),
  53. ],
  54. ),
  55. );
  56. });
  57. /// Handles deep links into the app
  58. /// To test on Android:
  59. ///
  60. /// `adb shell am start -W -a android.intent.action.VIEW -d "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21" com.goposse.fluro`
  61. var deepLinkHandler = new Handler(handlerFunc: (BuildContext context, Map<String, List<String>> params) {
  62. String message = params["message"]?.first;
  63. String colorHex = params["color_hex"]?.first;
  64. String result = params["result"]?.first;
  65. Color color = new Color(0xFFFFFFFF);
  66. if (colorHex != null && colorHex.length > 0) {
  67. color = new Color(ColorHelpers.fromHexString(colorHex));
  68. }
  69. return new DemoSimpleComponent(message: "DEEEEEP LINK!!!", color: color, result: result);
  70. });