💄 Better attachment display
This commit is contained in:
parent
580d9c7151
commit
a0a002974c
@ -56,8 +56,7 @@ class _CallScreenState extends State<CallScreen> {
|
||||
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,
|
||||
|
@ -12,14 +12,17 @@ class AttachmentList extends StatefulWidget {
|
||||
final String parentId;
|
||||
final List<int> 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<AttachmentList> {
|
||||
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<AttachmentList> {
|
||||
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<AttachmentList> {
|
||||
borderRadius: radius,
|
||||
child: buildEntry(element, idx),
|
||||
),
|
||||
).paddingSymmetric(horizontal: widget.dividedPadding);
|
||||
).paddingSymmetric(horizontal: widget.divided ? 4 : 0);
|
||||
} else {
|
||||
return buildEntry(element, idx);
|
||||
}
|
||||
|
@ -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,6 +74,7 @@ class ChatMessage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
if (snapshot.data?.isNotEmpty ?? false) {
|
||||
return Markdown(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
@ -90,17 +93,18 @@ class ChatMessage extends StatelessWidget {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ class _PostItemState extends State<PostItem> {
|
||||
},
|
||||
).paddingOnly(
|
||||
top: hasAttachment ? 10 : 6,
|
||||
left: hasAttachment ? 16 : 60,
|
||||
left: hasAttachment ? 24 : 60,
|
||||
right: 16,
|
||||
bottom: 10,
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user