refactor: toten Code entfernen, doppelte Zeit-Formatierung zusammenführen
message_bubble.dart war vollständig unbenutzt (durch message_group.dart abgelöst). Die zwei identischen _formatTime-Methoden in message_group.dart zu einer Top-Level-Funktion zusammengeführt - reine Extraktion, keine Verhaltensänderung. flutter analyze bleibt sauber.
This commit is contained in:
@@ -21,6 +21,12 @@ import 'package:pyramid/utils/gif_favorite_service.dart';
|
||||
import 'package:pyramid/widgets/mxc_image.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
String _formatMessageTime(DateTime t) {
|
||||
final h = t.hour.toString().padLeft(2, '0');
|
||||
final m = t.minute.toString().padLeft(2, '0');
|
||||
return '$h:$m';
|
||||
}
|
||||
|
||||
// Wraps a group of consecutive messages from the same sender
|
||||
class MessageGroup extends StatefulWidget {
|
||||
final List<Event> events;
|
||||
@@ -85,7 +91,7 @@ class _MessageGroupState extends State<MessageGroup> {
|
||||
final name = sender.calcDisplayname();
|
||||
final initial = name.isNotEmpty ? name[0].toUpperCase() : '?';
|
||||
final color = _colorFromId(firstEvent.senderId);
|
||||
final time = _formatTime(firstEvent.originServerTs);
|
||||
final time = _formatMessageTime(firstEvent.originServerTs);
|
||||
final avatarUri = sender.avatarUrl;
|
||||
|
||||
// Build a FLAT column of rows — each message at the same indentation level.
|
||||
@@ -318,12 +324,6 @@ class _MessageGroupState extends State<MessageGroup> {
|
||||
if (id.isEmpty) return colors[0];
|
||||
return colors[id.codeUnitAt(0) % colors.length];
|
||||
}
|
||||
|
||||
String _formatTime(DateTime t) {
|
||||
final h = t.hour.toString().padLeft(2, '0');
|
||||
final m = t.minute.toString().padLeft(2, '0');
|
||||
return '$h:$m';
|
||||
}
|
||||
}
|
||||
|
||||
// Shown under a message whose send failed (e.g. offline) — keeps the message
|
||||
@@ -439,7 +439,7 @@ class _ContinuationMessageState extends State<_ContinuationMessage> {
|
||||
opacity: _hovered ? 1 : 0,
|
||||
duration: const Duration(milliseconds: 120),
|
||||
child: Text(
|
||||
_formatTime(widget.event.originServerTs),
|
||||
_formatMessageTime(widget.event.originServerTs),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: widget.pt.fgDim,
|
||||
@@ -472,11 +472,6 @@ class _ContinuationMessageState extends State<_ContinuationMessage> {
|
||||
);
|
||||
}
|
||||
|
||||
String _formatTime(DateTime t) {
|
||||
final h = t.hour.toString().padLeft(2, '0');
|
||||
final m = t.minute.toString().padLeft(2, '0');
|
||||
return '$h:$m';
|
||||
}
|
||||
}
|
||||
|
||||
class _MessageContent extends StatelessWidget {
|
||||
|
||||
Reference in New Issue
Block a user