You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.8 KiB

4 years ago
import 'package:akuCommunity/utils/logger/logger_card.dart';
import 'package:akuCommunity/utils/logger/logger_data.dart';
import 'package:akuCommunity/extensions/page_router.dart';
4 years ago
import 'package:akuCommunity/widget/bee_scaffold.dart';
4 years ago
import 'package:flutter/material.dart';
class LoggerFAB extends StatefulWidget {
static openLogger(BuildContext context) {
Overlay.of(context).insert(OverlayEntry(
builder: (context) {
return LoggerFAB();
},
));
}
LoggerFAB({Key key}) : super(key: key);
@override
_LoggerFABState createState() => _LoggerFABState();
}
class _LoggerFABState extends State<LoggerFAB> {
double _x = 100;
double _y = 100;
double get screenWidth => MediaQuery.of(context).size.width;
double get screenHeight => MediaQuery.of(context).size.height;
bool _moving = false;
@override
Widget build(BuildContext context) {
return Stack(
children: [
AnimatedPositioned(
curve: Curves.easeInOutCubic,
4 years ago
duration: _moving ? Duration.zero : Duration(milliseconds: 300),
left: _x - 25,
top: _y - 25,
child: GestureDetector(
onPanStart: (detail) {
_moving = true;
},
onPanUpdate: (details) {
setState(() {
_x = details.globalPosition.dx;
_y = details.globalPosition.dy;
});
},
onPanEnd: (detail) {
if ((_x < screenWidth / 2)) {
_x = 50;
} else
_x = screenWidth - 50;
if ((_y < screenHeight / 2)) {
_y = 70;
} else
_y = screenHeight - 50;
4 years ago
_moving = false;
setState(() {});
},
onTap: () {
LoggerView().to();
4 years ago
},
child: Container(
decoration: BoxDecoration(
color: Colors.yellowAccent,
borderRadius: BorderRadius.circular(25),
),
height: 50,
width: 50,
child: Icon(Icons.code),
),
),
)
],
);
}
}
class LoggerView extends StatefulWidget {
LoggerView({Key key}) : super(key: key);
init() {}
@override
_LoggerViewState createState() => _LoggerViewState();
}
class _LoggerViewState extends State<LoggerView> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
4 years ago
return BeeScaffold(
title: 'Logger',
actions: [
IconButton(icon: Icon(Icons.list), onPressed: () {}),
],
4 years ago
body: ListView.builder(
itemBuilder: (context, index) =>
LoggerCard(data: LoggerData.data[index]),
itemCount: LoggerData.data.length,
),
);
}
}