mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
fix: click blank to show fab
This commit is contained in:
@@ -57,6 +57,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
bool _useDoubleColumn = false;
|
||||
|
||||
final _scrollController = ScrollController();
|
||||
final _autoHideKey = GlobalKey<AutoHideState>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -97,14 +98,19 @@ class _ServerPageState extends State<ServerPage>
|
||||
Widget _buildPortrait() {
|
||||
return Scaffold(
|
||||
appBar: _buildTagsSwitcher(Pros.server),
|
||||
body: ListenableBuilder(
|
||||
listenable: Stores.setting.textFactor.listenable(),
|
||||
builder: (_, __) {
|
||||
_updateTextScaler();
|
||||
return _buildBody();
|
||||
},
|
||||
body: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => _autoHideKey.currentState?.show(),
|
||||
child: ListenableBuilder(
|
||||
listenable: Stores.setting.textFactor.listenable(),
|
||||
builder: (_, __) {
|
||||
_updateTextScaler();
|
||||
return _buildBody();
|
||||
},
|
||||
),
|
||||
),
|
||||
floatingActionButton: AutoHide(
|
||||
key: _autoHideKey,
|
||||
direction: AxisDirection.right,
|
||||
controller: _scrollController,
|
||||
child: FloatingActionButton(
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user