Skip to content

Commit

Permalink
Fix the flip animation & display it after a delay
Browse files Browse the repository at this point in the history
  • Loading branch information
erdemyerebasmaz committed Sep 16, 2024
1 parent ea5d52c commit 818e8c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
18 changes: 10 additions & 8 deletions lib/routes/home/widgets/payments_list/flip_transition.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@ class FlipTransitionState extends State<FlipTransition> with TickerProviderState
curve: const Interval(0.0, 1.0, curve: Curves.fastOutSlowIn),
),
);

_flipAnimationController!.addStatusListener((status) {
if (status == AnimationStatus.completed) {
_flipAnimationController!.reverse();
}
});
_flipAnimationController!.forward().whenCompleteOrCancel(() {
widget.onComplete();
const successfulPaymentRouteAnimation = Duration(seconds: 5, milliseconds: 800);
Future.delayed(successfulPaymentRouteAnimation, () {
_flipAnimationController!.forward().whenCompleteOrCancel(() {
if (!mounted) return;
_flipAnimationController!.reverse().whenCompleteOrCancel(() {
if (mounted) {
widget.onComplete();
}
});
});
});
}

Expand Down
20 changes: 14 additions & 6 deletions lib/routes/home/widgets/payments_list/payment_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,19 @@ class _PaymentItemState extends State<PaymentItem> {
@override
void initState() {
super.initState();
isPaymentItemNew = _createdWithin(const Duration(seconds: 15));
setState(() {
isPaymentItemNew = _createdWithin(const Duration(seconds: 15));
});
}

@override
void didUpdateWidget(PaymentItem oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.paymentData != oldWidget.paymentData) {
setState(() {
isPaymentItemNew = _createdWithin(const Duration(seconds: 15));
});
}
}

@override
Expand Down Expand Up @@ -105,11 +117,7 @@ class _PaymentItemState extends State<PaymentItem> {
}

bool _createdWithin(Duration duration) {
final diff = widget.paymentData.paymentTime.difference(
DateTime.fromMillisecondsSinceEpoch(
DateTime.now().millisecondsSinceEpoch,
),
);
final diff = widget.paymentData.paymentTime.difference(DateTime.now());
return diff > -duration;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,11 @@ class SuccessfulPaymentRouteState extends State<SuccessfulPaymentRoute> with Tic
children: [
if (!showParticles)
SlideTransition(
position: _slideAnimation, // Apply the slide animation
position: _slideAnimation,
child: Container(
color: themeData.bottomAppBarTheme.color
?.withOpacity(0.95), // Fullscreen half-transparent background
color: themeData.bottomAppBarTheme.color?.withOpacity(0.98),
child: const Center(
child: SuccessfulPaymentMessage(), // The message widget
child: SuccessfulPaymentMessage(),
),
),
),
Expand Down

0 comments on commit 818e8c4

Please sign in to comment.