refactor: Adjust state event design
This commit is contained in:
parent
4e2b185f5d
commit
fc052c84ac
5 changed files with 8 additions and 72 deletions
|
|
@ -325,6 +325,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"changedTheChatDescription": "{username} changed the chat description",
|
||||
"changedTheChatDescriptionTo": "{username} changed the chat description to: '{description}'",
|
||||
"@changedTheChatDescriptionTo": {
|
||||
"type": "String",
|
||||
|
|
@ -337,6 +338,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"changedTheChatName": "{username} changed the chat name",
|
||||
"changedTheChatNameTo": "{username} changed the chat name to: '{chatname}'",
|
||||
"@changedTheChatNameTo": {
|
||||
"type": "String",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import 'package:swipe_to_action/swipe_to_action.dart';
|
|||
import 'package:fluffychat/config/setting_keys.dart';
|
||||
import 'package:fluffychat/config/themes.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/pages/chat/events/room_creation_state_event.dart';
|
||||
import 'package:fluffychat/utils/adaptive_bottom_sheet.dart';
|
||||
import 'package:fluffychat/utils/date_time_extension.dart';
|
||||
import 'package:fluffychat/utils/file_description.dart';
|
||||
|
|
@ -91,9 +90,6 @@ class Message extends StatelessWidget {
|
|||
if (event.type.startsWith('m.call.')) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
if (event.type == EventTypes.RoomCreate) {
|
||||
return RoomCreationStateEvent(event: event);
|
||||
}
|
||||
return StateMessage(event, onExpand: onExpand, isCollapsed: isCollapsed);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
import 'package:fluffychat/utils/date_time_extension.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
|
||||
import 'package:fluffychat/widgets/avatar.dart';
|
||||
|
||||
class RoomCreationStateEvent extends StatelessWidget {
|
||||
final Event event;
|
||||
|
||||
const RoomCreationStateEvent({required this.event, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = L10n.of(context);
|
||||
final matrixLocals = MatrixLocals(l10n);
|
||||
final theme = Theme.of(context);
|
||||
final roomName = event.room.getLocalizedDisplayname(matrixLocals);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 32.0),
|
||||
child: Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 256),
|
||||
child: Material(
|
||||
color: theme.colorScheme.surfaceContainer,
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
Avatar(
|
||||
mxContent: event.room.avatar,
|
||||
name: roomName,
|
||||
size: Avatar.defaultSize * 2,
|
||||
),
|
||||
Text(
|
||||
roomName,
|
||||
style: theme.textTheme.bodyLarge,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'${event.originServerTs.localizedTime(context)} | ${l10n.countParticipants((event.room.summary.mJoinedMemberCount ?? 1) + (event.room.summary.mInvitedMemberCount ?? 0))}',
|
||||
style: theme.textTheme.labelSmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -52,10 +52,7 @@ class StateMessage extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
if (onExpand != null) ...[
|
||||
const TextSpan(
|
||||
text: ' + ',
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const TextSpan(text: '\n'),
|
||||
TextSpan(
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.primary,
|
||||
|
|
@ -70,7 +67,7 @@ class StateMessage extends StatelessWidget {
|
|||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12 * AppSettings.fontSizeFactor.value,
|
||||
fontSize: 11 * AppSettings.fontSizeFactor.value,
|
||||
decoration: event.redacted
|
||||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ class MatrixLocals extends MatrixLocalizations {
|
|||
}
|
||||
|
||||
@override
|
||||
String changedTheChatDescriptionTo(String senderName, String content) {
|
||||
return l10n.changedTheChatDescriptionTo(senderName, content);
|
||||
String changedTheChatDescriptionTo(String senderName, _) {
|
||||
return l10n.changedTheChatDescription(senderName);
|
||||
}
|
||||
|
||||
@override
|
||||
String changedTheChatNameTo(String senderName, String content) {
|
||||
return l10n.changedTheChatNameTo(senderName, content);
|
||||
String changedTheChatNameTo(String senderName, _) {
|
||||
return l10n.changedTheChatName(senderName);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue