diff --git a/lib/screens/channel/call/call.dart b/lib/screens/channel/call/call.dart index d9eb481..1dc8a2b 100644 --- a/lib/screens/channel/call/call.dart +++ b/lib/screens/channel/call/call.dart @@ -56,8 +56,7 @@ class _CallScreenState extends State { color: Theme.of(context).colorScheme.surface, child: Scaffold( appBar: AppBar( - centerTitle: false, - titleSpacing: SolianTheme.titleSpacing(context), + centerTitle: true, toolbarHeight: SolianTheme.toolbarHeight(context), title: RichText( textAlign: TextAlign.center, diff --git a/lib/widgets/attachments/attachment_list.dart b/lib/widgets/attachments/attachment_list.dart index c1875eb..b6888ee 100644 --- a/lib/widgets/attachments/attachment_list.dart +++ b/lib/widgets/attachments/attachment_list.dart @@ -12,14 +12,17 @@ class AttachmentList extends StatefulWidget { final String parentId; final List attachmentsId; final bool divided; - final double dividedPadding; + + final double? width; + final double? viewport; const AttachmentList({ super.key, required this.parentId, required this.attachmentsId, this.divided = false, - this.dividedPadding = 16, + this.width, + this.viewport, }); @override @@ -101,7 +104,7 @@ class _AttachmentListState extends State { Widget buildEntry(Attachment element, int idx) { return GestureDetector( child: Container( - width: MediaQuery.of(context).size.width, + width: widget.width ?? MediaQuery.of(context).size.width, decoration: BoxDecoration( color: Theme.of(context).colorScheme.surfaceContainerHigh, ), @@ -198,7 +201,7 @@ class _AttachmentListState extends State { return CarouselSlider.builder( options: CarouselOptions( aspectRatio: _aspectRatio, - viewportFraction: 1, + viewportFraction: widget.viewport ?? (widget.divided ? 0.9 : 1), enableInfiniteScroll: false, ), itemCount: _attachmentsMeta.length, @@ -240,7 +243,7 @@ class _AttachmentListState extends State { borderRadius: radius, child: buildEntry(element, idx), ), - ).paddingSymmetric(horizontal: widget.dividedPadding); + ).paddingSymmetric(horizontal: widget.divided ? 4 : 0); } else { return buildEntry(element, idx); } diff --git a/lib/widgets/chat/chat_message.dart b/lib/widgets/chat/chat_message.dart index 4ed005f..fd0a932 100644 --- a/lib/widgets/chat/chat_message.dart +++ b/lib/widgets/chat/chat_message.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; @@ -72,35 +74,37 @@ class ChatMessage extends StatelessWidget { ); } - return Markdown( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - data: snapshot.data ?? '', - padding: const EdgeInsets.all(0), - onTapLink: (text, href, title) async { - if (href == null) return; - await launchUrlString( - href, - mode: LaunchMode.externalApplication, - ); - }, - ).paddingOnly( - left: 12, - right: 12, - top: 2, - bottom: hasAttachment ? 4 : 0, - ); + if (snapshot.data?.isNotEmpty ?? false) { + return Markdown( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + data: snapshot.data ?? '', + padding: const EdgeInsets.all(0), + onTapLink: (text, href, title) async { + if (href == null) return; + await launchUrlString( + href, + mode: LaunchMode.externalApplication, + ); + }, + ).paddingOnly( + left: 12, + right: 12, + top: 2, + bottom: hasAttachment ? 4 : 0, + ); + } else { + return const SizedBox(); + } }, ); } - @override - Widget build(BuildContext context) { - Widget widget; + Widget buildBody(BuildContext context) { if (isContentPreviewing) { - widget = buildContent(); + return buildContent(); } else if (isMerged) { - widget = Column( + return Column( children: [ buildContent().paddingOnly(left: 52), if (item.attachments?.isNotEmpty ?? false) @@ -112,7 +116,7 @@ class ChatMessage extends StatelessWidget { ], ); } else if (isReply) { - widget = Row( + return Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Transform.scale( @@ -130,7 +134,7 @@ class ChatMessage extends StatelessWidget { ], ); } else { - widget = Column( + return Column( key: Key('m${item.uuid}'), children: [ Row( @@ -152,25 +156,29 @@ class ChatMessage extends StatelessWidget { ], ).paddingSymmetric(horizontal: 12), buildContent(), + if (item.attachments?.isNotEmpty ?? false) + SizedBox( + width: min(MediaQuery.of(context).size.width, 640), + child: AttachmentList( + key: Key('m${item.uuid}attachments'), + parentId: item.uuid, + attachmentsId: item.attachments ?? List.empty(), + divided: true, + viewport: 1, + ), + ), ], ), ), ], ).paddingSymmetric(horizontal: 12), - if (item.attachments?.isNotEmpty ?? false) - AttachmentList( - key: Key('m${item.uuid}attachments'), - parentId: item.uuid, - attachmentsId: item.attachments ?? List.empty(), - ).paddingSymmetric(vertical: 4), ], ); } + } - if (item.isSending) { - return Opacity(opacity: 0.65, child: widget); - } else { - return widget; - } + @override + Widget build(BuildContext context) { + return buildBody(context); } } diff --git a/lib/widgets/posts/post_item.dart b/lib/widgets/posts/post_item.dart index 7918e4d..fd0b532 100644 --- a/lib/widgets/posts/post_item.dart +++ b/lib/widgets/posts/post_item.dart @@ -280,7 +280,7 @@ class _PostItemState extends State { }, ).paddingOnly( top: hasAttachment ? 10 : 6, - left: hasAttachment ? 16 : 60, + left: hasAttachment ? 24 : 60, right: 16, bottom: 10, ),