reorganize and rename widgets
This commit is contained in:
parent
05d25869ef
commit
d5f29dc344
1 changed files with 568 additions and 547 deletions
41
lib/widgets/common/bouncing_dots.dart
Normal file
41
lib/widgets/common/bouncing_dots.dart
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import "dart:math";
|
||||
|
||||
import "package:flutter_hooks/flutter_hooks.dart";
|
||||
import "package:material_ui/material_ui.dart";
|
||||
|
||||
/// Three dots that bounce one after another, in a loop.
|
||||
class const BouncingDots({required final Color color, super.key})
|
||||
extends HookWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = useAnimationController(
|
||||
duration: const .new(milliseconds: 1200),
|
||||
);
|
||||
useEffect(() {
|
||||
controller.repeat();
|
||||
return null;
|
||||
}, []);
|
||||
final progress = useAnimation(controller);
|
||||
|
||||
return Row(
|
||||
mainAxisSize: .min,
|
||||
spacing: 3,
|
||||
children: [0, 1, 2].map((index) {
|
||||
final phase = (progress - index * 0.15) % 1;
|
||||
final bounce = phase < 0.4 ? sin(phase / 0.4 * pi) : 0.0;
|
||||
|
||||
return Transform.translate(
|
||||
offset: .new(0, -3 * bounce),
|
||||
child: Opacity(
|
||||
opacity: 0.4 + 0.6 * bounce,
|
||||
child: Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: BoxDecoration(color: color, shape: .circle),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue