Skip to content

Commit

Permalink
Colorize the debug_messages based on the player dash color
Browse files Browse the repository at this point in the history
  • Loading branch information
imaNNeo committed Nov 12, 2024
1 parent d262d48 commit 3e6a0cd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 14 additions & 2 deletions lib/domain/entities/debug/debug_message.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:flappy_dash/domain/entities/dash_type.dart';
import 'package:flappy_dash/domain/entities/dispatching_match_event.dart';
import 'package:flappy_dash/domain/entities/match_event.dart';
import 'package:flappy_dash/domain/entities/styled_text.dart';
import 'package:flappy_dash/domain/extensions/string_extension.dart';
import 'package:flappy_dash/presentation/app_style.dart';
import 'package:flutter/material.dart';

sealed class DebugMessage {
Expand Down Expand Up @@ -31,14 +33,24 @@ class DebugIncomingEvent extends DebugMessage {
@override
List<StyledText> toDebugMessage(String currentUserId) {
final isMe = event.sender?.userId == currentUserId;
final senderColor = currentUserId.isNullOrBlank
? incomingEventColor
: AppColors.getDashColor(
DashType.fromUserId(currentUserId),
);
return [
StyledText(time, normalColor),
StyledText(' ↓ ', incomingEventColor, isBold: true),
StyledText('${event.runtimeType} ', incomingEventColor, isBold: true),
StyledText('from: ', normalColor),
StyledText(
'from: ',
normalColor,
isBold: true,
),
StyledText(
'${event.sender?.userId.split('-')[0]} ${isMe ? 'me' : ''}',
incomingEventColor,
senderColor,
isBold: true,
),
];
}
Expand Down
4 changes: 2 additions & 2 deletions lib/presentation/bloc/multiplayer/multiplayer_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ class MultiplayerCubit extends Cubit<MultiplayerState> {
case MatchStartedEvent():
_onMatchStarted(event.state);
break;

case _:
throw StateError('Invalid $event in this phase: $phase');
// Do nothing
break;
}
break;
case MatchPhase.running:
Expand Down

0 comments on commit 3e6a0cd

Please sign in to comment.