Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UI colors #242

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/shop_app_example/lib/ui/presentation_frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions examples/shop_app_example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/talker_flutter/lib/src/extensions/talker_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<TalkerActionItem> 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(
Expand All @@ -31,7 +26,6 @@ class TalkerActionsBottomSheet extends StatelessWidget {
.entries
.map(
(e) => _ActionTile(
talkerScreenTheme: talkerScreenTheme,
action: e.value,
showDivider: e.key != actions.length - 1,
),
Expand All @@ -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
Expand All @@ -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),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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')
],
Expand All @@ -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'),
],
),
),
Expand All @@ -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'),
],
),
),
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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: () =>
Expand All @@ -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'),
Expand All @@ -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}',
Expand Down Expand Up @@ -202,8 +190,8 @@ class TalkerMonitor extends StatelessWidget {
MaterialPageRoute(
builder: (context) => TalkerMonitorTypedLogsScreen(
exceptions: logs,
theme: theme,
typeName: typeName,
logColors: logColors,
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TalkerData> exceptions;

final LogColors logColors;

@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: theme.backgroundColor,
appBar: AppBar(
title: Text('Talker Monitor $typeName'),
),
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,15 +21,13 @@ class TalkerMonitorCard extends StatelessWidget {
final Color color;
final IconData icon;
final VoidCallback? onTap;
final TalkerScreenTheme theme;

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: TalkerBaseCard(
color: color,
backgroundColor: theme.backgroundColor,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Expand All @@ -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!
],
Expand Down
33 changes: 24 additions & 9 deletions packages/talker_flutter/lib/src/ui/talker_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
);
}
}
Loading
Loading