feat: Collapse all state events by default
parent
3d0a3ee226
commit
103cb8328d
@ -1,46 +1,84 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
|
|
||||||
|
import 'package:fluffychat/config/themes.dart';
|
||||||
import 'package:fluffychat/l10n/l10n.dart';
|
import 'package:fluffychat/l10n/l10n.dart';
|
||||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||||
import '../../../config/app_config.dart';
|
import '../../../config/app_config.dart';
|
||||||
|
|
||||||
class StateMessage extends StatelessWidget {
|
class StateMessage extends StatelessWidget {
|
||||||
final Event event;
|
final Event event;
|
||||||
const StateMessage(this.event, {super.key});
|
final void Function()? onExpand;
|
||||||
|
final bool isCollapsed;
|
||||||
|
const StateMessage(
|
||||||
|
this.event, {
|
||||||
|
this.onExpand,
|
||||||
|
this.isCollapsed = false,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final theme = Theme.of(context);
|
final theme = Theme.of(context);
|
||||||
return Padding(
|
return AnimatedSize(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
duration: FluffyThemes.animationDuration,
|
||||||
child: Center(
|
curve: FluffyThemes.animationCurve,
|
||||||
child: Padding(
|
child: isCollapsed
|
||||||
padding: const EdgeInsets.all(4),
|
? const SizedBox.shrink()
|
||||||
child: Material(
|
: Padding(
|
||||||
color: theme.colorScheme.surface.withAlpha(128),
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 3),
|
child: Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding: const EdgeInsets.all(4),
|
||||||
const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
|
child: Material(
|
||||||
child: Text(
|
color: theme.colorScheme.surface.withAlpha(128),
|
||||||
event.calcLocalizedBodyFallback(
|
borderRadius:
|
||||||
MatrixLocals(L10n.of(context)),
|
BorderRadius.circular(AppConfig.borderRadius / 3),
|
||||||
),
|
child: Padding(
|
||||||
textAlign: TextAlign.center,
|
padding: const EdgeInsets.symmetric(
|
||||||
maxLines: 2,
|
horizontal: 8.0,
|
||||||
overflow: TextOverflow.ellipsis,
|
vertical: 4.0,
|
||||||
style: TextStyle(
|
),
|
||||||
fontSize: 12 * AppConfig.fontSizeFactor,
|
child: Text.rich(
|
||||||
decoration:
|
TextSpan(
|
||||||
event.redacted ? TextDecoration.lineThrough : null,
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: event.calcLocalizedBodyFallback(
|
||||||
|
MatrixLocals(L10n.of(context)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (onExpand != null) ...[
|
||||||
|
const TextSpan(
|
||||||
|
text: ' + ',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
TextSpan(
|
||||||
|
style: TextStyle(
|
||||||
|
color: theme.colorScheme.primary,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = onExpand,
|
||||||
|
text: L10n.of(context).moreEvents,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12 * AppConfig.fontSizeFactor,
|
||||||
|
decoration: event.redacted
|
||||||
|
? TextDecoration.lineThrough
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue