@@ -28,6 +28,7 @@ import 'package:flutter/material.dart';
2828
2929import '../extensions/extensions.dart' ;
3030import '../models/chat_bubble.dart' ;
31+ import '../models/config_models/feature_active_config.dart' ;
3132import '../models/config_models/image_message_configuration.dart' ;
3233import '../models/config_models/message_reaction_configuration.dart' ;
3334import 'reaction_widget.dart' ;
@@ -44,6 +45,7 @@ class ImageMessageView extends StatelessWidget {
4445 this .outgoingChatBubbleConfig,
4546 this .highlightImage = false ,
4647 this .highlightScale = 1.2 ,
48+ this .featureActiveConfig,
4749 }) : super (key: key);
4850
4951 /// Provides configuration of chat bubble appearance from other user of chat.
@@ -70,6 +72,9 @@ class ImageMessageView extends StatelessWidget {
7072 /// Provides scale of highlighted image when user taps on replied image.
7173 final double highlightScale;
7274
75+ /// Provides configuration of active features in chat.
76+ final FeatureActiveConfig ? featureActiveConfig;
77+
7378 String get imageUrl => message.message;
7479
7580 Widget get iconButton => ShareIcon (
@@ -80,7 +85,7 @@ class ImageMessageView extends StatelessWidget {
8085 @override
8186 Widget build (BuildContext context) {
8287 final borderRadius = imageMessageConfig? .borderRadius ??
83- const BorderRadius .all (Radius .circular (14 ));
88+ const BorderRadius .all (Radius .circular (10 ));
8489 final backgroundColor = isMessageBySender
8590 ? outgoingChatBubbleConfig? .color ?? Colors .purple
8691 : inComingChatBubbleConfig? .color ?? Colors .grey.shade500;
@@ -118,44 +123,75 @@ class ImageMessageView extends StatelessWidget {
118123 ),
119124 height: imageMessageConfig? .height ?? 200 ,
120125 width: imageMessageConfig? .width ?? 150 ,
121- child: ClipRRect (
122- borderRadius: borderRadius,
123- child: (() {
124- if (imageUrl.isUrl) {
125- return Image .network (
126- imageUrl,
127- fit: BoxFit .fitHeight,
128- loadingBuilder: (context, child, loadingProgress) {
129- if (loadingProgress == null ) return child;
130- return Center (
131- child: CircularProgressIndicator (
132- value: loadingProgress.expectedTotalBytes !=
133- null
134- ? loadingProgress.cumulativeBytesLoaded /
135- loadingProgress.expectedTotalBytes!
136- : null ,
137- ),
126+ child: Stack (
127+ children: [
128+ ClipRRect (
129+ borderRadius: borderRadius,
130+ child: (() {
131+ if (imageUrl.isUrl) {
132+ return Image .network (
133+ imageUrl,
134+ fit: BoxFit .fitHeight,
135+ loadingBuilder: (context, child, loadingProgress) {
136+ if (loadingProgress == null ) return child;
137+ return Center (
138+ child: CircularProgressIndicator (
139+ value: loadingProgress.expectedTotalBytes !=
140+ null
141+ ? loadingProgress.cumulativeBytesLoaded /
142+ loadingProgress.expectedTotalBytes!
143+ : null ,
144+ ),
145+ );
146+ },
147+ );
148+ } else if (imageUrl.fromMemory) {
149+ return Image .memory (
150+ base64Decode (imageUrl
151+ .substring (imageUrl.indexOf ('base64' ) + 7 )),
152+ fit: BoxFit .fill,
138153 );
139- },
140- );
141- } else if (imageUrl.fromMemory) {
142- return Image .memory (
143- base64Decode (imageUrl
144- .substring (imageUrl.indexOf ('base64' ) + 7 )),
145- fit: BoxFit .fill,
146- );
147- } else {
148- return kIsWeb
149- ? Image .network (
150- imageUrl,
151- fit: BoxFit .fill,
152- )
153- : Image .file (
154- File (imageUrl),
155- fit: BoxFit .fill,
156- );
157- }
158- }()),
154+ } else {
155+ return kIsWeb
156+ ? Image .network (
157+ imageUrl,
158+ fit: BoxFit .fill,
159+ )
160+ : Image .file (
161+ File (imageUrl),
162+ fit: BoxFit .fill,
163+ );
164+ }
165+ }()),
166+ ),
167+ if (featureActiveConfig? .showTimestamp ?? false )
168+ Positioned (
169+ right: 8 ,
170+ bottom: 8 ,
171+ child: Container (
172+ padding: const EdgeInsets .symmetric (
173+ horizontal: 6 ,
174+ vertical: 2 ,
175+ ),
176+ decoration: BoxDecoration (
177+ color: Colors .black45,
178+ borderRadius: BorderRadius .circular (10 ),
179+ ),
180+ child: Text (
181+ message.createdAt.getTimeFromDateTime,
182+ style: const TextStyle (
183+ color: Colors .white,
184+ fontSize: 10 ,
185+ fontWeight: FontWeight .w500,
186+ ).merge (
187+ isMessageBySender
188+ ? outgoingChatBubbleConfig? .messageTimeTextStyle
189+ : inComingChatBubbleConfig? .messageTimeTextStyle,
190+ ),
191+ ),
192+ ),
193+ ),
194+ ],
159195 ),
160196 ),
161197 ),
0 commit comments