You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.0 KiB

2 years ago
  1. import 'package:animated_text_kit/animated_text_kit.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutter_riverpod/flutter_riverpod.dart';
  4. class CountdownOverlay extends ConsumerWidget {
  5. const CountdownOverlay({
  6. required bool isStartPressed,
  7. required Function() onFinish,
  8. required int initialSpeed,
  9. Key? key,
  10. }) : _isStartPressed = isStartPressed,
  11. _onFinish = onFinish,
  12. _kInitialSpeed = initialSpeed,
  13. super(key: key);
  14. final bool _isStartPressed;
  15. final Function() _onFinish;
  16. final int _kInitialSpeed;
  17. @override
  18. Widget build(BuildContext context, WidgetRef ref) {
  19. return Visibility(
  20. visible: _isStartPressed,
  21. child: Container(
  22. height: double.maxFinite,
  23. width: double.maxFinite,
  24. color: Colors.black54,
  25. child: Center(
  26. child: Wrap(
  27. children: [
  28. SizedBox(
  29. width: 250.0,
  30. child: DefaultTextStyle(
  31. style: const TextStyle(
  32. fontSize: 150.0,
  33. color: Colors.white,
  34. fontFamily: 'GoogleSans',
  35. ),
  36. child: AnimatedTextKit(
  37. // totalRepeatCount: 1,
  38. isRepeatingAnimation: false,
  39. pause: const Duration(milliseconds: 0),
  40. onFinished: _onFinish,
  41. animatedTexts: [
  42. RotateAnimatedText(
  43. '3',
  44. transitionHeight: 100 * 2.5,
  45. textStyle: const TextStyle(
  46. color: Colors.white,
  47. ),
  48. duration: Duration(milliseconds: _kInitialSpeed),
  49. ),
  50. RotateAnimatedText(
  51. '2',
  52. transitionHeight: 100 * 2.5,
  53. textStyle: const TextStyle(
  54. color: Colors.white,
  55. ),
  56. duration: Duration(milliseconds: _kInitialSpeed),
  57. ),
  58. RotateAnimatedText(
  59. '1',
  60. transitionHeight: 100 * 2.5,
  61. textStyle: const TextStyle(
  62. color: Colors.white,
  63. ),
  64. duration: Duration(milliseconds: _kInitialSpeed),
  65. ),
  66. RotateAnimatedText(
  67. 'GO!',
  68. textStyle: const TextStyle(
  69. fontSize: 120.0,
  70. color: Colors.white,
  71. ),
  72. transitionHeight: 120 * 2.5,
  73. duration: Duration(milliseconds: _kInitialSpeed),
  74. ),
  75. ],
  76. ),
  77. ),
  78. ),
  79. ],
  80. ),
  81. ),
  82. ),
  83. );
  84. }
  85. }