change: Remove previous collapse solution

This commit is contained in:
Christian Pauly 2021-02-25 09:11:17 +01:00
commit 71ad54d939
6 changed files with 124 additions and 65 deletions

View file

@ -16,9 +16,10 @@ import 'state_message.dart';
class Message extends StatelessWidget {
final Event event;
final Event nextEvent;
final Function(Event) onSelect;
final Function(Event) onAvatarTab;
final Function(String) scrollToEventId;
final void Function(Event) onSelect;
final void Function(Event) onAvatarTab;
final void Function(String) scrollToEventId;
final void Function(String) unfold;
final bool longPressSelect;
final bool selected;
final Timeline timeline;
@ -29,6 +30,7 @@ class Message extends StatelessWidget {
this.onSelect,
this.onAvatarTab,
this.scrollToEventId,
@required this.unfold,
this.selected,
this.timeline});
@ -38,15 +40,9 @@ class Message extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (event.type == EventTypes.RoomCreate) {
return InkWell(
onTap: () => onSelect(event),
child: StateMessage(event),
);
}
if (![EventTypes.Message, EventTypes.Sticker, EventTypes.Encrypted]
.contains(event.type)) {
return StateMessage(event);
return StateMessage(event, unfold: unfold);
}
var client = Matrix.of(context).client;

View file

@ -7,31 +7,55 @@ import '../../app_config.dart';
class StateMessage extends StatelessWidget {
final Event event;
const StateMessage(this.event);
final void Function(String) unfold;
const StateMessage(this.event, {@required this.unfold});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(
left: 8.0,
right: 8.0,
bottom: 8.0,
),
child: Center(
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(context).secondaryHeaderColor,
borderRadius: BorderRadius.circular(7),
),
child: Text(
event.getLocalizedBody(MatrixLocals(L10n.of(context))),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: Theme.of(context).textTheme.bodyText1.fontSize *
AppConfig.fontSizeFactor,
color: Theme.of(context).textTheme.bodyText2.color,
decoration: event.redacted ? TextDecoration.lineThrough : null,
if (event.unsigned['im.fluffychat.collapsed_state_event'] == true) {
return Container();
}
final int counter =
event.unsigned['im.fluffychat.collapsed_state_event_count'] ?? 0;
return InkWell(
onTap: counter != 0 ? () => unfold(event.eventId) : null,
child: Padding(
padding: const EdgeInsets.only(
left: 8.0,
right: 8.0,
bottom: 8.0,
),
child: Center(
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(context).secondaryHeaderColor,
borderRadius: BorderRadius.circular(7),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
event.getLocalizedBody(MatrixLocals(L10n.of(context))),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: Theme.of(context).textTheme.bodyText1.fontSize *
AppConfig.fontSizeFactor,
color: Theme.of(context).textTheme.bodyText2.color,
decoration:
event.redacted ? TextDecoration.lineThrough : null,
),
),
if (counter != 0)
Text(
counter == 1
? L10n.of(context).oneMoreEvent
: L10n.of(context).xMoreEvents(counter.toString()),
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
],
),
),
),