[ImageFooter] Fix photosModalBottomSheet

Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
Sahil Kumar
2021-01-14 17:15:10 +05:30
parent ebc5ada241
commit 2e31ed077b
+47 -38
View File
@@ -174,29 +174,40 @@ class _ImageFooterState extends State<ImageFooter> {
showModalBottomSheet(
context: context,
barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16.0),
backgroundColor: StreamChatTheme.of(context).colorTheme.white,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: const BorderRadius.only(
topLeft: const Radius.circular(16.0),
topRight: const Radius.circular(16.0),
),
),
builder: (context) {
return Column(
final crossAxisCount = 3;
final noOfRowToShowInitially =
widget.mediaAttachments.length > 3 ? 2 : 1;
final size = MediaQuery.of(context).size;
final initialChildSize =
48 + (size.width * noOfRowToShowInitially) / crossAxisCount;
return DraggableScrollableSheet(
expand: false,
initialChildSize: initialChildSize / size.height,
builder: (context, scrollController) {
return SingleChildScrollView(
controller: scrollController,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
decoration: BoxDecoration(
color: StreamChatTheme.of(context).colorTheme.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(16.0),
topLeft: Radius.circular(16.0),
)),
child: Stack(
Stack(
children: [
Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'Photos',
style:
StreamChatTheme.of(context).textTheme.headlineBold,
style: StreamChatTheme.of(context)
.textTheme
.headlineBold,
),
),
),
@@ -211,24 +222,27 @@ class _ImageFooterState extends State<ImageFooter> {
),
],
),
),
Container(
color: StreamChatTheme.of(context).colorTheme.white,
Flexible(
child: GridView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
physics: const NeverScrollableScrollPhysics(),
itemCount: widget.mediaAttachments.length,
padding: const EdgeInsets.all(1),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: crossAxisCount,
mainAxisSpacing: 2.0,
crossAxisSpacing: 2.0,
),
itemBuilder: (context, index) {
Widget media;
final attachment = widget.mediaAttachments[index];
if (widget.mediaAttachments[position].type == 'video') {
if (attachment.type == 'video') {
var controllerPackage = widget.videoPackages[
videoAttachments
.indexOf(widget.mediaAttachments[position])];
videoAttachments.indexOf(attachment)];
media = InkWell(
onTap: () {
widget.mediaSelectedCallBack(position);
},
onTap: () => widget.mediaSelectedCallBack(index),
child: FittedBox(
fit: BoxFit.cover,
child: Chewie(
@@ -238,22 +252,16 @@ class _ImageFooterState extends State<ImageFooter> {
);
} else {
media = InkWell(
onTap: () {
widget.mediaSelectedCallBack(position);
},
child: Padding(
padding: const EdgeInsets.all(1.0),
onTap: () => widget.mediaSelectedCallBack(index),
child: AspectRatio(
child: CachedNetworkImage(
imageUrl: widget
.mediaAttachments[position].imageUrl ??
widget.mediaAttachments[position].assetUrl ??
widget.mediaAttachments[position].thumbUrl,
imageUrl: attachment.imageUrl ??
attachment.assetUrl ??
attachment.thumbUrl,
fit: BoxFit.cover,
),
aspectRatio: 1.0,
),
),
);
}
@@ -283,7 +291,8 @@ class _ImageFooterState extends State<ImageFooter> {
padding: const EdgeInsets.all(1),
child: UserAvatar(
user: widget.message.user,
constraints: BoxConstraints.tight(Size(24, 24)),
constraints:
BoxConstraints.tight(Size(24, 24)),
showOnlineStatus: false,
),
),
@@ -291,12 +300,12 @@ class _ImageFooterState extends State<ImageFooter> {
],
);
},
itemCount: widget.mediaAttachments.length,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3),
),
),
],
),
);
},
);
},
);