fixed sweeper

This commit is contained in:
Thibault Deckers 2020-05-11 11:56:59 +09:00
parent 868c35773c
commit 0ab594f6ab
2 changed files with 10 additions and 5 deletions

View file

@ -138,6 +138,8 @@ class _ThumbnailHighlightOverlayState extends State<ThumbnailHighlightOverlay> {
), ),
), ),
toggledNotifier: _highlightedNotifier, toggledNotifier: _highlightedNotifier,
startAngle: pi * -3 / 4,
centerSweep: false,
onSweepEnd: () => _highlightedNotifier.value = false, onSweepEnd: () => _highlightedNotifier.value = false,
); );
}, },

View file

@ -9,6 +9,7 @@ class Sweeper extends StatefulWidget {
final double sweepAngle; final double sweepAngle;
final Curve curve; final Curve curve;
final ValueNotifier<bool> toggledNotifier; final ValueNotifier<bool> toggledNotifier;
final bool centerSweep;
final VoidCallback onSweepEnd; final VoidCallback onSweepEnd;
const Sweeper({ const Sweeper({
@ -18,6 +19,7 @@ class Sweeper extends StatefulWidget {
this.sweepAngle = pi / 4, this.sweepAngle = pi / 4,
this.curve = Curves.easeInOutCubic, this.curve = Curves.easeInOutCubic,
@required this.toggledNotifier, @required this.toggledNotifier,
this.centerSweep = true,
this.onSweepEnd, this.onSweepEnd,
}) : super(key: key); }) : super(key: key);
@ -42,9 +44,12 @@ class _SweeperState extends State<Sweeper> with SingleTickerProviderStateMixin {
duration: const Duration(milliseconds: sweepingDurationMillis), duration: const Duration(milliseconds: sweepingDurationMillis),
vsync: this, vsync: this,
); );
final startAngle = widget.startAngle;
final sweepAngle = widget.sweepAngle;
final centerSweep = widget.centerSweep;
_angle = Tween( _angle = Tween(
begin: widget.startAngle - widget.sweepAngle / 2, begin: startAngle - sweepAngle * (centerSweep ? .5 : 0),
end: widget.startAngle + pi * 2 - widget.sweepAngle / 2, end: startAngle + pi * 2 - sweepAngle * (centerSweep ? .5 : 1),
).animate(CurvedAnimation( ).animate(CurvedAnimation(
parent: _angleAnimationController, parent: _angleAnimationController,
curve: widget.curve, curve: widget.curve,
@ -109,10 +114,8 @@ class _SweeperState extends State<Sweeper> with SingleTickerProviderStateMixin {
setState(() {}); setState(() {});
await Future.delayed(Duration(milliseconds: (opacityAnimationDurationMillis * timeDilation).toInt())); await Future.delayed(Duration(milliseconds: (opacityAnimationDurationMillis * timeDilation).toInt()));
_isAppearing = false; _isAppearing = false;
_angleAnimationController.forward();
} else {
await Future.delayed(Duration(milliseconds: (opacityAnimationDurationMillis * timeDilation).toInt()));
_angleAnimationController.reset(); _angleAnimationController.reset();
_angleAnimationController.forward();
} }
setState(() {}); setState(() {});
} }