route_handlers.dart 2.7 KB

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