import 'package:flutter/material.dart'; import 'package:fluffychat/config/themes.dart'; import 'package:fluffychat/l10n/l10n.dart'; import 'package:fluffychat/pangea/bot/widgets/bot_face_svg.dart'; import 'package:fluffychat/widgets/matrix.dart'; class TokenFeedbackNotification extends StatefulWidget { final String message; const TokenFeedbackNotification({ super.key, required this.message, }); @override State createState() => _TokenFeedbackNotificationState(); } class _TokenFeedbackNotificationState extends State with SingleTickerProviderStateMixin { late AnimationController _slideController; late Animation _slideAnimation; @override void initState() { super.initState(); _slideController = AnimationController( vsync: this, duration: FluffyThemes.animationDuration, ); _slideAnimation = Tween( begin: const Offset(0, -1), end: Offset.zero, ).animate( CurvedAnimation( parent: _slideController, curve: Curves.easeOut, ), ); _slideController.forward(); } @override void dispose() { _slideController.dispose(); super.dispose(); } Future _close() async { await _slideController.reverse(); if (mounted) { MatrixState.pAnyState.closeOverlay("token_feedback_snackbar"); } } @override Widget build(BuildContext context) { return SafeArea( child: SlideTransition( position: _slideAnimation, child: Material( type: MaterialType.transparency, child: Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.symmetric( horizontal: 16.0, vertical: 12.0, ), decoration: BoxDecoration( color: Theme.of(context).colorScheme.surface, borderRadius: BorderRadius.circular(8.0), boxShadow: [ BoxShadow( color: Colors.black.withAlpha(51), blurRadius: 8.0, offset: const Offset(0, 2), ), ], ), child: Row( children: [ const BotFace( width: 30, expression: BotExpression.idle, ), const SizedBox(width: 12), Expanded( child: Text( widget.message, style: Theme.of(context).textTheme.bodyMedium, ), ), const SizedBox(width: 8), IconButton( icon: const Icon(Icons.close), onPressed: _close, tooltip: L10n.of(context).close, ), ], ), ), ), ), ); } }