migrate ui

This commit is contained in:
Salvatore Giordano
2021-04-30 14:58:50 +02:00
parent 2c02f0f631
commit 34888d0fff
103 changed files with 2622 additions and 2455 deletions
@@ -9,17 +9,15 @@ import '../stream_svg_icon.dart';
import 'attachment_widget.dart';
class GiphyAttachment extends AttachmentWidget {
final MessageTheme messageTheme;
final ShowMessageCallback onShowMessage;
final ValueChanged<ReturnActionType> onReturnAction;
final VoidCallback onAttachmentTap;
final ShowMessageCallback? onShowMessage;
final ValueChanged<ReturnActionType>? onReturnAction;
final VoidCallback? onAttachmentTap;
const GiphyAttachment({
Key key,
@required Message message,
@required Attachment attachment,
Size size,
this.messageTheme,
Key? key,
required Message message,
required Attachment attachment,
Size? size,
this.onShowMessage,
this.onReturnAction,
this.onAttachmentTap,
@@ -29,10 +27,10 @@ class GiphyAttachment extends AttachmentWidget {
Widget build(BuildContext context) {
final imageUrl =
attachment.thumbUrl ?? attachment.imageUrl ?? attachment.assetUrl;
if (imageUrl == null && source == AttachmentSource.network) {
if (imageUrl == null) {
return AttachmentError();
}
if (attachment.actions != null) {
if (attachment.actions.isNotEmpty) {
return _buildSendingAttachment(context, imageUrl);
}
return _buildSentAttachment(context, imageUrl);
@@ -73,7 +71,7 @@ class GiphyAttachment extends AttachmentWidget {
if (attachment.title != null)
Flexible(
child: Text(
attachment.title,
attachment.title!,
style: TextStyle(
color: StreamChatTheme.of(context)
.colorTheme
@@ -199,10 +197,11 @@ class GiphyAttachment extends AttachmentWidget {
child: Text(
'Send',
style: TextStyle(
color: StreamChatTheme.of(context)
.colorTheme
.accentBlue,
fontWeight: FontWeight.bold),
color: StreamChatTheme.of(context)
.colorTheme
.accentBlue,
fontWeight: FontWeight.bold,
),
),
),
),
@@ -259,8 +258,7 @@ class GiphyAttachment extends AttachmentWidget {
channel: channel,
child: FullScreenMedia(
mediaAttachments: [attachment],
userName: message.user.name,
sentAt: message.createdAt,
userName: message.user?.name,
message: message,
onShowMessage: onShowMessage,
),
@@ -268,7 +266,7 @@ class GiphyAttachment extends AttachmentWidget {
},
),
);
if (res != null) onReturnAction(res);
if (res != null) onReturnAction?.call(res);
}
Widget _buildSentAttachment(BuildContext context, String imageUrl) {
@@ -282,14 +280,13 @@ class GiphyAttachment extends AttachmentWidget {
channel: channel,
child: FullScreenMedia(
mediaAttachments: [attachment],
userName: message.user.name,
sentAt: message.createdAt,
userName: message.user?.name,
message: message,
onShowMessage: onShowMessage,
),
);
}));
if (res != null) onReturnAction(res);
if (res != null) onReturnAction!(res);
},
child: Stack(
children: [
@@ -297,16 +294,17 @@ class GiphyAttachment extends AttachmentWidget {
height: size?.height,
width: size?.width,
placeholder: (_, __) {
final image = Image.asset(
'images/placeholder.png',
fit: BoxFit.cover,
package: 'stream_chat_flutter',
);
final colorTheme = StreamChatTheme.of(context).colorTheme;
return Shimmer.fromColors(
baseColor:
StreamChatTheme.of(context).colorTheme.greyGainsboro,
highlightColor:
StreamChatTheme.of(context).colorTheme.whiteSmoke,
child: Image.asset(
'images/placeholder.png',
fit: BoxFit.cover,
package: 'stream_chat_flutter',
),
baseColor: colorTheme.greyGainsboro,
highlightColor: colorTheme.whiteSmoke,
child: image,
);
},
imageUrl: imageUrl,