Compare commits

...

2 Commits

Author SHA1 Message Date
张萌 b208dfd21f Merge branch 'master' of https://git.oa00.com/flutter_pub/power_logger
3 years ago
张萌 068d931471 增加 跟随系统主题选项
3 years ago

@ -17,7 +17,7 @@ class MyApp extends StatelessWidget {
return MaterialApp( return MaterialApp(
title: 'PowerLogger\nDemo', title: 'PowerLogger\nDemo',
home: MyHomePage(title: 'PowerLogger Demo'), home: MyHomePage(title: 'PowerLogger Demo'),
//theme: ThemeData.dark(), theme: ThemeData.dark(),
); );
} }
} }

@ -5,121 +5,121 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.6.1" version: "2.7.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
name: cupertino_icons name: cupertino_icons
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.3"
device_info_plus: device_info_plus:
dependency: transitive dependency: transitive
description: description:
name: device_info_plus name: device_info_plus
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.1.0"
device_info_plus_linux: device_info_plus_linux:
dependency: transitive dependency: transitive
description: description:
name: device_info_plus_linux name: device_info_plus_linux
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0"
device_info_plus_macos: device_info_plus_macos:
dependency: transitive dependency: transitive
description: description:
name: device_info_plus_macos name: device_info_plus_macos
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0"
device_info_plus_platform_interface: device_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: device_info_plus_platform_interface name: device_info_plus_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0"
device_info_plus_web: device_info_plus_web:
dependency: transitive dependency: transitive
description: description:
name: device_info_plus_web name: device_info_plus_web
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0"
device_info_plus_windows: device_info_plus_windows:
dependency: transitive dependency: transitive
description: description:
name: device_info_plus_windows name: device_info_plus_windows
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.1.0"
dio: dio:
dependency: "direct main" dependency: "direct main"
description: description:
name: dio name: dio
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
name: ffi name: ffi
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.1.2"
file: file:
dependency: transitive dependency: transitive
description: description:
name: file name: file
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "6.1.0" version: "6.1.2"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
@ -129,7 +129,7 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: flutter_highlight name: flutter_highlight
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.7.0" version: "0.7.0"
flutter_test: flutter_test:
@ -146,121 +146,121 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: get name: get
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.1.4" version: "4.3.8"
highlight: highlight:
dependency: transitive dependency: transitive
description: description:
name: highlight name: highlight
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.7.0" version: "0.7.0"
http: http:
dependency: transitive dependency: transitive
description: description:
name: http name: http
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.13.1" version: "0.13.3"
http_parser: http_parser:
dependency: transitive dependency: transitive
description: description:
name: http_parser name: http_parser
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
js: js:
dependency: transitive dependency: transitive
description: description:
name: js name: js
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.3" version: "0.6.3"
logger: logger:
dependency: transitive dependency: transitive
description: description:
name: logger name: logger
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.1.0"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.10" version: "0.12.10"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.4.0"
package_info_plus: package_info_plus:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus name: package_info_plus
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.3" version: "1.0.6"
package_info_plus_linux: package_info_plus_linux:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_linux name: package_info_plus_linux
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.3"
package_info_plus_macos: package_info_plus_macos:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_macos name: package_info_plus_macos
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.1"
package_info_plus_platform_interface: package_info_plus_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_platform_interface name: package_info_plus_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.2"
package_info_plus_web: package_info_plus_web:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_web name: package_info_plus_web
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.4"
package_info_plus_windows: package_info_plus_windows:
dependency: transitive dependency: transitive
description: description:
name: package_info_plus_windows name: package_info_plus_windows
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.3"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
pedantic: pedantic:
dependency: transitive dependency: transitive
description: description:
name: pedantic name: pedantic
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.11.0" version: "1.11.1"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.1"
power_logger: power_logger:
dependency: "direct main" dependency: "direct main"
description: description:
@ -277,65 +277,65 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.1"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.0" version: "0.4.1"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
win32: win32:
dependency: transitive dependency: transitive
description: description:
name: win32 name: win32
url: "https://pub.flutter-io.cn" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.5" version: "2.2.9"
sdks: sdks:
dart: ">=2.12.0 <3.0.0" dart: ">=2.13.0 <3.0.0"
flutter: ">=1.20.0" flutter: ">=1.20.0"

@ -6,6 +6,7 @@ import 'package:power_logger/src/view/dio_error_view.dart';
class DioErrorBuilder extends StatelessWidget { class DioErrorBuilder extends StatelessWidget {
final DioError data; final DioError data;
final DateTime date; final DateTime date;
DioErrorBuilder({Key? key, required this.data, required this.date}) DioErrorBuilder({Key? key, required this.data, required this.date})
: super(key: key); : super(key: key);
@ -21,14 +22,14 @@ class DioErrorBuilder extends StatelessWidget {
), ),
); );
}, },
title: Text(data.requestOptions.path,style: TextStyle(fontSize: 16,color: Color(0xFF333333)),), title: Text(data.requestOptions.path),
subtitle: Text('${data.message}\n$date',style: TextStyle(fontSize: 14,color: Color(0xFF666666)),), subtitle: Text('${data.message}\n$date'),
trailing: Row( trailing: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Chip( Chip(
backgroundColor: Colors.blue.withOpacity(0.4), backgroundColor: Colors.blue.withOpacity(0.4),
label: Text(data.requestOptions.method,style: TextStyle(fontSize: 14,color: Colors.black),), label: Text(data.requestOptions.method),
), ),
], ],
), ),

@ -18,14 +18,14 @@ class DioResponseBuilder extends StatelessWidget {
builder: (context) => DioResponseView(data: data), builder: (context) => DioResponseView(data: data),
), ),
), ),
title: Text(data.requestOptions.path,style: TextStyle(fontSize: 16,color: Color(0xFF333333)),), title: Text(data.requestOptions.path),
subtitle: Text(date.toString(),style: TextStyle(fontSize: 14,color: Color(0xFF666666)),), subtitle: Text(date.toString()),
trailing: Row( trailing: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
Chip( Chip(
backgroundColor: Colors.blue.withOpacity(0.8), backgroundColor: Colors.blue.withOpacity(0.8),
label: Text(data.requestOptions.method,style: TextStyle(fontSize: 14,color: Colors.black),), label: Text(data.requestOptions.method),
), ),
], ],
), ),

@ -9,8 +9,8 @@ class FlutterErrorBuilder extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListTile( return ListTile(
tileColor: Colors.red.withOpacity(0.4), tileColor: Colors.red.withOpacity(0.4),
title: Text(details.exception.toString(),style: TextStyle(fontSize: 14,color: Colors.black),), title: Text(details.exception.toString()),
trailing: Chip(label: Text('EXCEPTION',style: TextStyle(fontSize: 14,color: Colors.black),), backgroundColor: Colors.red), trailing: Chip(label: Text('EXCEPTION'), backgroundColor: Colors.red),
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,

@ -1,32 +1,39 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:power_logger/src/theme/custom_theme.dart';
/// UnfocusParser /// UnfocusParser
class UnfocusParser extends StatelessWidget { class UnfocusParser extends StatelessWidget {
final dynamic data; final dynamic data;
final String? tag; final String? tag;
const UnfocusParser({Key? key, required this.data, this.tag}) const UnfocusParser({Key? key, required this.data, this.tag})
: super(key: key); : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Material( return Material(
color: Colors.white10, color: Theme.of(context).brightness == Brightness.light
? Colors.black12
: Colors.white10,
child: ListTile( child: ListTile(
onTap: () => Navigator.push( onTap: () => Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => Scaffold( builder: (context) => Theme(
appBar: AppBar(title: Text(data.runtimeType.toString())), data: CustomTheme.instance.customTheme ?? Theme.of(context),
body: Text(data.toString(),style: TextStyle(fontSize: 16,color: Colors.black),), child: Scaffold(
appBar: AppBar(title: Text(data.runtimeType.toString())),
body: Text(data.toString()),
),
), ),
), ),
), ),
title: Text( title: Text(
data.toString(), data.toString(),
maxLines: 1, style: TextStyle(fontSize: 16,color: Colors.black), maxLines: 1,
), ),
trailing: Chip( trailing: Chip(
label: Text(tag ?? data.runtimeType.toString(),style: TextStyle(fontSize: 16,color: Colors.black),), label: Text(tag ?? data.runtimeType.toString()),
), ),
), ),
); );

@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:power_logger/power_logger.dart'; import 'package:power_logger/power_logger.dart';
import 'package:power_logger/src/theme/custom_theme.dart';
import 'package:power_logger/src/views/info_view.dart'; import 'package:power_logger/src/views/info_view.dart';
import 'package:power_logger/src/views/logger_view.dart'; import 'package:power_logger/src/views/logger_view.dart';
import 'package:power_logger/src/views/settings_view.dart'; import 'package:power_logger/src/views/settings_view.dart';
@ -16,67 +17,67 @@ class _PowerLoggerViewState extends State<PowerLoggerView> {
PageController _pageController = PageController(); PageController _pageController = PageController();
int _currentIndex = 0; int _currentIndex = 0;
void Function(void Function())? _setState; void Function(void Function())? _setState;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Theme(
appBar: AppBar( data: CustomTheme.instance.customTheme ?? Theme.of(context),
title: Text('Logger View'), child: Scaffold(
backgroundColor: Colors.blue, appBar: AppBar(
actions: [ title: Text('Logger View'),
IconButton( actions: [
icon: Icon(Icons.clear_all_rounded), IconButton(
onPressed: () { icon: Icon(Icons.clear_all_rounded),
LoggerData.clear(); onPressed: () {
setState(() {}); LoggerData.clear();
}, setState(() {});
), },
], ),
), ],
body: PageView( ),
controller: _pageController, body: PageView(
onPageChanged: (index) { controller: _pageController,
_currentIndex = index; onPageChanged: (index) {
if (_setState != null) _setState!(() {}); _currentIndex = index;
}, if (_setState != null) _setState!(() {});
children: [ },
LoggerView(), children: [
InfoView(), LoggerView(),
SettingsView(), InfoView(),
], SettingsView(
), stateRefresh: () => setState(() {}),
bottomNavigationBar: StatefulBuilder( ),
builder: (context, kSetState) { ],
_setState = kSetState; ),
return BottomNavigationBar( bottomNavigationBar: StatefulBuilder(
backgroundColor: Colors.white, builder: (context, kSetState) {
currentIndex: _currentIndex, _setState = kSetState;
selectedLabelStyle: TextStyle(fontSize: 14), return BottomNavigationBar(
selectedItemColor: Colors.blue, currentIndex: _currentIndex,
unselectedItemColor: Color(0xFF666666), onTap: (index) {
unselectedLabelStyle: TextStyle(fontSize: 12), _currentIndex = index;
onTap: (index) { kSetState(() {});
_currentIndex = index; _pageController.animateToPage(
kSetState(() {}); index,
_pageController.animateToPage( duration: Duration(milliseconds: 300),
index, curve: Curves.easeInOutCubic,
duration: Duration(milliseconds: 300), );
curve: Curves.easeInOutCubic, },
); items: [
}, BottomNavigationBarItem(
items: [ icon: Icon(Icons.assessment), label: 'Log'),
BottomNavigationBarItem( BottomNavigationBarItem(
icon: Icon(Icons.assessment,color: Color(0xFF666666),),activeIcon: Icon(Icons.assessment,color: Colors.blue,), label: '日志'), icon: Icon(Icons.perm_device_information),
BottomNavigationBarItem( label: 'Info',
icon: Icon(Icons.perm_device_information,color: Color(0xFF666666),),activeIcon: Icon(Icons.perm_device_information,color: Colors.blue,), ),
label: '信息', BottomNavigationBarItem(
), icon: Icon(Icons.settings),
BottomNavigationBarItem( label: 'Settings',
icon: Icon(Icons.settings,color: Color(0xFF666666),),activeIcon: Icon(Icons.settings,color: Colors.blue,), ),
label: '设置', ],
), );
], },
); ),
},
), ),
); );
} }

@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
class CustomTheme {
factory CustomTheme() => _instance;
static CustomTheme get instance => _instance;
static late CustomTheme _instance = CustomTheme._();
CustomTheme._() {
follow = true;
}
ThemeData? customTheme;
late bool follow;
void setThemeData(bool state) {
follow = state;
if (follow) {
customTheme = null;
} else {
customTheme = ThemeData.light();
}
}
}

@ -21,12 +21,12 @@ class BoxView extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
DefaultTextStyle( DefaultTextStyle(
style: TextStyle(fontSize: 16,color: Colors.red), style: Theme.of(context).textTheme.caption!,
child: title, child: title,
), ),
child == null ? SizedBox() : SizedBox(height: 10), child == null ? SizedBox() : SizedBox(height: 10),
DefaultTextStyle( DefaultTextStyle(
style: TextStyle(fontSize: 15,color: Color(0xFF333333)), style: Theme.of(context).textTheme.bodyText2!,
child: child ?? SizedBox(), child: child ?? SizedBox(),
), ),
children == null ? SizedBox() : SizedBox(height: 10), children == null ? SizedBox() : SizedBox(height: 10),

@ -1,6 +1,7 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:power_logger/src/theme/custom_theme.dart';
import 'package:power_logger/src/view/box_view.dart'; import 'package:power_logger/src/view/box_view.dart';
import 'package:power_logger/src/view/table_view.dart'; import 'package:power_logger/src/view/table_view.dart';
import 'package:power_logger/src/view/title_view.dart'; import 'package:power_logger/src/view/title_view.dart';
@ -66,33 +67,36 @@ class _DioErrorViewState extends State<DioErrorView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Theme(
appBar: AppBar( data: CustomTheme.instance.customTheme ?? Theme.of(context),
backgroundColor: Theme.of(context).brightness == Brightness.light child: Scaffold(
? Colors.red[100] appBar: AppBar(
: Colors.red[900], backgroundColor: Theme.of(context).brightness == Brightness.light
title: Text(widget.data.requestOptions.path), ? Colors.red[100]
actions: [ : Colors.red[900],
Chip( title: Text(widget.data.requestOptions.path),
label: Text(widget.data.requestOptions.method), actions: [
backgroundColor: Colors.lightGreen.withOpacity(0.5), Chip(
), label: Text(widget.data.requestOptions.method),
SizedBox(width: 8), backgroundColor: Colors.lightGreen.withOpacity(0.5),
], ),
), SizedBox(width: 8),
body: ListView( ],
padding: EdgeInsets.symmetric(vertical: 20), ),
children: [ body: ListView(
TitleView(title: Text('Request')), padding: EdgeInsets.symmetric(vertical: 20),
_buildBaseURL(), children: [
_buildPath(), TitleView(title: Text('Request')),
_buildMessage(), _buildBaseURL(),
_buildMap(_request.headers), _buildPath(),
_buildMap(_request.queryParameters), _buildMessage(),
_buildMap(_request.data), _buildMap(_request.headers),
TitleView(title: Text('Response')), _buildMap(_request.queryParameters),
_buildStatus(), _buildMap(_request.data),
], TitleView(title: Text('Response')),
_buildStatus(),
],
),
), ),
); );
} }

@ -7,6 +7,7 @@ import 'package:flutter_highlight/themes/atom-one-dark.dart';
import 'package:flutter_highlight/themes/atom-one-light.dart'; import 'package:flutter_highlight/themes/atom-one-light.dart';
import 'package:power_logger/external_lib/pretty_json.dart'; import 'package:power_logger/external_lib/pretty_json.dart';
import 'package:power_logger/src/parser/dio_parser/dio_parser.dart'; import 'package:power_logger/src/parser/dio_parser/dio_parser.dart';
import 'package:power_logger/src/theme/custom_theme.dart';
import 'package:power_logger/src/view/box_view.dart'; import 'package:power_logger/src/view/box_view.dart';
import 'package:power_logger/src/view/table_view.dart'; import 'package:power_logger/src/view/table_view.dart';
import 'package:power_logger/src/view/title_view.dart'; import 'package:power_logger/src/view/title_view.dart';
@ -79,8 +80,9 @@ class _DioResponseViewState extends State<DioResponseView> {
child: HighlightView( child: HighlightView(
widget.data!.data, widget.data!.data,
language: _dioParser.highlight, language: _dioParser.highlight,
theme: atomOneLightTheme theme: Theme.of(context).brightness == Brightness.light
, ? atomOneLightTheme
: atomOneDarkTheme,
), ),
); );
case ContentType.JSON: case ContentType.JSON:
@ -149,47 +151,50 @@ class _DioResponseViewState extends State<DioResponseView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Theme(
appBar: AppBar( data: CustomTheme.instance.customTheme ?? Theme.of(context),
backgroundColor: Colors.green[600], child: Scaffold(
title: Text(widget.data!.requestOptions.path), appBar: AppBar(
actions: [ backgroundColor: Colors.green[600],
Chip( title: Text(widget.data!.requestOptions.path),
label: Text(widget.data!.requestOptions.method), actions: [
backgroundColor: Colors.lightGreen, Chip(
), label: Text(widget.data!.requestOptions.method),
SizedBox(width: 8), backgroundColor: Colors.lightGreen,
], ),
), SizedBox(width: 8),
body: ListView( ],
padding: EdgeInsets.symmetric(vertical: 20), ),
children: [ body: ListView(
TitleView(title: Text('Request')), padding: EdgeInsets.symmetric(vertical: 20),
_buildBaseURL(), children: [
_buildPath(), TitleView(title: Text('Request')),
_buildMap(_request.headers), _buildBaseURL(),
_buildMap(_request.queryParameters), _buildPath(),
_buildMap(_request.data), _buildMap(_request.headers),
TitleView(title: Text('Response')), _buildMap(_request.queryParameters),
_buildMap(widget.data!.headers.map), _buildMap(_request.data),
_buildStatus(), TitleView(title: Text('Response')),
SwitchListTile( _buildMap(widget.data!.headers.map),
value: _showRawData, _buildStatus(),
title: Text('RawData'), SwitchListTile(
onChanged: (state) => setState(() => _showRawData = state), value: _showRawData,
), title: Text('RawData'),
AnimatedCrossFade( onChanged: (state) => setState(() => _showRawData = state),
firstChild: _buildRawData(), ),
secondChild: _buildData(), AnimatedCrossFade(
crossFadeState: _showRawData firstChild: _buildRawData(),
? CrossFadeState.showFirst secondChild: _buildData(),
: CrossFadeState.showSecond, crossFadeState: _showRawData
duration: Duration(milliseconds: 500), ? CrossFadeState.showFirst
firstCurve: Curves.easeInOutCubic, : CrossFadeState.showSecond,
secondCurve: Curves.easeInOutCubic, duration: Duration(milliseconds: 500),
sizeCurve: Curves.easeInOutCubic, firstCurve: Curves.easeInOutCubic,
), secondCurve: Curves.easeInOutCubic,
], sizeCurve: Curves.easeInOutCubic,
),
],
),
), ),
); );
} }

@ -1,7 +1,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:power_logger/src/theme/custom_theme.dart';
class FlutterErrorView extends StatefulWidget { class FlutterErrorView extends StatefulWidget {
final FlutterErrorDetails details; final FlutterErrorDetails details;
FlutterErrorView({Key? key, required this.details}) : super(key: key); FlutterErrorView({Key? key, required this.details}) : super(key: key);
@override @override
@ -22,35 +24,38 @@ class _FlutterErrorViewState extends State<FlutterErrorView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Theme(
appBar: AppBar( data: CustomTheme.instance.customTheme ?? Theme.of(context),
title: Text('Flutter Error'), child: Scaffold(
), appBar: AppBar(
body: Column( title: Text('Flutter Error'),
children: [ ),
Card( body: Column(
margin: EdgeInsets.all(10), children: [
child: Padding( Card(
padding: EdgeInsets.all(10), margin: EdgeInsets.all(10),
child: SelectableText( child: Padding(
exceptionValue, padding: EdgeInsets.all(10),
style: TextStyle( child: SelectableText(
fontSize: 22, exceptionValue,
style: TextStyle(
fontSize: 22,
),
), ),
), ),
), ),
), Expanded(
Expanded( child: ListView.separated(
child: ListView.separated( padding: EdgeInsets.all(10),
padding: EdgeInsets.all(10), itemBuilder: (context, index) {
itemBuilder: (context, index) { return Text(_stringList[index]);
return Text(_stringList[index]); },
}, separatorBuilder: (context, index) => SizedBox(height: 5),
separatorBuilder: (context, index) => SizedBox(height: 5), itemCount: _stringList.length,
itemCount: _stringList.length, ),
), ),
), ],
], ),
), ),
); );
} }

@ -9,7 +9,7 @@ class TitleView extends StatelessWidget {
return Padding( return Padding(
padding: EdgeInsets.symmetric(horizontal: 5, vertical: 10), padding: EdgeInsets.symmetric(horizontal: 5, vertical: 10),
child: DefaultTextStyle( child: DefaultTextStyle(
style: TextStyle(fontSize: 26,color: Color(0xFF666666)), style: Theme.of(context).textTheme.headline4!,
child: title, child: title,
), ),
); );

@ -71,8 +71,8 @@ class _InfoViewState extends State<InfoView>
SliverList( SliverList(
delegate: SliverChildListDelegate([ delegate: SliverChildListDelegate([
ListTile( ListTile(
title: Text('Package Info',style: TextStyle(fontSize: 18,color: Color(0xff333333))), title: Text('Package Info'),
tileColor: Colors.blue.withOpacity(0.2), tileColor: Theme.of(context).accentColor.withOpacity(0.2),
), ),
InfoTile(title: 'appName', subTitle: packageInfo!.appName), InfoTile(title: 'appName', subTitle: packageInfo!.appName),
InfoTile( InfoTile(
@ -81,8 +81,8 @@ class _InfoViewState extends State<InfoView>
title: 'packageName', subTitle: packageInfo!.packageName), title: 'packageName', subTitle: packageInfo!.packageName),
InfoTile(title: 'version', subTitle: packageInfo!.version), InfoTile(title: 'version', subTitle: packageInfo!.version),
ListTile( ListTile(
title: Text('Device Info',style: TextStyle(fontSize: 18,color: Color(0xff333333))), title: Text('Device Info'),
tileColor: Colors.blue.withOpacity(0.1), tileColor: Theme.of(context).accentColor.withOpacity(0.1),
), ),
])), ])),
_buildView(), _buildView(),

@ -4,6 +4,7 @@ import 'package:power_logger/src/views/platform_specific/info_tile.dart';
class AndroidView extends StatelessWidget { class AndroidView extends StatelessWidget {
final AndroidDeviceInfo? androidInfo; final AndroidDeviceInfo? androidInfo;
AndroidView({Key? key, required this.androidInfo}) : super(key: key); AndroidView({Key? key, required this.androidInfo}) : super(key: key);
@override @override

@ -15,8 +15,8 @@ class InfoTile extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListTile( return ListTile(
title: Text(title,style: TextStyle(fontSize: 14,color: Color(0xff333333)),), title: Text(title),
subtitle: Text(subTitle,style: TextStyle(fontSize: 14,color: Color(0xff666666))), subtitle: Text(subTitle),
onLongPress: () async { onLongPress: () async {
ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of(context).hideCurrentSnackBar();
Clipboard.setData(ClipboardData(text: subTitle)); Clipboard.setData(ClipboardData(text: subTitle));

@ -1,8 +1,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:power_logger/power_logger.dart'; import 'package:power_logger/power_logger.dart';
import 'package:power_logger/src/theme/custom_theme.dart';
class SettingsView extends StatefulWidget { class SettingsView extends StatefulWidget {
SettingsView({Key? key}) : super(key: key); final VoidCallback stateRefresh;
SettingsView({Key? key, required this.stateRefresh}) : super(key: key);
@override @override
_SettingsViewState createState() => _SettingsViewState(); _SettingsViewState createState() => _SettingsViewState();
@ -14,9 +16,7 @@ class _SettingsViewState extends State<SettingsView> {
return ListView( return ListView(
children: [ children: [
SwitchListTile( SwitchListTile(
inactiveThumbColor: Colors.white, title: Text('终端日志'),
inactiveTrackColor: Color(0xFF999999),
title: Text('终端日志',style: TextStyle(fontSize: 16,color: Colors.black),),
subtitle: Text(''), subtitle: Text(''),
value: LoggerData.markLogger, value: LoggerData.markLogger,
onChanged: (state) { onChanged: (state) {
@ -24,6 +24,15 @@ class _SettingsViewState extends State<SettingsView> {
setState(() {}); setState(() {});
}, },
), ),
SwitchListTile(
title: Text(CustomTheme.instance.follow ? '跟随系统' : 'Light'),
subtitle: Text(''),
value: CustomTheme.instance.follow,
onChanged: (state) {
CustomTheme.instance.setThemeData(state);
widget.stateRefresh();
},
),
], ],
); );
} }

@ -105,7 +105,7 @@ class _FabButton extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.blue, color: Theme.of(context).colorScheme.secondary,
borderRadius: BorderRadius.circular(25), borderRadius: BorderRadius.circular(25),
boxShadow: [ boxShadow: [
BoxShadow( BoxShadow(

Loading…
Cancel
Save