logger view add extra page

hmxc
小赖 4 years ago
parent 859824680f
commit fd0a549296

@ -1,6 +1,7 @@
import 'package:akuCommunity/extensions/num_ext.dart'; import 'package:akuCommunity/extensions/num_ext.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class LoggerDioErr extends StatelessWidget { class LoggerDioErr extends StatelessWidget {
@ -13,7 +14,7 @@ class LoggerDioErr extends StatelessWidget {
elevation: 10, elevation: 10,
highlightElevation: 1, highlightElevation: 1,
color: Colors.red[100], color: Colors.red[100],
onPressed: () {}, onPressed: () => Get.to(_LoggerErrDetail(error: error)),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -39,3 +40,22 @@ class LoggerDioErr extends StatelessWidget {
); );
} }
} }
class _LoggerErrDetail extends StatefulWidget {
final DioError error;
_LoggerErrDetail({Key key, this.error}) : super(key: key);
@override
__LoggerErrDetailState createState() => __LoggerErrDetailState();
}
class __LoggerErrDetailState extends State<_LoggerErrDetail> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: widget.error.request.path.text.make(),
),
);
}
}

@ -1,6 +1,7 @@
import 'package:akuCommunity/extensions/num_ext.dart'; import 'package:akuCommunity/extensions/num_ext.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart' hide Response;
import 'package:velocity_x/velocity_x.dart'; import 'package:velocity_x/velocity_x.dart';
class LoggerDioSuccess extends StatelessWidget { class LoggerDioSuccess extends StatelessWidget {
@ -10,10 +11,9 @@ class LoggerDioSuccess extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialButton( return MaterialButton(
elevation: 10, elevation: 0,
highlightElevation: 1,
color: Colors.white, color: Colors.white,
onPressed: () {}, onPressed: () => Get.to(_LoggerSuccessDetail(response: response)),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -38,3 +38,50 @@ class LoggerDioSuccess extends StatelessWidget {
); );
} }
} }
class _LoggerSuccessDetail extends StatefulWidget {
final Response response;
_LoggerSuccessDetail({Key key, this.response}) : super(key: key);
@override
__LoggerSuccessDetailState createState() => __LoggerSuccessDetailState();
}
class __LoggerSuccessDetailState extends State<_LoggerSuccessDetail> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: widget.response.request.path.text.make(),
),
body: ListView(
padding: EdgeInsets.symmetric(horizontal: 10),
children: [
ListTile(
title: 'Request'.text.bold.size(22).make(),
trailing: [
Chip(
label: widget.response.request.method.text.make(),
backgroundColor: Colors.lightGreen,
),
].row(),
),
ListTile(title: 'headers'.text.make()),
widget.response.request?.headers.toString().text.make(),
ListTile(title: 'queryParameters'.text.make()),
(widget.response.request?.queryParameters ?? '')
.toString()
.text
.make(),
ListTile(title: 'data'.text.make()),
(widget.response.request?.data ?? '').toString().text.make(),
ListTile(title: 'Response'.text.bold.size(22).make()),
ListTile(title: 'headers'.text.make()),
widget.response?.headers.toString().text.make(),
ListTile(title: 'data'.text.make()),
(widget.response?.data ?? '').toString().text.make(),
],
),
);
}
}

@ -32,6 +32,7 @@ class _LoggerFABState extends State<LoggerFAB> {
return Stack( return Stack(
children: [ children: [
AnimatedPositioned( AnimatedPositioned(
curve: Curves.easeInOutCubic,
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,
@ -46,10 +47,14 @@ class _LoggerFABState extends State<LoggerFAB> {
}); });
}, },
onPanEnd: (detail) { onPanEnd: (detail) {
if (_x < 100) _x = 50; if ((_x < screenWidth / 2)) {
if (_y < 100) _y = 75; _x = 50;
if (_x > screenWidth - 50) _x = screenWidth - 50; } else
if (_y > screenHeight - 50) _y = screenHeight - 50; _x = screenWidth - 50;
if ((_y < screenHeight / 2)) {
_y = 70;
} else
_y = screenHeight - 50;
_moving = false; _moving = false;
setState(() {}); setState(() {});
}, },

Loading…
Cancel
Save