2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2022-08-26 08:11:35 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
|
|
|
class AnimatedText extends StatefulWidget {
|
|
|
|
const AnimatedText({
|
|
|
|
Key? key,
|
|
|
|
required this.stringsToLoopThrough,
|
|
|
|
required this.style,
|
|
|
|
this.duration = const Duration(milliseconds: 700),
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
final List<String> stringsToLoopThrough;
|
|
|
|
final TextStyle style;
|
|
|
|
final Duration duration;
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<AnimatedText> createState() => _AnimatedTextState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _AnimatedTextState extends State<AnimatedText> {
|
|
|
|
Timer? _timer;
|
|
|
|
late String _text;
|
|
|
|
late final List<String> _strings;
|
|
|
|
int _currentIndex = 0;
|
|
|
|
|
|
|
|
void update() {
|
|
|
|
if (_currentIndex < _strings.length - 1) {
|
|
|
|
_currentIndex++;
|
|
|
|
} else {
|
|
|
|
_currentIndex = 0;
|
|
|
|
}
|
|
|
|
setState(() {
|
|
|
|
_text = _strings[_currentIndex];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
_strings = widget.stringsToLoopThrough;
|
|
|
|
_text = _strings[0];
|
|
|
|
|
|
|
|
_timer = Timer.periodic(widget.duration, (_) {
|
|
|
|
update();
|
|
|
|
});
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_timer?.cancel();
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Text(
|
|
|
|
_text,
|
|
|
|
style: widget.style,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|