update fab position and hide fab button when page open

master
小赖 4 years ago
parent 1469b68b32
commit 17a42b57c6

@ -34,6 +34,8 @@ class _LoggerFABState extends State<LoggerFAB> {
double get screenWidth => MediaQuery.of(context).size.width;
double get screenHeight => MediaQuery.of(context).size.height;
bool _moving = false;
bool showSubPage = false;
@override
Widget build(BuildContext context) {
return AnimatedPositioned(
@ -41,6 +43,10 @@ class _LoggerFABState extends State<LoggerFAB> {
duration: _moving ? Duration.zero : Duration(milliseconds: 300),
left: _x - 25,
top: _y - 25,
child: AnimatedOpacity(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOutCubic,
opacity: showSubPage ? 0 : 1,
child: GestureDetector(
onPanStart: (detail) {
_moving = true;
@ -56,17 +62,23 @@ class _LoggerFABState extends State<LoggerFAB> {
_x = 50;
} else
_x = screenWidth - 50;
if ((_y < screenHeight / 2)) {
_y = 70;
} else
if (_y > screenHeight - 50) {
_y = screenHeight - 50;
} else if (_y < 50) _y = 50;
_moving = false;
setState(() {});
},
onTap: () => Navigator.push(
onTap: showSubPage
? null
: () async {
showSubPage = true;
await Navigator.push(
context,
MaterialPageRoute(builder: (context) => PowerLoggerView()),
),
);
showSubPage = false;
},
child: ClipOval(
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 5, sigmaY: 5),
@ -85,6 +97,7 @@ class _LoggerFABState extends State<LoggerFAB> {
),
),
),
),
);
}
}

Loading…
Cancel
Save