route_handlers.dart 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * fluro
  3. * Created by Yakka
  4. * https://theyakka.com
  5. *
  6. * Copyright (c) 2019 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 = Handler(
  16. handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  17. return HomeComponent();
  18. });
  19. var demoRouteHandler = 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 = Color(0xFFFFFFFF);
  25. if (colorHex != null && colorHex.length > 0) {
  26. color = Color(ColorHelpers.fromHexString(colorHex));
  27. }
  28. return DemoSimpleComponent(
  29. message: message ?? 'Testing', color: color, result: result);
  30. });
  31. var demoFunctionHandler = 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 AlertDialog(
  39. title: Text(
  40. "Hey Hey!",
  41. style: TextStyle(
  42. color: const Color(0xFF00D6F7),
  43. fontFamily: "Lazer84",
  44. fontSize: 22.0,
  45. ),
  46. ),
  47. content: Text("$message"),
  48. actions: <Widget>[
  49. Padding(
  50. padding: EdgeInsets.only(bottom: 8.0, right: 8.0),
  51. child: TextButton(
  52. onPressed: () {
  53. Navigator.of(context).pop(true);
  54. },
  55. child: Text("OK"),
  56. ),
  57. ),
  58. ],
  59. );
  60. },
  61. );
  62. return;
  63. });
  64. /// Handles deep links into the app
  65. /// To test on Android:
  66. ///
  67. /// `adb shell am start -W -a android.intent.action.VIEW -d "fluro://deeplink?path=/message&mesage=fluro%20rocks%21%21" com.theyakka.fluro`
  68. var deepLinkHandler = Handler(
  69. handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
  70. String? colorHex = params["color_hex"]?.first;
  71. String? result = params["result"]?.first;
  72. Color color = Color(0xFFFFFFFF);
  73. if (colorHex != null && colorHex.length > 0) {
  74. color = Color(ColorHelpers.fromHexString(colorHex));
  75. }
  76. return DemoSimpleComponent(
  77. message: "DEEEEEP LINK!!!", color: color, result: result);
  78. });