mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-19 14:53:44 +00:00
fix(ui): smooth task progress bar updates (#1532)
This commit is contained in:
1 file changed
+11
-2
@@ -1,3 +1,4 @@
|
||||
import 'package:shadcn_flutter/shadcn_flutter.dart' show kDefaultDuration;
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class TaskProgressBar extends StatefulWidget {
|
||||
@@ -74,7 +75,14 @@ class _TaskProgressBarState extends State<TaskProgressBar> with SingleTickerProv
|
||||
color: widget.trackColor,
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return AnimatedBuilder(
|
||||
final progress = (widget.value ?? 0).clamp(0.0, 1.0);
|
||||
return TweenAnimationBuilder<double>(
|
||||
tween: Tween<double>(begin: progress, end: progress),
|
||||
duration: MediaQuery.disableAnimationsOf(context) || widget.indeterminate
|
||||
? Duration.zero
|
||||
: kDefaultDuration,
|
||||
curve: Curves.easeInOut,
|
||||
builder: (context, animatedProgress, child) => AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) {
|
||||
if (widget.indeterminate) {
|
||||
@@ -102,7 +110,7 @@ class _TaskProgressBarState extends State<TaskProgressBar> with SingleTickerProv
|
||||
);
|
||||
}
|
||||
|
||||
final fillWidth = constraints.maxWidth * ((widget.value ?? 0).clamp(0, 1));
|
||||
final fillWidth = constraints.maxWidth * animatedProgress;
|
||||
final bandWidth = fillWidth == 0 ? 0.0 : (fillWidth * 0.35).clamp(16.0, 40.0);
|
||||
final travelDistance = fillWidth + bandWidth * 2;
|
||||
final durationMs = (travelDistance / _shimmerPixelsPerSecond * 1000)
|
||||
@@ -136,6 +144,7 @@ class _TaskProgressBarState extends State<TaskProgressBar> with SingleTickerProv
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user