treewide: use dot shorthands where possible
Now this feature is stable, we should use it. I might have missed some usecases, but these can be added in future commits.
This commit is contained in:
parent
6281c1d13a
commit
d2ec5f035b
67 changed files with 391 additions and 534 deletions
|
|
@ -64,12 +64,11 @@ class EventRenderer extends ConsumerWidget {
|
|||
textOnly: textOnly,
|
||||
),
|
||||
|
||||
MembershipContent content =>
|
||||
event.previousContent is MembershipContent &&
|
||||
(event.previousContent as MembershipContent).status ==
|
||||
content.status
|
||||
? null
|
||||
: MembershipRenderer(event),
|
||||
MembershipContent content => switch (event.previousContent) {
|
||||
MembershipContent(:final status) =>
|
||||
status == content.status ? null : MembershipRenderer(event),
|
||||
_ => null,
|
||||
},
|
||||
|
||||
AvatarContent() => GenericEventRenderer(Icons.interests, [
|
||||
MessageDisplayname(event),
|
||||
|
|
@ -101,10 +100,10 @@ class EventRenderer extends ConsumerWidget {
|
|||
MessageDisplayname(event),
|
||||
Text(
|
||||
"changed the room's history visibility to ${switch (historyVisibility) {
|
||||
HistoryVisibility.invited => "since invited",
|
||||
HistoryVisibility.joined => "since joined",
|
||||
HistoryVisibility.shared => "all history visible (shared)",
|
||||
HistoryVisibility.worldReadable => "all history visible (world readable)",
|
||||
.invited => "since invited",
|
||||
.joined => "since joined",
|
||||
.shared => "all history visible (shared)",
|
||||
.worldReadable => "all history visible (world readable)",
|
||||
}}",
|
||||
),
|
||||
]),
|
||||
|
|
@ -158,7 +157,7 @@ class EventRenderer extends ConsumerWidget {
|
|||
);
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
if (child != null) ...[
|
||||
if (textOnly)
|
||||
|
|
@ -168,7 +167,7 @@ class EventRenderer extends ConsumerWidget {
|
|||
onSecondaryTapUp: contextMenuCallback,
|
||||
onLongPressStart: contextMenuCallback,
|
||||
child: Padding(
|
||||
padding: isGrouped ? EdgeInsets.zero : EdgeInsets.only(top: 8),
|
||||
padding: isGrouped ? .zero : .only(top: 8),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
|
|
@ -183,12 +182,7 @@ class EventRenderer extends ConsumerWidget {
|
|||
color: theme.colorScheme.error,
|
||||
),
|
||||
),
|
||||
].map(
|
||||
(child) => Padding(
|
||||
padding: EdgeInsetsGeometry.only(left: 4),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
].map((child) => Padding(padding: .only(left: 4), child: child)),
|
||||
],
|
||||
] else if (textOnly)
|
||||
Text("Unknown event type", style: errorStyle),
|
||||
|
|
|
|||
|
|
@ -7,14 +7,11 @@ class GenericEventRenderer extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) => Padding(
|
||||
padding: EdgeInsets.only(bottom: 8),
|
||||
padding: .only(bottom: 8),
|
||||
child: Row(
|
||||
spacing: 8,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Icon(icon),
|
||||
),
|
||||
Padding(padding: .symmetric(horizontal: 4), child: Icon(icon)),
|
||||
Expanded(child: Wrap(spacing: 4, children: children)),
|
||||
],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import "package:nexus/helpers/extensions/show_user_popover.dart";
|
|||
import "package:nexus/helpers/extensions/string_to_color.dart";
|
||||
import "package:nexus/models/content/membership.dart";
|
||||
import "package:nexus/models/event.dart";
|
||||
import "package:nexus/models/membership_status.dart";
|
||||
import "package:nexus/widgets/lazy_loading/message_displayname.dart";
|
||||
import "package:nexus/widgets/renderers/generic_event.dart";
|
||||
|
||||
|
|
@ -29,24 +28,21 @@ class MembershipRenderer extends StatelessWidget {
|
|||
globalPosition: details.globalPosition,
|
||||
),
|
||||
child: Text(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
overflow: .ellipsis,
|
||||
content.displayName ?? event.stateKey!.localpart,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
color: event.sender.colorHash,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
style: .new(color: event.sender.colorHash, fontWeight: .bold),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
overflow: TextOverflow.ellipsis,
|
||||
overflow: .ellipsis,
|
||||
maxLines: 1,
|
||||
"${switch (content.status) {
|
||||
MembershipStatus.invite => "was invited to",
|
||||
MembershipStatus.join => "joined",
|
||||
MembershipStatus.leave => event.sender == event.stateKey ? "left" : (event.unsigned["prev_content"]?["membership"] == "ban" ? "was unbanned from" : "was kicked from"),
|
||||
MembershipStatus.ban => "was banned from",
|
||||
MembershipStatus.knock => "asked to join",
|
||||
.invite => "was invited to",
|
||||
.join => "joined",
|
||||
.leave => event.sender == event.stateKey ? "left" : (event.unsigned["prev_content"]?["membership"] == "ban" ? "was unbanned from" : "was kicked from"),
|
||||
.ban => "was banned from",
|
||||
.knock => "asked to join",
|
||||
}} the room${event.sender == event.stateKey ? "" : " by "}",
|
||||
),
|
||||
if (event.sender != event.stateKey) MessageDisplayname(event),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import "package:nexus/models/content/encrypted.dart";
|
|||
import "package:nexus/models/content/message.dart";
|
||||
import "package:nexus/models/content/sticker.dart";
|
||||
import "package:nexus/models/event.dart";
|
||||
import "package:nexus/models/requests/get_event_request.dart";
|
||||
import "package:nexus/widgets/file_card.dart";
|
||||
import "package:nexus/widgets/html/html.dart";
|
||||
import "package:nexus/widgets/lazy_loading/message_avatar.dart";
|
||||
|
|
@ -49,19 +48,19 @@ class MessageRenderer extends ConsumerWidget {
|
|||
child: Text(
|
||||
format(event.timestamp),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
overflow: .ellipsis,
|
||||
style: theme.textTheme.labelSmall?.copyWith(color: Colors.grey),
|
||||
),
|
||||
);
|
||||
|
||||
final textStyle = TextStyle(
|
||||
fontSize: event.localContent?.bigEmoji == true ? 32 : null,
|
||||
fontStyle: event.content is EmoteMessageContent ? FontStyle.italic : null,
|
||||
fontStyle: event.content is EmoteMessageContent ? .italic : null,
|
||||
);
|
||||
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: .start,
|
||||
mainAxisSize: .min,
|
||||
spacing: 8,
|
||||
children: [
|
||||
if (!textOnly)
|
||||
|
|
@ -72,7 +71,7 @@ class MessageRenderer extends ConsumerWidget {
|
|||
Flexible(
|
||||
child: Column(
|
||||
spacing: 4,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
if (!isGrouped && !textOnly)
|
||||
Row(
|
||||
|
|
@ -83,7 +82,7 @@ class MessageRenderer extends ConsumerWidget {
|
|||
],
|
||||
),
|
||||
Card(
|
||||
margin: textOnly ? EdgeInsets.zero : EdgeInsets.only(bottom: 4),
|
||||
margin: textOnly ? .zero : .only(bottom: 4),
|
||||
color: textOnly
|
||||
? Colors.transparent
|
||||
: ref.watch(
|
||||
|
|
@ -99,24 +98,21 @@ class MessageRenderer extends ConsumerWidget {
|
|||
elevation: textOnly ? 0 : null,
|
||||
|
||||
child: Padding(
|
||||
padding: textOnly ? EdgeInsets.zero : EdgeInsets.all(12),
|
||||
padding: textOnly ? .zero : .all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
if (!textOnly && event.replyTo != null)
|
||||
Card(
|
||||
margin: EdgeInsets.only(bottom: 8),
|
||||
margin: .only(bottom: 8),
|
||||
color: theme.colorScheme.surfaceContainerHigh,
|
||||
child: InkWell(
|
||||
onTap: onTapReply,
|
||||
child: Padding(
|
||||
padding: EdgeInsetsGeometry.symmetric(
|
||||
vertical: 8,
|
||||
horizontal: 12,
|
||||
),
|
||||
padding: .symmetric(vertical: 8, horizontal: 12),
|
||||
child: switch (ref.watch(
|
||||
EventController.provider(
|
||||
GetEventRequest(
|
||||
.new(
|
||||
roomId: event.roomId,
|
||||
eventId: event.replyTo!,
|
||||
),
|
||||
|
|
@ -145,12 +141,10 @@ class MessageRenderer extends ConsumerWidget {
|
|||
? Text(
|
||||
body,
|
||||
maxLines: maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
overflow: .ellipsis,
|
||||
)
|
||||
: ConstrainedBox(
|
||||
constraints: BoxConstraints.loose(
|
||||
Size.square(200),
|
||||
),
|
||||
constraints: .loose(.square(200)),
|
||||
child: MessageImage(
|
||||
url.mxcToHttps(
|
||||
ref.watch(
|
||||
|
|
@ -199,9 +193,9 @@ class MessageRenderer extends ConsumerWidget {
|
|||
:final formattedBody,
|
||||
:final format,
|
||||
) => Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: .start,
|
||||
children: [
|
||||
format == MessageFormat.html && !textOnly
|
||||
format == .html && !textOnly
|
||||
? Html(
|
||||
roomId: event.roomId,
|
||||
textStyle: textStyle,
|
||||
|
|
@ -243,9 +237,7 @@ class MessageRenderer extends ConsumerWidget {
|
|||
),
|
||||
)) {
|
||||
final url? => ConstrainedBox(
|
||||
constraints: BoxConstraints.loose(
|
||||
Size.square(500),
|
||||
),
|
||||
constraints: .loose(.square(500)),
|
||||
child: switch (event.content) {
|
||||
VideoMessageContent(:final info) =>
|
||||
VideoPlayer(url, info),
|
||||
|
|
@ -286,7 +278,7 @@ class MessageRenderer extends ConsumerWidget {
|
|||
),
|
||||
MessageContent(:final body) => Row(
|
||||
spacing: 8,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
Text("Unknown message type:", style: errorStyle),
|
||||
Text(body),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue