Revert "design: New date separators in timeline"

This reverts commit f15b81c5a6.
pull/956/head
Krille 1 year ago
parent f15b81c5a6
commit 554f951a30
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -2485,6 +2485,5 @@
"stickers": "Stickers", "stickers": "Stickers",
"discover": "Discover", "discover": "Discover",
"commandHint_ignore": "Ignore the given matrix ID", "commandHint_ignore": "Ignore the given matrix ID",
"commandHint_unignore": "Unignore the given matrix ID", "commandHint_unignore": "Unignore the given matrix ID"
"today": "Today"
} }

@ -5,14 +5,12 @@ import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:fluffychat/config/themes.dart'; import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/chat/chat.dart'; import 'package:fluffychat/pages/chat/chat.dart';
import 'package:fluffychat/pages/chat/events/date_separator.dart';
import 'package:fluffychat/pages/chat/events/message.dart'; import 'package:fluffychat/pages/chat/events/message.dart';
import 'package:fluffychat/pages/chat/seen_by_row.dart'; import 'package:fluffychat/pages/chat/seen_by_row.dart';
import 'package:fluffychat/pages/chat/typing_indicators.dart'; import 'package:fluffychat/pages/chat/typing_indicators.dart';
import 'package:fluffychat/pages/user_bottom_sheet/user_bottom_sheet.dart'; import 'package:fluffychat/pages/user_bottom_sheet/user_bottom_sheet.dart';
import 'package:fluffychat/utils/account_config.dart'; import 'package:fluffychat/utils/account_config.dart';
import 'package:fluffychat/utils/adaptive_bottom_sheet.dart'; import 'package:fluffychat/utils/adaptive_bottom_sheet.dart';
import 'package:fluffychat/utils/date_time_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/filtered_timeline_extension.dart'; import 'package:fluffychat/utils/matrix_sdk_extensions/filtered_timeline_extension.dart';
import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/platform_infos.dart';
@ -108,8 +106,6 @@ class ChatEventList extends StatelessWidget {
// The message at this index: // The message at this index:
final event = events[i]; final event = events[i];
final nextEvent = i + 1 < events.length ? events[i + 1] : null;
final previousEvent = i > 0 ? events[i - 1] : null;
final animateIn = animateInEventIndex != null && final animateIn = animateInEventIndex != null &&
controller.timeline!.events.length > animateInEventIndex && controller.timeline!.events.length > animateInEventIndex &&
event == controller.timeline!.events[animateInEventIndex]; event == controller.timeline!.events[animateInEventIndex];
@ -118,48 +114,39 @@ class ChatEventList extends StatelessWidget {
key: ValueKey(event.eventId), key: ValueKey(event.eventId),
index: i, index: i,
controller: controller.scrollController, controller: controller.scrollController,
child: Column( child: Message(
mainAxisSize: MainAxisSize.min, event,
children: [ animateIn: animateIn,
if (nextEvent?.originServerTs resetAnimateIn: () {
.isSameDate(event.originServerTs) != controller.animateInEventIndex = null;
true) },
DateSeparator(date: event.originServerTs), onSwipe: () => controller.replyAction(replyTo: event),
Message( onInfoTab: controller.showEventInfo,
event, onAvatarTab: (Event event) => showAdaptiveBottomSheet(
animateIn: animateIn, context: context,
resetAnimateIn: () { builder: (c) => UserBottomSheet(
controller.animateInEventIndex = null; user: event.senderFromMemoryOrFallback,
}, outerContext: context,
onSwipe: () => controller.replyAction(replyTo: event), onMention: () => controller.sendController.text +=
onInfoTab: controller.showEventInfo, '${event.senderFromMemoryOrFallback.mention} ',
onAvatarTab: (Event event) => showAdaptiveBottomSheet(
context: context,
builder: (c) => UserBottomSheet(
user: event.senderFromMemoryOrFallback,
outerContext: context,
onMention: () => controller.sendController.text +=
'${event.senderFromMemoryOrFallback.mention} ',
),
),
highlightMarker:
controller.scrollToEventIdMarker == event.eventId,
onSelect: controller.onSelectMessage,
scrollToEventId: (String eventId) =>
controller.scrollToEventId(eventId),
longPressSelect: controller.selectedEvents.isNotEmpty,
selected: controller.selectedEvents
.any((e) => e.eventId == event.eventId),
timeline: controller.timeline!,
displayReadMarker:
controller.readMarkerEventId == event.eventId &&
controller.timeline?.allowNewEvent == false,
nextEvent: nextEvent,
previousEvent: previousEvent,
avatarPresenceBackgroundColor:
hasWallpaper ? Colors.transparent : null,
), ),
], ),
highlightMarker:
controller.scrollToEventIdMarker == event.eventId,
onSelect: controller.onSelectMessage,
scrollToEventId: (String eventId) =>
controller.scrollToEventId(eventId),
longPressSelect: controller.selectedEvents.isNotEmpty,
selected: controller.selectedEvents
.any((e) => e.eventId == event.eventId),
timeline: controller.timeline!,
displayReadMarker:
controller.readMarkerEventId == event.eventId &&
controller.timeline?.allowNewEvent == false,
nextEvent: i + 1 < events.length ? events[i + 1] : null,
previousEvent: i > 0 ? events[i - 1] : null,
avatarPresenceBackgroundColor:
hasWallpaper ? Colors.transparent : null,
), ),
); );
}, },

@ -1,42 +0,0 @@
import 'package:flutter/material.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/date_time_extension.dart';
class DateSeparator extends StatelessWidget {
final DateTime date;
const DateSeparator({required this.date, super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: Row(
children: [
Expanded(
child: Container(
height: 1,
color: Theme.of(context).dividerColor,
),
),
Padding(
padding: const EdgeInsets.all(12.0),
child: Text(
date.localizedTimeShort(context, dateOnly: true),
style: TextStyle(
color: Theme.of(context).colorScheme.secondary,
fontSize: 13 * AppConfig.fontSizeFactor,
),
),
),
Expanded(
child: Container(
height: 1,
color: Theme.of(context).dividerColor,
),
),
],
),
);
}
}

@ -203,53 +203,27 @@ class Message extends StatelessWidget {
if (!nextEventSameSender) if (!nextEventSameSender)
Padding( Padding(
padding: const EdgeInsets.only(left: 8.0, bottom: 4), padding: const EdgeInsets.only(left: 8.0, bottom: 4),
child: Row( child: ownMessage || event.room.isDirectChat
mainAxisAlignment: ownMessage ? const SizedBox(height: 12)
? MainAxisAlignment.end : FutureBuilder<User?>(
: MainAxisAlignment.start,
children: [
if (ownMessage || event.room.isDirectChat)
const SizedBox(height: 12)
else
FutureBuilder<User?>(
future: event.fetchSenderUser(), future: event.fetchSenderUser(),
builder: (context, snapshot) { builder: (context, snapshot) {
final displayname = final displayname =
snapshot.data?.calcDisplayname() ?? snapshot.data?.calcDisplayname() ??
event.senderFromMemoryOrFallback event.senderFromMemoryOrFallback
.calcDisplayname(); .calcDisplayname();
return ConstrainedBox( return Text(
constraints: const BoxConstraints( displayname,
maxWidth: FluffyThemes.columnWidth / 2, style: TextStyle(
), fontSize: 12,
child: Text( color: (Theme.of(context).brightness ==
displayname, Brightness.light
maxLines: 1, ? displayname.color
overflow: TextOverflow.ellipsis, : displayname.lightColorText),
style: TextStyle(
fontSize: 12,
color: (Theme.of(context).brightness ==
Brightness.light
? displayname.color
: displayname.lightColorText),
),
), ),
); );
}, },
), ),
Text(
(ownMessage || event.room.isDirectChat
? ''
: ' | ') +
event.originServerTs
.localizedTimeOfDay(context),
style: TextStyle(
fontSize: 12 * AppConfig.fontSizeFactor,
color: Theme.of(context).colorScheme.secondary,
),
),
],
),
), ),
Container( Container(
alignment: alignment, alignment: alignment,
@ -389,12 +363,38 @@ class Message extends StatelessWidget {
Widget container; Widget container;
final showReceiptsRow = final showReceiptsRow =
event.hasAggregatedEvents(timeline, RelationshipTypes.reaction); event.hasAggregatedEvents(timeline, RelationshipTypes.reaction);
if (showReceiptsRow || selected || displayReadMarker) { if (showReceiptsRow || displayTime || selected || displayReadMarker) {
container = Column( container = Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: crossAxisAlignment:
ownMessage ? CrossAxisAlignment.end : CrossAxisAlignment.start, ownMessage ? CrossAxisAlignment.end : CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
if (displayTime || selected)
Padding(
padding: displayTime
? const EdgeInsets.symmetric(vertical: 8.0)
: EdgeInsets.zero,
child: Center(
child: Material(
color: displayTime
? Theme.of(context).colorScheme.background
: Theme.of(context)
.colorScheme
.background
.withOpacity(0.33),
borderRadius:
BorderRadius.circular(AppConfig.borderRadius / 2),
clipBehavior: Clip.antiAlias,
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
event.originServerTs.localizedTime(context),
style: TextStyle(fontSize: 13 * AppConfig.fontSizeFactor),
),
),
),
),
),
row, row,
AnimatedSize( AnimatedSize(
duration: FluffyThemes.animationDuration, duration: FluffyThemes.animationDuration,

@ -187,7 +187,12 @@ class ChatListView extends StatelessWidget {
? NavigationBar( ? NavigationBar(
elevation: 4, elevation: 4,
labelBehavior: labelBehavior:
NavigationDestinationLabelBehavior.alwaysShow, NavigationDestinationLabelBehavior.alwaysHide,
height: 64,
shadowColor:
Theme.of(context).colorScheme.onBackground,
surfaceTintColor:
Theme.of(context).colorScheme.background,
selectedIndex: controller.selectedIndex, selectedIndex: controller.selectedIndex,
onDestinationSelected: onDestinationSelected:
controller.onDestinationSelected, controller.onDestinationSelected,

@ -45,7 +45,7 @@ extension DateTimeExtension on DateTime {
/// Returns [localizedTimeOfDay()] if the ChatTime is today, the name of the week /// Returns [localizedTimeOfDay()] if the ChatTime is today, the name of the week
/// day if the ChatTime is this week and a date string else. /// day if the ChatTime is this week and a date string else.
String localizedTimeShort(BuildContext context, {bool dateOnly = false}) { String localizedTimeShort(BuildContext context) {
final now = DateTime.now(); final now = DateTime.now();
final sameYear = now.year == year; final sameYear = now.year == year;
@ -58,7 +58,7 @@ extension DateTimeExtension on DateTime {
1000 * 60 * 60 * 24 * 7; 1000 * 60 * 60 * 24 * 7;
if (sameDay) { if (sameDay) {
return dateOnly ? L10n.of(context)!.today : localizedTimeOfDay(context); return localizedTimeOfDay(context);
} else if (sameWeek) { } else if (sameWeek) {
return DateFormat.EEEE(Localizations.localeOf(context).languageCode) return DateFormat.EEEE(Localizations.localeOf(context).languageCode)
.format(this); .format(this);
@ -92,9 +92,5 @@ extension DateTimeExtension on DateTime {
); );
} }
bool isSameDate(DateTime other) {
return year == other.year && month == other.month && day == other.day;
}
static String _z(int i) => i < 10 ? '0${i.toString()}' : i.toString(); static String _z(int i) => i < 10 ? '0${i.toString()}' : i.toString();
} }

Loading…
Cancel
Save