wonders/lib/ui/screens/timeline/widgets/_event_popups.dart

71 lines
1.9 KiB
Dart
Raw Normal View History

2022-08-29 20:38:28 -06:00
part of '../timeline_screen.dart';
class _EventPopups extends StatefulWidget {
const _EventPopups({Key? key, required this.currentEvent}) : super(key: key);
final TimelineEvent? currentEvent;
@override
State<_EventPopups> createState() => _EventPopupsState();
}
class _EventPopupsState extends State<_EventPopups> {
final _debouncer = Debouncer(500.ms);
TimelineEvent? _eventToShow;
@override
void dispose() {
_debouncer.reset();
super.dispose();
}
@override
void didUpdateWidget(covariant _EventPopups oldWidget) {
super.didUpdateWidget(oldWidget);
_debouncer.call(showCardForCurrentYr);
}
void showCardForCurrentYr() {
setState(() {
_eventToShow = widget.currentEvent;
});
}
@override
Widget build(BuildContext context) {
final evt = _eventToShow;
return TopCenter(
child: ClipRect(
child: IgnorePointer(
ignoringSemantics: false,
child: AnimatedSwitcher(
duration: $styles.times.fast,
child: evt == null
? SizedBox.shrink()
: Semantics(
liveRegion: true,
child: Animate(
effects: const [
SlideEffect(begin: Offset(0, -.1)),
],
key: ValueKey(_eventToShow?.year),
child: IntrinsicHeight(
2022-10-25 00:27:19 -06:00
child: SizedBox(
width: $styles.sizes.maxContentWidth3,
2022-10-25 00:27:19 -06:00
child: Padding(
padding: EdgeInsets.all($styles.insets.md),
child: TimelineEventCard(
text: evt.description,
year: evt.year,
),
2022-08-29 20:38:28 -06:00
),
),
),
),
),
),
),
),
);
}
}