Browse Source

change processbar move gently

pull/6/head
Sun 4 years ago
parent
commit
1eca960069
  1. 26
      lib/pages/home.dart

26
lib/pages/home.dart

@ -96,32 +96,32 @@ class HomeList extends StatefulWidget {
_HomeListState createState() => _HomeListState(); _HomeListState createState() => _HomeListState();
} }
class _HomeListState extends State<HomeList> { class _HomeListState extends State<HomeList> with SingleTickerProviderStateMixin {
bool isShowHome = true; bool isShowHome = true;
bool isShowFriends = false; bool isShowFriends = false;
bool isShowGroups = false; bool isShowGroups = false;
bool isShowFiles = false; bool isShowFiles = false;
bool isProcess = true; bool isProcess = true;
double processNum = 0.0; AnimationController controller;
Timer timer;
@override @override
void initState() { void initState() {
super.initState(); controller = AnimationController(
timer = Timer.periodic(Duration(seconds: 1), (Timer _t) { vsync: this, duration: const Duration(seconds: 5)
processNum += 0.1; )..addListener(() {
if (processNum > 1.0) { if (controller.value == 1.0) {
isProcess = false; isProcess = false;
timer?.cancel(); }
} setState(() {});
setState(() {});
}); });
controller.forward();
super.initState();
} }
@override @override
void dispose() { void dispose() {
timer?.cancel(); controller.dispose();
super.dispose(); super.dispose();
} }
@ -319,7 +319,7 @@ class _HomeListState extends State<HomeList> {
? LinearProgressIndicator( ? LinearProgressIndicator(
backgroundColor: Color(0x40ADB0BB), backgroundColor: Color(0x40ADB0BB),
valueColor: AlwaysStoppedAnimation(color.primary), valueColor: AlwaysStoppedAnimation(color.primary),
value: processNum, value: controller.value,
) )
: const Divider(height: 1.0, color: Color(0x40ADB0BB)), : const Divider(height: 1.0, color: Color(0x40ADB0BB)),
const SizedBox(height: 5.0), const SizedBox(height: 5.0),

Loading…
Cancel
Save