diff --git a/lib/pages/tab_navigator.dart b/lib/pages/tab_navigator.dart index 8d4030bb..68c7b7ef 100644 --- a/lib/pages/tab_navigator.dart +++ b/lib/pages/tab_navigator.dart @@ -1,4 +1,4 @@ -import 'package:akuCommunity/utils/logger_view.dart'; +import 'package:akuCommunity/utils/logger/logger_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; diff --git a/lib/utils/logger_card.dart b/lib/utils/logger/logger_card.dart similarity index 55% rename from lib/utils/logger_card.dart rename to lib/utils/logger/logger_card.dart index 366c0e57..2bcbcb7e 100644 --- a/lib/utils/logger_card.dart +++ b/lib/utils/logger/logger_card.dart @@ -1,38 +1,14 @@ +import 'package:akuCommunity/utils/logger/logger_dio_err.dart'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:velocity_x/velocity_x.dart'; class LoggerCard extends StatelessWidget { final dynamic data; const LoggerCard({Key key, this.data}) : super(key: key); Widget _buildDioErr() { DioError error = data; - return VxBox( - child: Column( - children: [ - Row( - children: [ - Spacer(), - Chip( - backgroundColor: Colors.greenAccent, - label: Text(error.request.method), - ), - ], - ), - Text(error.message), - Text(error.request.path), - Text(error.request.method), - ], - ), - ) - .height(200) - .p4 - .red200 - .margin(EdgeInsets.all(5)) - .shadowSm - .make() - .material(color: Colors.transparent); + return LoggerDioErr(error: error); } Widget _buildResponse() { diff --git a/lib/utils/logger_data.dart b/lib/utils/logger/logger_data.dart similarity index 100% rename from lib/utils/logger_data.dart rename to lib/utils/logger/logger_data.dart diff --git a/lib/utils/logger/logger_dio_err.dart b/lib/utils/logger/logger_dio_err.dart new file mode 100644 index 00000000..aa0a3ed4 --- /dev/null +++ b/lib/utils/logger/logger_dio_err.dart @@ -0,0 +1,39 @@ +import 'package:akuCommunity/extensions/num_ext.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class LoggerDioErr extends StatelessWidget { + final DioError error; + const LoggerDioErr({Key key, this.error}) : super(key: key); + + @override + Widget build(BuildContext context) { + return MaterialButton( + elevation: 10, + highlightElevation: 1, + color: Colors.red[100], + onPressed: () {}, + child: Column( + children: [ + Row( + children: [ + 5.wb, + error.request.path.text.bold.make().expand(), + Chip( + backgroundColor: Colors.redAccent, + label: Text(error.response?.statusCode?.toString() ?? 'UNKNOW'), + ), + 5.wb, + Chip( + backgroundColor: Colors.greenAccent, + label: Text(error.request.method), + ), + ], + ), + error.message.text.sm.light.make(), + ], + ), + ); + } +} diff --git a/lib/utils/logger_view.dart b/lib/utils/logger/logger_view.dart similarity index 88% rename from lib/utils/logger_view.dart rename to lib/utils/logger/logger_view.dart index 055eead6..a07bfb0e 100644 --- a/lib/utils/logger_view.dart +++ b/lib/utils/logger/logger_view.dart @@ -1,8 +1,9 @@ -import 'package:akuCommunity/utils/logger_card.dart'; -import 'package:akuCommunity/utils/logger_data.dart'; +import 'package:akuCommunity/utils/logger/logger_card.dart'; +import 'package:akuCommunity/utils/logger/logger_data.dart'; import 'package:akuCommunity/extensions/page_router.dart'; import 'package:flutter/material.dart'; +import 'package:velocity_x/velocity_x.dart'; class LoggerFAB extends StatefulWidget { static openLogger(BuildContext context) { @@ -88,7 +89,12 @@ class _LoggerViewState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(), + appBar: AppBar( + title: 'Logger'.text.make(), + actions: [ + IconButton(icon: Icon(Icons.list), onPressed: () {}), + ], + ), body: ListView.builder( itemBuilder: (context, index) => LoggerCard(data: LoggerData.data[index]), diff --git a/lib/utils/net_util.dart b/lib/utils/net_util.dart index 0e546065..1478cd82 100644 --- a/lib/utils/net_util.dart +++ b/lib/utils/net_util.dart @@ -1,6 +1,6 @@ import 'dart:convert'; -import 'package:akuCommunity/utils/logger_data.dart'; +import 'package:akuCommunity/utils/logger/logger_data.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:dio/dio.dart';