历史记录

This commit is contained in:
toly
2023-05-03 15:21:44 +08:00
parent 1893c43a9f
commit b75bf0227f
6 changed files with 101 additions and 16 deletions

View File

@@ -1,15 +1,17 @@
import 'package:flutter/material.dart';
class AnimateText extends StatefulWidget {
final String text;
import 'models/merit_record.dart';
const AnimateText({Key? key, required this.text}) : super(key: key);
class AnimateText extends StatefulWidget {
final MeritRecord record;
const AnimateText({Key? key, required this.record}) : super(key: key);
@override
State<AnimateText> createState() => _FadTextState();
State<AnimateText> createState() => _AnimateTextState();
}
class _FadTextState extends State<AnimateText> with SingleTickerProviderStateMixin {
class _AnimateTextState extends State<AnimateText> with SingleTickerProviderStateMixin {
late AnimationController controller;
late Animation<double> opacity;
late Animation<Offset> position;
@@ -18,17 +20,23 @@ class _FadTextState extends State<AnimateText> with SingleTickerProviderStateMix
@override
void initState() {
super.initState();
controller = AnimationController(vsync: this, duration: Duration(milliseconds: 500));
controller =
AnimationController(vsync: this, duration: Duration(milliseconds: 500));
opacity = Tween(begin: 1.0, end: 0.0).animate(controller);
scale = Tween(begin: 1.0, end: 0.9).animate(controller);
position = Tween<Offset>(begin: const Offset(0, 2), end: Offset.zero,).animate(controller);
position = Tween<Offset>(
begin: const Offset(0, 2),
end: Offset.zero,
).animate(controller);
controller.forward();
}
@override
void didUpdateWidget(covariant AnimateText oldWidget) {
super.didUpdateWidget(oldWidget);
controller.forward(from: 0);
if (oldWidget.record.id != widget.record.id) {
controller.forward(from: 0);
}
}
@override
@@ -45,8 +53,8 @@ class _FadTextState extends State<AnimateText> with SingleTickerProviderStateMix
position: position,
child: FadeTransition(
opacity: opacity,
child: Text(widget.text),
child: Text('功德+${widget.record.value}'),
)),
);
}
}
}