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

Loading…
Cancel
Save