route_handlers.dart 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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(message: message, color: color, result: result);
  29. });
  30. var demoFunctionHandler = 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 AlertDialog(
  38. title: Text(
  39. "Hey Hey!",
  40. style: TextStyle(
  41. color: const Color(0xFF00D6F7),
  42. fontFamily: "Lazer84",
  43. fontSize: 22.0,
  44. ),
  45. ),
  46. content: Text("$message"),
  47. actions: <Widget>[
  48. Padding(
  49. padding: EdgeInsets.only(bottom: 8.0, right: 8.0),
  50. child: FlatButton(
  51. onPressed: () {
  52. Navigator.of(context).pop(true);
  53. },
  54. child: 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.theyakka.fluro`
  66. var deepLinkHandler = 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 = Color(0xFFFFFFFF);
  71. if (colorHex != null && colorHex.length > 0) {
  72. color = Color(ColorHelpers.fromHexString(colorHex));
  73. }
  74. return DemoSimpleComponent(
  75. message: "DEEEEEP LINK!!!", color: color, result: result);
  76. });