design: Hide unimportant state events instead of folding

This commit is contained in:
Christian Pauly 2022-10-15 10:38:06 +02:00
commit b642f89738
13 changed files with 125 additions and 161 deletions

View file

@ -22,7 +22,6 @@ class Message extends StatelessWidget {
final void Function(Event)? onAvatarTab;
final void Function(Event)? onInfoTab;
final void Function(String)? scrollToEventId;
final void Function(String) unfold;
final void Function(SwipeDirection) onSwipe;
final bool longPressSelect;
final bool selected;
@ -36,7 +35,6 @@ class Message extends StatelessWidget {
this.onAvatarTab,
this.scrollToEventId,
required this.onSwipe,
required this.unfold,
this.selected = false,
required this.timeline,
Key? key})
@ -57,7 +55,7 @@ class Message extends StatelessWidget {
if (event.type.startsWith('m.call.')) {
return Container();
}
return StateMessage(event, unfold: unfold);
return StateMessage(event);
}
if (event.type == EventTypes.Message &&

View file

@ -8,9 +8,7 @@ import '../../../config/app_config.dart';
class StateMessage extends StatelessWidget {
final Event event;
final void Function(String) unfold;
const StateMessage(this.event, {required this.unfold, Key? key})
: super(key: key);
const StateMessage(this.event, {Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -25,48 +23,43 @@ class StateMessage extends StatelessWidget {
vertical: 4.0,
),
child: Center(
child: InkWell(
onTap: counter != 0 ? () => unfold(event.eventId) : null,
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.grey.shade900,
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FutureBuilder<String>(
future: event
.calcLocalizedBody(MatrixLocals(L10n.of(context)!)),
builder: (context, snapshot) {
return Text(
snapshot.data ??
event.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!)),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14 * AppConfig.fontSizeFactor,
color: Theme.of(context).textTheme.bodyText2!.color,
decoration: event.redacted
? TextDecoration.lineThrough
: null,
),
);
}),
if (counter != 0)
Text(
L10n.of(context)!.moreEvents(counter),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14 * AppConfig.fontSizeFactor,
),
child: Container(
padding: const EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: Colors.grey.shade900,
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FutureBuilder<String>(
future:
event.calcLocalizedBody(MatrixLocals(L10n.of(context)!)),
builder: (context, snapshot) {
return Text(
snapshot.data ??
event.calcLocalizedBodyFallback(
MatrixLocals(L10n.of(context)!)),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 14 * AppConfig.fontSizeFactor,
color: Theme.of(context).textTheme.bodyText2!.color,
decoration:
event.redacted ? TextDecoration.lineThrough : null,
),
);
}),
if (counter != 0)
Text(
L10n.of(context)!.moreEvents(counter),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14 * AppConfig.fontSizeFactor,
),
],
),
),
],
),
),
),