diff --git a/examples/shop_app_example/lib/ui/presentation_frame.dart b/examples/shop_app_example/lib/ui/presentation_frame.dart index f5533db6..5648533c 100644 --- a/examples/shop_app_example/lib/ui/presentation_frame.dart +++ b/examples/shop_app_example/lib/ui/presentation_frame.dart @@ -273,7 +273,8 @@ class _LogsPreview extends StatelessWidget { final data = reversedLogs[index]; return TalkerDataCard( data: data, - color: data.getFlutterColor(talkerTheme), + color: data + .getFlutterColor(talkerTheme.logColors), ); }, childCount: reversedLogs.length, diff --git a/examples/shop_app_example/pubspec.lock b/examples/shop_app_example/pubspec.lock index a523cc92..3ab53f99 100644 --- a/examples/shop_app_example/pubspec.lock +++ b/examples/shop_app_example/pubspec.lock @@ -580,10 +580,10 @@ packages: dependency: transitive description: name: uuid - sha256: "814e9e88f21a176ae1359149021870e87f7cddaf633ab678a5d2b0bff7fd1ba8" + sha256: "83d37c7ad7aaf9aa8e275490669535c8080377cfa7a7004c24dfac53afffaa90" url: "https://pub.dev" source: hosted - version: "4.4.1" + version: "4.4.2" vector_math: dependency: transitive description: diff --git a/packages/talker_flutter/lib/src/controller/talker_view_controller.dart b/packages/talker_flutter/lib/src/controller/talker_view_controller.dart index 863a3e1a..17a22867 100644 --- a/packages/talker_flutter/lib/src/controller/talker_view_controller.dart +++ b/packages/talker_flutter/lib/src/controller/talker_view_controller.dart @@ -7,7 +7,7 @@ import 'package:talker_flutter/talker_flutter.dart'; class TalkerViewController extends ChangeNotifier { BaseTalkerFilter _filter = BaseTalkerFilter(); - var _expandedLogs = true; + var _expandedLogs = false; bool _isLogOrderReversed = true; /// Filter for selecting specific logs and errors diff --git a/packages/talker_flutter/lib/src/extensions/talker_data.dart b/packages/talker_flutter/lib/src/extensions/talker_data.dart index 55ace74a..3ae99583 100644 --- a/packages/talker_flutter/lib/src/extensions/talker_data.dart +++ b/packages/talker_flutter/lib/src/extensions/talker_data.dart @@ -2,11 +2,11 @@ import 'package:flutter/material.dart'; import 'package:talker_flutter/talker_flutter.dart'; extension TalkerDataFlutterExt on TalkerData { - Color getFlutterColor(TalkerScreenTheme theme) { + Color getFlutterColor(LogColors colors) { final key = this.key; if (key == null) return Colors.grey; final type = TalkerLogType.fromKey(key); - return theme.logColors[type] ?? Colors.grey; + return colors[type] ?? Colors.grey; } } diff --git a/packages/talker_flutter/lib/src/ui/talker_actions/talker_actions_bottom_sheet.dart b/packages/talker_flutter/lib/src/ui/talker_actions/talker_actions_bottom_sheet.dart index b7b26b1c..9036ed12 100644 --- a/packages/talker_flutter/lib/src/ui/talker_actions/talker_actions_bottom_sheet.dart +++ b/packages/talker_flutter/lib/src/ui/talker_actions/talker_actions_bottom_sheet.dart @@ -1,26 +1,21 @@ import 'package:flutter/material.dart'; import 'package:talker_flutter/src/ui/widgets/bottom_sheet.dart'; -import 'package:talker_flutter/talker_flutter.dart'; class TalkerActionsBottomSheet extends StatelessWidget { const TalkerActionsBottomSheet({ Key? key, - required this.talkerScreenTheme, required this.actions, }) : super(key: key); - final TalkerScreenTheme talkerScreenTheme; final List actions; @override Widget build(BuildContext context) { return BaseBottomSheet( title: 'Talker Actions', - talkerScreenTheme: talkerScreenTheme, child: Container( margin: const EdgeInsets.symmetric(horizontal: 16).copyWith(bottom: 16), decoration: BoxDecoration( - color: talkerScreenTheme.backgroundColor, borderRadius: BorderRadius.circular(16), ), child: Column( @@ -31,7 +26,6 @@ class TalkerActionsBottomSheet extends StatelessWidget { .entries .map( (e) => _ActionTile( - talkerScreenTheme: talkerScreenTheme, action: e.value, showDivider: e.key != actions.length - 1, ), @@ -48,12 +42,10 @@ class _ActionTile extends StatelessWidget { const _ActionTile({ Key? key, required this.action, - required this.talkerScreenTheme, this.showDivider = true, }) : super(key: key); final TalkerActionItem action; - final TalkerScreenTheme talkerScreenTheme; final bool showDivider; @override @@ -65,19 +57,16 @@ class _ActionTile extends StatelessWidget { onTap: () => _onTap(context), title: Text( action.title, - style: TextStyle( - color: talkerScreenTheme.textColor, + style: const TextStyle( fontSize: 20, fontWeight: FontWeight.w500, ), ), - leading: Icon(action.icon, color: talkerScreenTheme.textColor), - ), - if (showDivider) - Divider( - color: talkerScreenTheme.textColor.withOpacity(0.2), - height: 1, + leading: Icon( + action.icon, ), + ), + if (showDivider) const Divider(height: 1), ], ); } diff --git a/packages/talker_flutter/lib/src/ui/talker_monitor/talker_monitor.dart b/packages/talker_flutter/lib/src/ui/talker_monitor/talker_monitor.dart index 7bd5b370..c62725de 100644 --- a/packages/talker_flutter/lib/src/ui/talker_monitor/talker_monitor.dart +++ b/packages/talker_flutter/lib/src/ui/talker_monitor/talker_monitor.dart @@ -6,20 +6,18 @@ import 'package:talker_flutter/talker_flutter.dart'; class TalkerMonitor extends StatelessWidget { const TalkerMonitor({ Key? key, - required this.theme, required this.talker, + required this.logColors, }) : super(key: key); - /// Theme for customize [TalkerScreen] - final TalkerScreenTheme theme; - /// Talker implementation final Talker talker; + final LogColors logColors; + @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: theme.backgroundColor, appBar: AppBar( title: const FittedBox( fit: BoxFit.scaleDown, @@ -60,7 +58,6 @@ class TalkerMonitor extends StatelessWidget { logs: httpRequests, title: 'Http Requests', color: Colors.green, - theme: theme, icon: Icons.wifi, onTap: () => _openHttpMonitor(context), subtitleWidget: Column( @@ -69,7 +66,9 @@ class TalkerMonitor extends StatelessWidget { RichText( text: TextSpan( text: '${httpRequests.length}', - style: const TextStyle(color: Colors.white), + style: TextStyle( + color: Theme.of(context).colorScheme.onSurface, + ), children: const [ TextSpan(text: ' http requests executed') ], @@ -80,10 +79,7 @@ class TalkerMonitor extends StatelessWidget { text: '${httpResponses.length} successful', style: const TextStyle(color: Colors.green), children: const [ - TextSpan( - text: ' responses received', - style: TextStyle(color: Colors.white), - ), + TextSpan(text: ' responses received'), ], ), ), @@ -92,10 +88,7 @@ class TalkerMonitor extends StatelessWidget { text: '${httpErrors.length} failure', style: const TextStyle(color: Colors.red), children: const [ - TextSpan( - text: ' responses received', - style: TextStyle(color: Colors.white), - ), + TextSpan(text: ' responses received'), ], ), ), @@ -108,10 +101,9 @@ class TalkerMonitor extends StatelessWidget { const SliverToBoxAdapter(child: SizedBox(height: 10)), SliverToBoxAdapter( child: TalkerMonitorCard( - theme: theme, logs: errors, title: 'Errors', - color: theme.logColors.getByType(TalkerLogType.error), + color: logColors.getByType(TalkerLogType.error), icon: Icons.error_outline_rounded, subtitle: 'Application has ${errors.length} unresolved errors', @@ -124,10 +116,9 @@ class TalkerMonitor extends StatelessWidget { const SliverToBoxAdapter(child: SizedBox(height: 10)), SliverToBoxAdapter( child: TalkerMonitorCard( - theme: theme, logs: exceptions, title: 'Exceptions', - color: theme.logColors.getByType(TalkerLogType.exception), + color: logColors.getByType(TalkerLogType.exception), icon: Icons.error_outline_rounded, subtitle: 'Application has ${exceptions.length} unresolved exceptions', @@ -140,10 +131,9 @@ class TalkerMonitor extends StatelessWidget { const SliverToBoxAdapter(child: SizedBox(height: 10)), SliverToBoxAdapter( child: TalkerMonitorCard( - theme: theme, logs: warnings, title: 'Warnings', - color: theme.logColors.getByType(TalkerLogType.warning), + color: logColors.getByType(TalkerLogType.warning), icon: Icons.warning_amber_rounded, subtitle: 'Application has ${warnings.length} warnings', onTap: () => @@ -155,10 +145,9 @@ class TalkerMonitor extends StatelessWidget { const SliverToBoxAdapter(child: SizedBox(height: 10)), SliverToBoxAdapter( child: TalkerMonitorCard( - theme: theme, logs: infos, title: 'Infos', - color: theme.logColors.getByType(TalkerLogType.info), + color: logColors.getByType(TalkerLogType.info), icon: Icons.info_outline_rounded, subtitle: 'Info logs count: ${infos.length}', onTap: () => _openTypedLogsScreen(context, infos, 'Infos'), @@ -169,10 +158,9 @@ class TalkerMonitor extends StatelessWidget { const SliverToBoxAdapter(child: SizedBox(height: 10)), SliverToBoxAdapter( child: TalkerMonitorCard( - theme: theme, logs: verboseDebug, title: 'Verbose & debug', - color: theme.logColors.getByType(TalkerLogType.verbose), + color: logColors.getByType(TalkerLogType.verbose), icon: Icons.remove_red_eye_outlined, subtitle: 'Verbose and debug logs count: ${verboseDebug.length}', @@ -202,8 +190,8 @@ class TalkerMonitor extends StatelessWidget { MaterialPageRoute( builder: (context) => TalkerMonitorTypedLogsScreen( exceptions: logs, - theme: theme, typeName: typeName, + logColors: logColors, ), ), ); diff --git a/packages/talker_flutter/lib/src/ui/talker_monitor/talker_monitor_typed_logs_screen.dart b/packages/talker_flutter/lib/src/ui/talker_monitor/talker_monitor_typed_logs_screen.dart index eaaa5342..14ea9022 100644 --- a/packages/talker_flutter/lib/src/ui/talker_monitor/talker_monitor_typed_logs_screen.dart +++ b/packages/talker_flutter/lib/src/ui/talker_monitor/talker_monitor_typed_logs_screen.dart @@ -6,18 +6,18 @@ class TalkerMonitorTypedLogsScreen extends StatelessWidget { const TalkerMonitorTypedLogsScreen({ Key? key, required this.exceptions, - required this.theme, + required this.logColors, required this.typeName, }) : super(key: key); final String typeName; - final TalkerScreenTheme theme; final List exceptions; + final LogColors logColors; + @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: theme.backgroundColor, appBar: AppBar( title: Text('Talker Monitor $typeName'), ), @@ -28,11 +28,11 @@ class TalkerMonitorTypedLogsScreen extends StatelessWidget { delegate: SliverChildBuilderDelegate( (context, index) { final data = exceptions[index]; + return TalkerDataCard( data: data, onCopyTap: () => _copyTalkerDataItemText(context, data), - color: data.getFlutterColor(theme), - backgroundColor: theme.cardColor, + color: logColors.fromTalkerData(data), ); }, childCount: exceptions.length, diff --git a/packages/talker_flutter/lib/src/ui/talker_monitor/widgets/talker_monitor_card.dart b/packages/talker_flutter/lib/src/ui/talker_monitor/widgets/talker_monitor_card.dart index c6870648..c1d8e76e 100644 --- a/packages/talker_flutter/lib/src/ui/talker_monitor/widgets/talker_monitor_card.dart +++ b/packages/talker_flutter/lib/src/ui/talker_monitor/widgets/talker_monitor_card.dart @@ -12,7 +12,6 @@ class TalkerMonitorCard extends StatelessWidget { required this.color, required this.icon, this.onTap, - required this.theme, }) : super(key: key); final String title; @@ -22,7 +21,6 @@ class TalkerMonitorCard extends StatelessWidget { final Color color; final IconData icon; final VoidCallback? onTap; - final TalkerScreenTheme theme; @override Widget build(BuildContext context) { @@ -30,7 +28,6 @@ class TalkerMonitorCard extends StatelessWidget { onTap: onTap, child: TalkerBaseCard( color: color, - backgroundColor: theme.backgroundColor, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ @@ -54,10 +51,7 @@ class TalkerMonitorCard extends StatelessWidget { if (subtitle != null) Text( subtitle!, - style: TextStyle( - color: theme.textColor, - fontSize: 14, - ), + style: const TextStyle(fontSize: 14), ), if (subtitleWidget != null) subtitleWidget! ], diff --git a/packages/talker_flutter/lib/src/ui/talker_screen.dart b/packages/talker_flutter/lib/src/ui/talker_screen.dart index 018a79bb..c27af78b 100644 --- a/packages/talker_flutter/lib/src/ui/talker_screen.dart +++ b/packages/talker_flutter/lib/src/ui/talker_screen.dart @@ -3,21 +3,21 @@ import 'package:talker_flutter/talker_flutter.dart'; /// UI view for output of all Talker logs and errors class TalkerScreen extends StatelessWidget { - const TalkerScreen({ + // TODO: make me const again when theme is removed. Theme cannot be remove rightn now for backward compability reasons. + TalkerScreen({ Key? key, required this.talker, this.appBarTitle = 'Talker', - this.theme = const TalkerScreenTheme(), this.itemsBuilder, this.appBarLeading, - }) : super(key: key); + LogColors? logColors, + @Deprecated("theme is depricated use logColors instead") this.theme, + }) : logColors = logColors ?? theme?.logColors ?? defaultColors, + super(key: key); /// Talker implementation final Talker talker; - /// Theme for customize [TalkerScreen] - final TalkerScreenTheme theme; - /// Screen [AppBar] title final String appBarTitle; @@ -28,16 +28,31 @@ class TalkerScreen extends StatelessWidget { /// log items cards in list final TalkerDataBuilder? itemsBuilder; + final LogColors logColors; + + final TalkerScreenTheme? theme; + @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: theme.backgroundColor, + final scaffold = Scaffold( body: TalkerView( talker: talker, - theme: theme, appBarTitle: appBarTitle, appBarLeading: appBarLeading, + logColors: logColors, + ), + ); + + if (theme == null) return scaffold; + + return Theme( + data: ThemeData( + colorScheme: ColorScheme.fromSwatch( + cardColor: theme!.cardColor, + backgroundColor: theme!.backgroundColor, + ), ), + child: scaffold, ); } } diff --git a/packages/talker_flutter/lib/src/ui/talker_settings/talker_settings_bottom_sheet.dart b/packages/talker_flutter/lib/src/ui/talker_settings/talker_settings_bottom_sheet.dart index a8d5c46c..ae2deca1 100644 --- a/packages/talker_flutter/lib/src/ui/talker_settings/talker_settings_bottom_sheet.dart +++ b/packages/talker_flutter/lib/src/ui/talker_settings/talker_settings_bottom_sheet.dart @@ -8,13 +8,9 @@ import 'package:talker_flutter/talker_flutter.dart'; class TalkerSettingsBottomSheet extends StatefulWidget { const TalkerSettingsBottomSheet({ Key? key, - required this.talkerScreenTheme, required this.talker, }) : super(key: key); - /// Theme for customize [TalkerScreen] - final TalkerScreenTheme talkerScreenTheme; - /// Talker implementation final ValueNotifier talker; @@ -39,13 +35,11 @@ class _TalkerSettingsBottomSheetState extends State { child: Text( 'Basic settings', style: theme.textTheme.titleLarge?.copyWith( - color: widget.talkerScreenTheme.textColor, fontWeight: FontWeight.w700, ), ), ), TalkerSettingsCard( - talkerScreenTheme: widget.talkerScreenTheme, title: 'Enabled', enabled: widget.talker.value.settings.enabled, onChanged: (enabled) { @@ -56,7 +50,6 @@ class _TalkerSettingsBottomSheetState extends State { ), TalkerSettingsCard( canEdit: widget.talker.value.settings.enabled, - talkerScreenTheme: widget.talkerScreenTheme, title: 'Use console logs', enabled: widget.talker.value.settings.useConsoleLogs, onChanged: (enabled) { @@ -70,7 +63,6 @@ class _TalkerSettingsBottomSheetState extends State { ), TalkerSettingsCard( canEdit: widget.talker.value.settings.enabled, - talkerScreenTheme: widget.talkerScreenTheme, title: 'Use history', enabled: widget.talker.value.settings.useHistory, onChanged: (enabled) { @@ -144,7 +136,6 @@ class _TalkerSettingsBottomSheetState extends State { return BaseBottomSheet( title: 'Talker Settings', - talkerScreenTheme: widget.talkerScreenTheme, child: Expanded( child: CustomScrollView( slivers: [ diff --git a/packages/talker_flutter/lib/src/ui/talker_settings/widgets/talker_setting_card.dart b/packages/talker_flutter/lib/src/ui/talker_settings/widgets/talker_setting_card.dart index 5dc45fd4..e38a7f10 100644 --- a/packages/talker_flutter/lib/src/ui/talker_settings/widgets/talker_setting_card.dart +++ b/packages/talker_flutter/lib/src/ui/talker_settings/widgets/talker_setting_card.dart @@ -1,12 +1,10 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:talker_flutter/src/ui/widgets/base_card.dart'; -import 'package:talker_flutter/talker_flutter.dart'; class TalkerSettingsCard extends StatelessWidget { const TalkerSettingsCard({ Key? key, - required this.talkerScreenTheme, required this.title, required this.enabled, required this.onChanged, @@ -16,7 +14,6 @@ class TalkerSettingsCard extends StatelessWidget { final String title; final bool enabled; final Function(bool enabled) onChanged; - final TalkerScreenTheme talkerScreenTheme; final bool canEdit; @override @@ -29,13 +26,10 @@ class TalkerSettingsCard extends StatelessWidget { child: TalkerBaseCard( padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8) .copyWith(right: 0), - color: talkerScreenTheme.textColor, - backgroundColor: talkerScreenTheme.cardColor, child: ListTile( title: Text( title, - style: TextStyle( - color: talkerScreenTheme.textColor, + style: const TextStyle( fontSize: 18, fontWeight: FontWeight.w500, ), diff --git a/packages/talker_flutter/lib/src/ui/talker_view.dart b/packages/talker_flutter/lib/src/ui/talker_view.dart index 667cacc1..7c907337 100644 --- a/packages/talker_flutter/lib/src/ui/talker_view.dart +++ b/packages/talker_flutter/lib/src/ui/talker_view.dart @@ -15,17 +15,18 @@ class TalkerView extends StatefulWidget { required this.talker, this.controller, this.scrollController, - this.theme = const TalkerScreenTheme(), this.appBarTitle, this.itemsBuilder, this.appBarLeading, - }) : super(key: key); + final LogColors? logColors, + }) : logColors = logColors ?? defaultColors, + super(key: key); /// Talker implementation final Talker talker; /// Theme for customize [TalkerScreen] - final TalkerScreenTheme theme; + final LogColors logColors; /// Screen [AppBar] title final String? appBarTitle; @@ -51,7 +52,6 @@ class _TalkerViewState extends State { @override Widget build(BuildContext context) { - final talkerTheme = widget.theme; return GestureDetector( onTap: () => FocusScope.of(context).requestFocus(FocusNode()), child: AnimatedBuilder( @@ -73,15 +73,13 @@ class _TalkerViewState extends State { title: widget.appBarTitle, leading: widget.appBarLeading, talker: widget.talker, - talkerTheme: talkerTheme, titlesController: _titlesController, titles: titles, uniqTitles: uniqTitles, controller: _controller, onMonitorTap: () => _openTalkerMonitor(context), onActionsTap: () => _showActionsBottomSheet(context), - onSettingsTap: () => - _openTalkerSettings(context, talkerTheme), + onSettingsTap: () => _openTalkerSettings(context), onToggleTitle: _onToggleTitle, ), const SliverToBoxAdapter(child: SizedBox(height: 8)), @@ -94,10 +92,9 @@ class _TalkerViewState extends State { } return TalkerDataCard( data: data, - backgroundColor: widget.theme.cardColor, onCopyTap: () => _copyTalkerDataItemText(data), expanded: _controller.expandedLogs, - color: data.getFlutterColor(widget.theme), + color: widget.logColors.fromTalkerData(data), ); }, childCount: filtredElements.length, @@ -129,7 +126,7 @@ class _TalkerViewState extends State { return data; } - void _openTalkerSettings(BuildContext context, TalkerScreenTheme theme) { + void _openTalkerSettings(BuildContext context) { final talker = ValueNotifier(widget.talker); showModalBottomSheet( @@ -138,7 +135,6 @@ class _TalkerViewState extends State { isScrollControlled: false, builder: (context) { return TalkerSettingsBottomSheet( - talkerScreenTheme: theme, talker: talker, ); }, @@ -149,8 +145,8 @@ class _TalkerViewState extends State { Navigator.of(context).push( MaterialPageRoute( builder: (context) => TalkerMonitor( - theme: widget.theme, talker: widget.talker, + logColors: widget.logColors, ), ), ); @@ -205,7 +201,6 @@ class _TalkerViewState extends State { icon: Icons.ios_share_outlined, ), ], - talkerScreenTheme: widget.theme, ); }, ); diff --git a/packages/talker_flutter/lib/src/ui/theme/default_theme.dart b/packages/talker_flutter/lib/src/ui/theme/default_theme.dart deleted file mode 100644 index 70585717..00000000 --- a/packages/talker_flutter/lib/src/ui/theme/default_theme.dart +++ /dev/null @@ -1,3 +0,0 @@ -import 'package:flutter/material.dart'; - -const defaultCardBackgroundColor = Color.fromARGB(255, 49, 49, 49); diff --git a/packages/talker_flutter/lib/src/ui/theme/talker_screen_theme.dart b/packages/talker_flutter/lib/src/ui/theme/talker_screen_theme.dart index bd65fd42..18cbf94e 100644 --- a/packages/talker_flutter/lib/src/ui/theme/talker_screen_theme.dart +++ b/packages/talker_flutter/lib/src/ui/theme/talker_screen_theme.dart @@ -1,16 +1,15 @@ import 'package:flutter/material.dart'; -import 'package:talker_flutter/src/ui/theme/default_theme.dart'; +import 'package:talker/talker.dart'; import 'package:talker_flutter/talker_flutter.dart'; typedef LogColors = Map; -/// Configuring the UI of [TalkerScreen] class TalkerScreenTheme { const TalkerScreenTheme({ this.backgroundColor = const Color(0xFF212121), this.textColor = Colors.white, - this.cardColor = defaultCardBackgroundColor, - LogColors? logColors, + this.cardColor = const Color.fromARGB(255, 49, 49, 49), + @Deprecated("use logColors directly in TalkerScreen") LogColors? logColors, }) : _customColors = logColors; /// Background screen color @@ -26,11 +25,11 @@ class TalkerScreenTheme { Map get logColors { if (_customColors != null) { - final customMap = Map.from(_defaultColors); + final customMap = Map.from(defaultColors); customMap.addAll(_customColors!); return customMap; } - return _defaultColors; + return defaultColors; } factory TalkerScreenTheme.fromTheme(ThemeData theme, [LogColors? logColors]) { @@ -44,12 +43,20 @@ class TalkerScreenTheme { } extension MapTalkerFlutterColorsExt on LogColors { + Color fromTalkerData(final TalkerData data) { + final key = data.key; + + if (key == null) return Colors.grey; + final type = TalkerLogType.fromKey(key); + return getByType(type); + } + Color getByType(TalkerLogType type) { return this[type] ?? Colors.grey; } } -const _defaultColors = { +const defaultColors = { /// Base logs section TalkerLogType.error: Color.fromARGB(255, 239, 83, 80), TalkerLogType.critical: Color.fromARGB(255, 198, 40, 40), diff --git a/packages/talker_flutter/lib/src/ui/widgets/base_card.dart b/packages/talker_flutter/lib/src/ui/widgets/base_card.dart index c8c79656..1c228a91 100644 --- a/packages/talker_flutter/lib/src/ui/widgets/base_card.dart +++ b/packages/talker_flutter/lib/src/ui/widgets/base_card.dart @@ -1,19 +1,16 @@ import 'package:flutter/material.dart'; -import 'package:talker_flutter/src/ui/theme/default_theme.dart'; class TalkerBaseCard extends StatelessWidget { const TalkerBaseCard({ Key? key, required this.child, - required this.color, + this.color, this.padding = const EdgeInsets.all(8), - this.backgroundColor = defaultCardBackgroundColor, }) : super(key: key); final Widget child; - final Color color; + final Color? color; final EdgeInsets? padding; - final Color backgroundColor; @override Widget build(BuildContext context) { @@ -22,8 +19,10 @@ class TalkerBaseCard extends StatelessWidget { padding: padding, margin: const EdgeInsets.symmetric(horizontal: 16), decoration: BoxDecoration( - color: backgroundColor, - border: Border.all(color: color), + color: color?.withOpacity(.1), + border: Border.all( + color: color ?? Theme.of(context).colorScheme.onSurface, + ), borderRadius: BorderRadius.circular(10), ), child: child, diff --git a/packages/talker_flutter/lib/src/ui/widgets/bottom_sheet.dart b/packages/talker_flutter/lib/src/ui/widgets/bottom_sheet.dart index e32a6f8a..ce840ede 100644 --- a/packages/talker_flutter/lib/src/ui/widgets/bottom_sheet.dart +++ b/packages/talker_flutter/lib/src/ui/widgets/bottom_sheet.dart @@ -1,15 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:talker_flutter/talker_flutter.dart'; class BaseBottomSheet extends StatelessWidget { const BaseBottomSheet({ Key? key, - required this.talkerScreenTheme, required this.child, required this.title, }) : super(key: key); - final TalkerScreenTheme talkerScreenTheme; final Widget child; final String title; @@ -28,7 +25,7 @@ class BaseBottomSheet extends StatelessWidget { bottom: mq.padding.bottom, ), decoration: BoxDecoration( - color: talkerScreenTheme.backgroundColor, + color: theme.colorScheme.surface, borderRadius: BorderRadius.circular(16), ), child: Column( @@ -40,17 +37,10 @@ class BaseBottomSheet extends StatelessWidget { child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( - title, - style: theme.textTheme.headlineSmall - ?.copyWith(color: talkerScreenTheme.textColor), - ), + Text(title, style: theme.textTheme.headlineSmall), InkWell( onTap: () => Navigator.pop(context), - child: Icon( - Icons.close_rounded, - color: talkerScreenTheme.textColor, - ), + child: const Icon(Icons.close_rounded), ), ], ), diff --git a/packages/talker_flutter/lib/src/ui/widgets/data_card.dart b/packages/talker_flutter/lib/src/ui/widgets/data_card.dart index b3feb569..d6941af3 100644 --- a/packages/talker_flutter/lib/src/ui/widgets/data_card.dart +++ b/packages/talker_flutter/lib/src/ui/widgets/data_card.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:talker_flutter/src/ui/theme/default_theme.dart'; import 'package:talker_flutter/src/ui/widgets/base_card.dart'; import 'package:talker_flutter/talker_flutter.dart'; @@ -9,10 +8,9 @@ class TalkerDataCard extends StatefulWidget { required this.data, this.onCopyTap, this.onTap, - this.expanded = true, + this.expanded = false, this.margin, required this.color, - this.backgroundColor = defaultCardBackgroundColor, }) : super(key: key); final TalkerData data; @@ -21,7 +19,6 @@ class TalkerDataCard extends StatefulWidget { final bool expanded; final EdgeInsets? margin; final Color color; - final Color backgroundColor; @override State createState() => _TalkerDataCardState(); @@ -52,7 +49,7 @@ class _TalkerDataCardState extends State { Widget build(BuildContext context) { final errorMessage = _errorMessage; final errorType = _type; - final message = _message; + final message = _message ?? _type; final stackTrace = _stackTrace; return Padding( padding: widget.margin ?? const EdgeInsets.only(bottom: 8), @@ -60,7 +57,6 @@ class _TalkerDataCardState extends State { onTap: _onTap, child: TalkerBaseCard( color: widget.color, - backgroundColor: widget.backgroundColor, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -83,10 +79,7 @@ class _TalkerDataCardState extends State { Text( message, maxLines: _expanded ? null : 2, - style: TextStyle( - color: widget.color, - fontSize: 12, - ), + style: const TextStyle(fontSize: 12), ), ], ), @@ -97,10 +90,7 @@ class _TalkerDataCardState extends State { child: IconButton( padding: EdgeInsets.zero, iconSize: 20, - icon: Icon( - Icons.copy, - color: widget.color, - ), + icon: const Icon(Icons.copy), onPressed: widget.onCopyTap, ), ), @@ -115,49 +105,40 @@ class _TalkerDataCardState extends State { ? const EdgeInsets.all(6) : EdgeInsets.zero, decoration: stackTrace != null - ? BoxDecoration( - color: Colors.grey[900], - borderRadius: BorderRadius.circular(10), - ) + ? BoxDecoration(borderRadius: BorderRadius.circular(10)) : null, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (_expanded && errorType != null) + if (_expanded && errorType != null && message == null) Text( errorType, - style: TextStyle( - color: widget.color, - fontSize: 12, - ), + style: const TextStyle(fontSize: 12), ), if (_expanded && errorMessage != null) Text( errorMessage, - style: TextStyle( - color: widget.color, - fontSize: 12, - ), + style: const TextStyle(fontSize: 12), ), ], ), ), - if (_expanded && stackTrace != null) + if (_expanded && stackTrace != null) ...[ Container( - margin: const EdgeInsets.only(top: 8), padding: const EdgeInsets.all(6), decoration: BoxDecoration( - color: Colors.grey[900], + color: Theme.of(context).colorScheme.errorContainer, borderRadius: BorderRadius.circular(10), ), child: Text( stackTrace, style: TextStyle( - color: widget.color, fontSize: 12, + color: Theme.of(context).colorScheme.onErrorContainer, ), ), ), + ] ], ), ), diff --git a/packages/talker_flutter/lib/src/ui/widgets/talker_view_appbar.dart b/packages/talker_flutter/lib/src/ui/widgets/talker_view_appbar.dart index 513570b8..ea954a48 100644 --- a/packages/talker_flutter/lib/src/ui/widgets/talker_view_appbar.dart +++ b/packages/talker_flutter/lib/src/ui/widgets/talker_view_appbar.dart @@ -9,7 +9,6 @@ class TalkerViewAppBar extends StatelessWidget { required this.title, required this.leading, required this.talker, - required this.talkerTheme, required this.titlesController, required this.controller, required this.titles, @@ -24,7 +23,6 @@ class TalkerViewAppBar extends StatelessWidget { final Widget? leading; final Talker talker; - final TalkerScreenTheme talkerTheme; final GroupButtonController titlesController; final TalkerViewController controller; @@ -41,7 +39,6 @@ class TalkerViewAppBar extends StatelessWidget { Widget build(BuildContext context) { final theme = Theme.of(context); return SliverAppBar( - backgroundColor: talkerTheme.backgroundColor, elevation: 0, pinned: true, floating: true, @@ -49,43 +46,30 @@ class TalkerViewAppBar extends StatelessWidget { collapsedHeight: 60, toolbarHeight: 60, leading: leading, - iconTheme: IconThemeData(color: talkerTheme.textColor), actions: [ UnconstrainedBox( child: _MonitorButton( talker: talker, onPressed: onMonitorTap, - talkerTheme: talkerTheme, ), ), UnconstrainedBox( child: IconButton( onPressed: onSettingsTap, - icon: Icon( - Icons.settings_rounded, - color: talkerTheme.textColor, - ), + icon: const Icon(Icons.settings_rounded), ), ), UnconstrainedBox( child: IconButton( onPressed: onActionsTap, - icon: Icon( + icon: const Icon( Icons.menu_rounded, - color: talkerTheme.textColor, ), ), ), const SizedBox(width: 10), ], - title: title != null - ? Text( - title!, - style: TextStyle( - color: talkerTheme.textColor, - ), - ) - : null, + title: title != null ? Text(title!) : null, flexibleSpace: FlexibleSpaceBar( collapseMode: CollapseMode.parallax, background: SafeArea( @@ -109,28 +93,24 @@ class TalkerViewAppBar extends StatelessWidget { return Container( padding: const EdgeInsets.all(8), decoration: BoxDecoration( - border: Border.all(color: talkerTheme.textColor), + border: Border.all( + color: theme.colorScheme.onSurface, + ), borderRadius: BorderRadius.circular(10), color: selected ? theme.colorScheme.primaryContainer - : talkerTheme.cardColor, + : theme.colorScheme.surface, ), child: Row( children: [ Text( '$count', - style: TextStyle( - fontSize: 12, - color: talkerTheme.textColor, - ), + style: const TextStyle(fontSize: 12), ), const SizedBox(width: 4), Text( '$value', - style: TextStyle( - fontSize: 12, - color: talkerTheme.textColor, - ), + style: const TextStyle(fontSize: 12), ), ], ), @@ -144,10 +124,7 @@ class TalkerViewAppBar extends StatelessWidget { ), ), const SizedBox(height: 4), - _SearchTextField( - controller: controller, - talkerTheme: talkerTheme, - ), + _SearchTextField(controller: controller), ], ), ), @@ -165,11 +142,9 @@ class TalkerViewAppBar extends StatelessWidget { class _SearchTextField extends StatelessWidget { const _SearchTextField({ Key? key, - required this.talkerTheme, required this.controller, }) : super(key: key); - final TalkerScreenTheme talkerTheme; final TalkerViewController controller; @override @@ -179,29 +154,23 @@ class _SearchTextField extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 16), child: TextFormField( style: theme.textTheme.bodyLarge!.copyWith( - color: talkerTheme.textColor, fontSize: 14, ), onChanged: controller.updateFilterSearchQuery, decoration: InputDecoration( fillColor: theme.cardColor, enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: talkerTheme.textColor), + borderSide: BorderSide(color: theme.colorScheme.onSurface), borderRadius: BorderRadius.circular(10), ), border: OutlineInputBorder( - borderSide: BorderSide(color: talkerTheme.textColor), + borderSide: const BorderSide(), borderRadius: BorderRadius.circular(10), ), contentPadding: const EdgeInsets.symmetric(vertical: 16), - prefixIcon: Icon( - Icons.search, - color: talkerTheme.textColor, - size: 20, - ), + prefixIcon: const Icon(Icons.search, size: 20), hintText: 'Search...', hintStyle: theme.textTheme.bodyLarge!.copyWith( - color: talkerTheme.textColor, fontSize: 14, ), ), @@ -215,11 +184,9 @@ class _MonitorButton extends StatelessWidget { Key? key, required this.talker, required this.onPressed, - required this.talkerTheme, }) : super(key: key); final Talker talker; - final TalkerScreenTheme talkerTheme; final VoidCallback onPressed; @override @@ -235,10 +202,7 @@ class _MonitorButton extends StatelessWidget { Center( child: IconButton( onPressed: onPressed, - icon: Icon( - Icons.monitor_heart_outlined, - color: talkerTheme.textColor, - ), + icon: const Icon(Icons.monitor_heart_outlined), ), ), if (haveErrors)