Files
pipelines/app/lib/features/chat/conversation/chat_stop_icon.dart
T

49 lines
1.2 KiB
Dart

import 'package:flutter/widgets.dart';
/// Slow, continuous progress motion confined to the Stop glyph. The native
/// button, hit target and semantics never rotate. TickerMode pauses hidden UI.
class ChatStopIcon extends StatefulWidget {
const ChatStopIcon({super.key, required this.child});
final Widget child;
static const period = Duration(seconds: 8);
@override
State<ChatStopIcon> createState() => _ChatStopIconState();
}
class _ChatStopIconState extends State<ChatStopIcon>
with SingleTickerProviderStateMixin {
late final _rotation = AnimationController(
vsync: this,
duration: ChatStopIcon.period,
);
@override
void didChangeDependencies() {
super.didChangeDependencies();
if (MediaQuery.maybeDisableAnimationsOf(context) ?? false) {
_rotation.stop();
_rotation.value = 0;
} else if (!_rotation.isAnimating) {
_rotation.repeat();
}
}
@override
void dispose() {
_rotation.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) => RepaintBoundary(
key: const Key('chat-stop-paint-boundary'),
child: RotationTransition(
key: const Key('chat-stop-rotation'),
turns: _rotation,
child: widget.child,
),
);
}