* fix: on flag token info, close word card * chore: update icon and tooltip for emoji mode * refactor: create base feedback dialog * fix: start drag imeadiatly on tap practice match item
111 lines
2.9 KiB
Dart
111 lines
2.9 KiB
Dart
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<TokenFeedbackNotification> createState() =>
|
|
_TokenFeedbackNotificationState();
|
|
}
|
|
|
|
class _TokenFeedbackNotificationState extends State<TokenFeedbackNotification>
|
|
with SingleTickerProviderStateMixin {
|
|
late AnimationController _slideController;
|
|
late Animation<Offset> _slideAnimation;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
_slideController = AnimationController(
|
|
vsync: this,
|
|
duration: FluffyThemes.animationDuration,
|
|
);
|
|
|
|
_slideAnimation = Tween<Offset>(
|
|
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<void> _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,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|