mirror of
https://github.com/Myzel394/quid_faciam_hodie.git
synced 2025-06-19 15:45:26 +02:00
improved camera button animation
This commit is contained in:
parent
833d208041
commit
4c7d55ba62
@ -31,6 +31,7 @@ class _RecordButtonState extends State<RecordButton> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
|
// Take photo
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (widget.disabled) {
|
if (widget.disabled) {
|
||||||
return;
|
return;
|
||||||
@ -49,15 +50,25 @@ class _RecordButtonState extends State<RecordButton> {
|
|||||||
widget.onPhotoShot();
|
widget.onPhotoShot();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLongPressDown: (_) {
|
// Start Video
|
||||||
|
onLongPress: () {
|
||||||
if (widget.disabled) {
|
if (widget.disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
animateToVideoIcon = true;
|
videoInAnimationActive = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
HapticFeedback.heavyImpact();
|
||||||
|
|
||||||
|
if (widget.active) {
|
||||||
|
widget.onVideoEnd();
|
||||||
|
} else {
|
||||||
|
widget.onVideoBegin();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
// Stop Video
|
||||||
onLongPressUp: () {
|
onLongPressUp: () {
|
||||||
if (widget.disabled) {
|
if (widget.disabled) {
|
||||||
return;
|
return;
|
||||||
@ -68,38 +79,43 @@ class _RecordButtonState extends State<RecordButton> {
|
|||||||
animateToVideoIcon = false;
|
animateToVideoIcon = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
HapticFeedback.lightImpact();
|
||||||
|
|
||||||
if (widget.active) {
|
if (widget.active) {
|
||||||
widget.onVideoEnd();
|
widget.onVideoEnd();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onTapCancel: () {
|
// Animate to video icon
|
||||||
setState(() {
|
onTapDown: (_) {
|
||||||
videoInAnimationActive = false;
|
|
||||||
animateToVideoIcon = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onPanCancel: () {
|
|
||||||
setState(() {
|
|
||||||
videoInAnimationActive = false;
|
|
||||||
animateToVideoIcon = false;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
onLongPress: () {
|
|
||||||
if (widget.disabled) {
|
if (widget.disabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HapticFeedback.heavyImpact();
|
setState(() {
|
||||||
|
animateToVideoIcon = true;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// Cancel icon animation
|
||||||
|
onTapCancel: () {
|
||||||
|
if (videoInAnimationActive || animateToVideoIcon) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
videoInAnimationActive = true;
|
videoInAnimationActive = false;
|
||||||
|
animateToVideoIcon = false;
|
||||||
});
|
});
|
||||||
|
},
|
||||||
if (widget.active) {
|
// Cancel icon animation
|
||||||
widget.onVideoEnd();
|
onPanCancel: () {
|
||||||
} else {
|
if (videoInAnimationActive || animateToVideoIcon) {
|
||||||
widget.onVideoBegin();
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setState(() {
|
||||||
|
videoInAnimationActive = false;
|
||||||
|
animateToVideoIcon = false;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
child: Opacity(
|
child: Opacity(
|
||||||
opacity: widget.disabled ? 0.5 : 1.0,
|
opacity: widget.disabled ? 0.5 : 1.0,
|
||||||
@ -134,9 +150,9 @@ class _RecordButtonState extends State<RecordButton> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
AnimatedScale(
|
AnimatedScale(
|
||||||
curve: Curves.easeOutCirc,
|
curve: animateToVideoIcon ? Curves.easeOut : Curves.linear,
|
||||||
duration: animateToVideoIcon
|
duration: animateToVideoIcon
|
||||||
? const Duration(milliseconds: 1000)
|
? const Duration(milliseconds: 250)
|
||||||
: OUT_DURATION,
|
: OUT_DURATION,
|
||||||
scale: videoInAnimationActive ? 1 : .6,
|
scale: videoInAnimationActive ? 1 : .6,
|
||||||
child: const Icon(
|
child: const Icon(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user