💄 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,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
centerTitle: false,
|
centerTitle: true,
|
||||||
titleSpacing: SolianTheme.titleSpacing(context),
|
|
||||||
toolbarHeight: SolianTheme.toolbarHeight(context),
|
toolbarHeight: SolianTheme.toolbarHeight(context),
|
||||||
title: RichText(
|
title: RichText(
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
|
@ -12,14 +12,17 @@ class AttachmentList extends StatefulWidget {
|
|||||||
final String parentId;
|
final String parentId;
|
||||||
final List<int> attachmentsId;
|
final List<int> attachmentsId;
|
||||||
final bool divided;
|
final bool divided;
|
||||||
final double dividedPadding;
|
|
||||||
|
final double? width;
|
||||||
|
final double? viewport;
|
||||||
|
|
||||||
const AttachmentList({
|
const AttachmentList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.parentId,
|
required this.parentId,
|
||||||
required this.attachmentsId,
|
required this.attachmentsId,
|
||||||
this.divided = false,
|
this.divided = false,
|
||||||
this.dividedPadding = 16,
|
this.width,
|
||||||
|
this.viewport,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -101,7 +104,7 @@ class _AttachmentListState extends State<AttachmentList> {
|
|||||||
Widget buildEntry(Attachment element, int idx) {
|
Widget buildEntry(Attachment element, int idx) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: MediaQuery.of(context).size.width,
|
width: widget.width ?? MediaQuery.of(context).size.width,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
color: Theme.of(context).colorScheme.surfaceContainerHigh,
|
||||||
),
|
),
|
||||||
@ -198,7 +201,7 @@ class _AttachmentListState extends State<AttachmentList> {
|
|||||||
return CarouselSlider.builder(
|
return CarouselSlider.builder(
|
||||||
options: CarouselOptions(
|
options: CarouselOptions(
|
||||||
aspectRatio: _aspectRatio,
|
aspectRatio: _aspectRatio,
|
||||||
viewportFraction: 1,
|
viewportFraction: widget.viewport ?? (widget.divided ? 0.9 : 1),
|
||||||
enableInfiniteScroll: false,
|
enableInfiniteScroll: false,
|
||||||
),
|
),
|
||||||
itemCount: _attachmentsMeta.length,
|
itemCount: _attachmentsMeta.length,
|
||||||
@ -240,7 +243,7 @@ class _AttachmentListState extends State<AttachmentList> {
|
|||||||
borderRadius: radius,
|
borderRadius: radius,
|
||||||
child: buildEntry(element, idx),
|
child: buildEntry(element, idx),
|
||||||
),
|
),
|
||||||
).paddingSymmetric(horizontal: widget.dividedPadding);
|
).paddingSymmetric(horizontal: widget.divided ? 4 : 0);
|
||||||
} else {
|
} else {
|
||||||
return buildEntry(element, idx);
|
return buildEntry(element, idx);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_animate/flutter_animate.dart';
|
import 'package:flutter_animate/flutter_animate.dart';
|
||||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
@ -72,35 +74,37 @@ class ChatMessage extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Markdown(
|
if (snapshot.data?.isNotEmpty ?? false) {
|
||||||
shrinkWrap: true,
|
return Markdown(
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
shrinkWrap: true,
|
||||||
data: snapshot.data ?? '',
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
padding: const EdgeInsets.all(0),
|
data: snapshot.data ?? '',
|
||||||
onTapLink: (text, href, title) async {
|
padding: const EdgeInsets.all(0),
|
||||||
if (href == null) return;
|
onTapLink: (text, href, title) async {
|
||||||
await launchUrlString(
|
if (href == null) return;
|
||||||
href,
|
await launchUrlString(
|
||||||
mode: LaunchMode.externalApplication,
|
href,
|
||||||
);
|
mode: LaunchMode.externalApplication,
|
||||||
},
|
);
|
||||||
).paddingOnly(
|
},
|
||||||
left: 12,
|
).paddingOnly(
|
||||||
right: 12,
|
left: 12,
|
||||||
top: 2,
|
right: 12,
|
||||||
bottom: hasAttachment ? 4 : 0,
|
top: 2,
|
||||||
);
|
bottom: hasAttachment ? 4 : 0,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
Widget buildBody(BuildContext context) {
|
||||||
Widget build(BuildContext context) {
|
|
||||||
Widget widget;
|
|
||||||
if (isContentPreviewing) {
|
if (isContentPreviewing) {
|
||||||
widget = buildContent();
|
return buildContent();
|
||||||
} else if (isMerged) {
|
} else if (isMerged) {
|
||||||
widget = Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
buildContent().paddingOnly(left: 52),
|
buildContent().paddingOnly(left: 52),
|
||||||
if (item.attachments?.isNotEmpty ?? false)
|
if (item.attachments?.isNotEmpty ?? false)
|
||||||
@ -112,7 +116,7 @@ class ChatMessage extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else if (isReply) {
|
} else if (isReply) {
|
||||||
widget = Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Transform.scale(
|
Transform.scale(
|
||||||
@ -130,7 +134,7 @@ class ChatMessage extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
widget = Column(
|
return Column(
|
||||||
key: Key('m${item.uuid}'),
|
key: Key('m${item.uuid}'),
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@ -152,25 +156,29 @@ class ChatMessage extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
).paddingSymmetric(horizontal: 12),
|
).paddingSymmetric(horizontal: 12),
|
||||||
buildContent(),
|
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),
|
).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) {
|
@override
|
||||||
return Opacity(opacity: 0.65, child: widget);
|
Widget build(BuildContext context) {
|
||||||
} else {
|
return buildBody(context);
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,7 +280,7 @@ class _PostItemState extends State<PostItem> {
|
|||||||
},
|
},
|
||||||
).paddingOnly(
|
).paddingOnly(
|
||||||
top: hasAttachment ? 10 : 6,
|
top: hasAttachment ? 10 : 6,
|
||||||
left: hasAttachment ? 16 : 60,
|
left: hasAttachment ? 24 : 60,
|
||||||
right: 16,
|
right: 16,
|
||||||
bottom: 10,
|
bottom: 10,
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user