fix: click blank to show fab

This commit is contained in:
lollipopkit
2024-05-10 21:46:05 +08:00
parent 5bc28a0560
commit 6b5f98cb2d
2 changed files with 29 additions and 12 deletions

View File

@@ -6,19 +6,21 @@ final class AutoHide extends StatefulWidget {
final Widget child;
final ScrollController controller;
final AxisDirection direction;
final double offset;
const AutoHide({
super.key,
required this.child,
required this.controller,
required this.direction,
this.offset = 55,
});
@override
State<AutoHide> createState() => _AutoHideState();
State<AutoHide> createState() => AutoHideState();
}
final class _AutoHideState extends State<AutoHide> {
final class AutoHideState extends State<AutoHide> {
bool _visible = true;
bool _isScrolling = false;
Timer? _timer;
@@ -38,6 +40,15 @@ final class _AutoHideState extends State<AutoHide> {
super.dispose();
}
void show() {
debugPrint('show');
if (_visible) return;
setState(() {
_visible = true;
});
_setupTimer();
}
void _setupTimer() {
_timer?.cancel();
_timer = Timer.periodic(const Duration(seconds: 3), (_) {
@@ -84,19 +95,19 @@ final class _AutoHideState extends State<AutoHide> {
case AxisDirection.down:
return _visible
? Matrix4.identity()
: Matrix4.translationValues(0, 55, 0);
: Matrix4.translationValues(0, widget.offset, 0);
case AxisDirection.up:
return _visible
? Matrix4.identity()
: Matrix4.translationValues(0, -55, 0);
: Matrix4.translationValues(0, -widget.offset, 0);
case AxisDirection.left:
return _visible
? Matrix4.identity()
: Matrix4.translationValues(-55, 0, 0);
: Matrix4.translationValues(-widget.offset, 0, 0);
case AxisDirection.right:
return _visible
? Matrix4.identity()
: Matrix4.translationValues(55, 0, 0);
: Matrix4.translationValues(widget.offset, 0, 0);
}
}
}