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(
title: 'PowerLogger\nDemo',
home: MyHomePage(title: 'PowerLogger Demo'),
//theme: ThemeData.dark(),
theme: ThemeData.dark(),
);
}
}

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

@ -6,6 +6,7 @@ import 'package:power_logger/src/view/dio_error_view.dart';
class DioErrorBuilder extends StatelessWidget {
final DioError data;
final DateTime date;
DioErrorBuilder({Key? key, required this.data, required this.date})
: super(key: key);
@ -21,14 +22,14 @@ class DioErrorBuilder extends StatelessWidget {
),
);
},
title: Text(data.requestOptions.path,style: TextStyle(fontSize: 16,color: Color(0xFF333333)),),
subtitle: Text('${data.message}\n$date',style: TextStyle(fontSize: 14,color: Color(0xFF666666)),),
title: Text(data.requestOptions.path),
subtitle: Text('${data.message}\n$date'),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Chip(
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),
),
),
title: Text(data.requestOptions.path,style: TextStyle(fontSize: 16,color: Color(0xFF333333)),),
subtitle: Text(date.toString(),style: TextStyle(fontSize: 14,color: Color(0xFF666666)),),
title: Text(data.requestOptions.path),
subtitle: Text(date.toString()),
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
Chip(
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) {
return ListTile(
tileColor: Colors.red.withOpacity(0.4),
title: Text(details.exception.toString(),style: TextStyle(fontSize: 14,color: Colors.black),),
trailing: Chip(label: Text('EXCEPTION',style: TextStyle(fontSize: 14,color: Colors.black),), backgroundColor: Colors.red),
title: Text(details.exception.toString()),
trailing: Chip(label: Text('EXCEPTION'), backgroundColor: Colors.red),
onTap: () {
Navigator.push(
context,

@ -1,32 +1,39 @@
import 'package:flutter/material.dart';
import 'package:power_logger/src/theme/custom_theme.dart';
/// UnfocusParser
class UnfocusParser extends StatelessWidget {
final dynamic data;
final String? tag;
const UnfocusParser({Key? key, required this.data, this.tag})
: super(key: key);
@override
Widget build(BuildContext context) {
return Material(
color: Colors.white10,
color: Theme.of(context).brightness == Brightness.light
? Colors.black12
: Colors.white10,
child: ListTile(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Scaffold(
builder: (context) => Theme(
data: CustomTheme.instance.customTheme ?? Theme.of(context),
child: Scaffold(
appBar: AppBar(title: Text(data.runtimeType.toString())),
body: Text(data.toString(),style: TextStyle(fontSize: 16,color: Colors.black),),
body: Text(data.toString()),
),
),
),
),
title: Text(
data.toString(),
maxLines: 1, style: TextStyle(fontSize: 16,color: Colors.black),
maxLines: 1,
),
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: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/logger_view.dart';
import 'package:power_logger/src/views/settings_view.dart';
@ -16,12 +17,14 @@ class _PowerLoggerViewState extends State<PowerLoggerView> {
PageController _pageController = PageController();
int _currentIndex = 0;
void Function(void Function())? _setState;
@override
Widget build(BuildContext context) {
return Scaffold(
return Theme(
data: CustomTheme.instance.customTheme ?? Theme.of(context),
child: Scaffold(
appBar: AppBar(
title: Text('Logger View'),
backgroundColor: Colors.blue,
actions: [
IconButton(
icon: Icon(Icons.clear_all_rounded),
@ -41,19 +44,16 @@ class _PowerLoggerViewState extends State<PowerLoggerView> {
children: [
LoggerView(),
InfoView(),
SettingsView(),
SettingsView(
stateRefresh: () => setState(() {}),
),
],
),
bottomNavigationBar: StatefulBuilder(
builder: (context, kSetState) {
_setState = kSetState;
return BottomNavigationBar(
backgroundColor: Colors.white,
currentIndex: _currentIndex,
selectedLabelStyle: TextStyle(fontSize: 14),
selectedItemColor: Colors.blue,
unselectedItemColor: Color(0xFF666666),
unselectedLabelStyle: TextStyle(fontSize: 12),
onTap: (index) {
_currentIndex = index;
kSetState(() {});
@ -65,19 +65,20 @@ class _PowerLoggerViewState extends State<PowerLoggerView> {
},
items: [
BottomNavigationBarItem(
icon: Icon(Icons.assessment,color: Color(0xFF666666),),activeIcon: Icon(Icons.assessment,color: Colors.blue,), label: '日志'),
icon: Icon(Icons.assessment), label: 'Log'),
BottomNavigationBarItem(
icon: Icon(Icons.perm_device_information,color: Color(0xFF666666),),activeIcon: Icon(Icons.perm_device_information,color: Colors.blue,),
label: '信息',
icon: Icon(Icons.perm_device_information),
label: 'Info',
),
BottomNavigationBarItem(
icon: Icon(Icons.settings,color: Color(0xFF666666),),activeIcon: Icon(Icons.settings,color: Colors.blue,),
label: '设置',
icon: Icon(Icons.settings),
label: 'Settings',
),
],
);
},
),
),
);
}
}

@ -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,
children: [
DefaultTextStyle(
style: TextStyle(fontSize: 16,color: Colors.red),
style: Theme.of(context).textTheme.caption!,
child: title,
),
child == null ? SizedBox() : SizedBox(height: 10),
DefaultTextStyle(
style: TextStyle(fontSize: 15,color: Color(0xFF333333)),
style: Theme.of(context).textTheme.bodyText2!,
child: child ?? SizedBox(),
),
children == null ? SizedBox() : SizedBox(height: 10),

@ -1,6 +1,7 @@
import 'package:dio/dio.dart';
import 'package:flutter/foundation.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/table_view.dart';
import 'package:power_logger/src/view/title_view.dart';
@ -66,7 +67,9 @@ class _DioErrorViewState extends State<DioErrorView> {
@override
Widget build(BuildContext context) {
return Scaffold(
return Theme(
data: CustomTheme.instance.customTheme ?? Theme.of(context),
child: Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).brightness == Brightness.light
? Colors.red[100]
@ -94,6 +97,7 @@ class _DioErrorViewState extends State<DioErrorView> {
_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:power_logger/external_lib/pretty_json.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/table_view.dart';
import 'package:power_logger/src/view/title_view.dart';
@ -79,8 +80,9 @@ class _DioResponseViewState extends State<DioResponseView> {
child: HighlightView(
widget.data!.data,
language: _dioParser.highlight,
theme: atomOneLightTheme
,
theme: Theme.of(context).brightness == Brightness.light
? atomOneLightTheme
: atomOneDarkTheme,
),
);
case ContentType.JSON:
@ -149,7 +151,9 @@ class _DioResponseViewState extends State<DioResponseView> {
@override
Widget build(BuildContext context) {
return Scaffold(
return Theme(
data: CustomTheme.instance.customTheme ?? Theme.of(context),
child: Scaffold(
appBar: AppBar(
backgroundColor: Colors.green[600],
title: Text(widget.data!.requestOptions.path),
@ -191,6 +195,7 @@ class _DioResponseViewState extends State<DioResponseView> {
),
],
),
),
);
}
}

@ -1,7 +1,9 @@
import 'package:flutter/material.dart';
import 'package:power_logger/src/theme/custom_theme.dart';
class FlutterErrorView extends StatefulWidget {
final FlutterErrorDetails details;
FlutterErrorView({Key? key, required this.details}) : super(key: key);
@override
@ -22,7 +24,9 @@ class _FlutterErrorViewState extends State<FlutterErrorView> {
@override
Widget build(BuildContext context) {
return Scaffold(
return Theme(
data: CustomTheme.instance.customTheme ?? Theme.of(context),
child: Scaffold(
appBar: AppBar(
title: Text('Flutter Error'),
),
@ -52,6 +56,7 @@ class _FlutterErrorViewState extends State<FlutterErrorView> {
),
],
),
),
);
}
}

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

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

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

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

@ -1,8 +1,10 @@
import 'package:flutter/material.dart';
import 'package:power_logger/power_logger.dart';
import 'package:power_logger/src/theme/custom_theme.dart';
class SettingsView extends StatefulWidget {
SettingsView({Key? key}) : super(key: key);
final VoidCallback stateRefresh;
SettingsView({Key? key, required this.stateRefresh}) : super(key: key);
@override
_SettingsViewState createState() => _SettingsViewState();
@ -14,9 +16,7 @@ class _SettingsViewState extends State<SettingsView> {
return ListView(
children: [
SwitchListTile(
inactiveThumbColor: Colors.white,
inactiveTrackColor: Color(0xFF999999),
title: Text('终端日志',style: TextStyle(fontSize: 16,color: Colors.black),),
title: Text('终端日志'),
subtitle: Text(''),
value: LoggerData.markLogger,
onChanged: (state) {
@ -24,6 +24,15 @@ class _SettingsViewState extends State<SettingsView> {
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) {
return Container(
decoration: BoxDecoration(
color: Colors.blue,
color: Theme.of(context).colorScheme.secondary,
borderRadius: BorderRadius.circular(25),
boxShadow: [
BoxShadow(

Loading…
Cancel
Save