mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-17 08:55:12 +00:00
refactor: Remove unnecessary FutureBuilder
This commit is contained in:
parent
c447e15949
commit
8a64bdd82d
5 changed files with 76 additions and 129 deletions
|
@ -251,23 +251,15 @@ class MessageContent extends StatelessWidget {
|
|||
final bigEmotes = event.onlyEmotes &&
|
||||
event.numberEmotes > 0 &&
|
||||
event.numberEmotes <= 10;
|
||||
return FutureBuilder<String>(
|
||||
future: event.calcLocalizedBody(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
hideReply: true,
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
return Linkify(
|
||||
text: snapshot.data ??
|
||||
event.calcLocalizedBodyFallback(
|
||||
text: event.calcLocalizedBodyFallback(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
hideReply: true,
|
||||
),
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontSize: bigEmotes ? fontSize * 3 : fontSize,
|
||||
decoration:
|
||||
event.redacted ? TextDecoration.lineThrough : null,
|
||||
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
||||
),
|
||||
options: const LinkifyOptions(humanize: false),
|
||||
linkStyle: TextStyle(
|
||||
|
@ -278,8 +270,6 @@ class MessageContent extends StatelessWidget {
|
|||
),
|
||||
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
case EventTypes.CallInvite:
|
||||
return FutureBuilder<User?>(
|
||||
|
|
|
@ -21,22 +21,15 @@ class StateMessage extends StatelessWidget {
|
|||
color: Theme.of(context).colorScheme.background,
|
||||
borderRadius: BorderRadius.circular(AppConfig.borderRadius / 2),
|
||||
),
|
||||
child: FutureBuilder<String>(
|
||||
future: event.calcLocalizedBody(MatrixLocals(L10n.of(context)!)),
|
||||
builder: (context, snapshot) {
|
||||
return Text(
|
||||
snapshot.data ??
|
||||
child: Text(
|
||||
event.calcLocalizedBodyFallback(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12 * AppConfig.fontSizeFactor,
|
||||
decoration:
|
||||
event.redacted ? TextDecoration.lineThrough : null,
|
||||
decoration: event.redacted ? TextDecoration.lineThrough : null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -63,15 +63,8 @@ class PinnedEvents extends StatelessWidget {
|
|||
future: controller.room.getEventById(pinnedEventIds.last),
|
||||
builder: (context, snapshot) {
|
||||
final event = snapshot.data;
|
||||
return FutureBuilder<String>(
|
||||
future: event?.calcLocalizedBody(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
withSenderNamePrefix: true,
|
||||
hideReply: true,
|
||||
),
|
||||
builder: (context, snapshot) => ChatAppBarListTile(
|
||||
title: snapshot.data ??
|
||||
event?.calcLocalizedBodyFallback(
|
||||
return ChatAppBarListTile(
|
||||
title: event?.calcLocalizedBodyFallback(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
withSenderNamePrefix: true,
|
||||
hideReply: true,
|
||||
|
@ -83,13 +76,11 @@ class PinnedEvents extends StatelessWidget {
|
|||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
icon: const Icon(Icons.push_pin),
|
||||
tooltip: L10n.of(context)!.unpin,
|
||||
onPressed:
|
||||
controller.room.canSendEvent(EventTypes.RoomPinnedEvents)
|
||||
onPressed: controller.room.canSendEvent(EventTypes.RoomPinnedEvents)
|
||||
? () => controller.unpinEvent(event!.eventId)
|
||||
: null,
|
||||
),
|
||||
onTap: () => _displayPinnedEventsDialog(context),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
@ -66,15 +66,7 @@ class _EditContent extends StatelessWidget {
|
|||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
Container(width: 15.0),
|
||||
FutureBuilder<String>(
|
||||
future: event.calcLocalizedBody(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
withSenderNamePrefix: false,
|
||||
hideReply: true,
|
||||
),
|
||||
builder: (context, snapshot) {
|
||||
return Text(
|
||||
snapshot.data ??
|
||||
Text(
|
||||
event.calcLocalizedBodyFallback(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
withSenderNamePrefix: false,
|
||||
|
@ -85,8 +77,6 @@ class _EditContent extends StatelessWidget {
|
|||
style: TextStyle(
|
||||
color: Theme.of(context).textTheme.bodyMedium!.color,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
@ -226,27 +226,12 @@ class ChatListItem extends StatelessWidget {
|
|||
maxLines: 1,
|
||||
softWrap: false,
|
||||
)
|
||||
: FutureBuilder<String>(
|
||||
future: room.lastEvent?.calcLocalizedBody(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
hideReply: true,
|
||||
hideEdit: true,
|
||||
plaintextBody: true,
|
||||
removeMarkdown: true,
|
||||
withSenderNamePrefix: !isDirectChat ||
|
||||
directChatMatrixId !=
|
||||
room.lastEvent?.senderId,
|
||||
) ??
|
||||
Future.value(L10n.of(context)!.emptyChat),
|
||||
builder: (context, snapshot) {
|
||||
return Text(
|
||||
: Text(
|
||||
room.membership == Membership.invite
|
||||
? isDirectChat
|
||||
? L10n.of(context)!.invitePrivateChat
|
||||
: L10n.of(context)!.inviteGroupChat
|
||||
: snapshot.data ??
|
||||
room.lastEvent
|
||||
?.calcLocalizedBodyFallback(
|
||||
: room.lastEvent?.calcLocalizedBodyFallback(
|
||||
MatrixLocals(L10n.of(context)!),
|
||||
hideReply: true,
|
||||
hideEdit: true,
|
||||
|
@ -269,8 +254,6 @@ class ChatListItem extends StatelessWidget {
|
|||
? TextDecoration.lineThrough
|
||||
: null,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
|
|
Loading…
Reference in a new issue