lint changes
This commit is contained in:
@@ -1,17 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
import 'package:stream_chat_flutter/src/stream_chat_theme.dart';
|
||||||
|
|
||||||
|
/// List tile for [ChannelBottomSheet]
|
||||||
class OptionListTile extends StatelessWidget {
|
class OptionListTile extends StatelessWidget {
|
||||||
final String? title;
|
/// Constructor for creating [OptionListTile]
|
||||||
final Widget? leading;
|
|
||||||
final Widget? trailing;
|
|
||||||
final VoidCallback? onTap;
|
|
||||||
final Color? titleColor;
|
|
||||||
final Color? tileColor;
|
|
||||||
final Color? separatorColor;
|
|
||||||
final TextStyle? titleTextStyle;
|
|
||||||
|
|
||||||
const OptionListTile({
|
const OptionListTile({
|
||||||
|
Key? key,
|
||||||
this.title,
|
this.title,
|
||||||
this.leading,
|
this.leading,
|
||||||
this.trailing,
|
this.trailing,
|
||||||
@@ -20,61 +14,83 @@ class OptionListTile extends StatelessWidget {
|
|||||||
this.tileColor,
|
this.tileColor,
|
||||||
this.separatorColor,
|
this.separatorColor,
|
||||||
this.titleTextStyle,
|
this.titleTextStyle,
|
||||||
});
|
}) : super(key: key);
|
||||||
|
|
||||||
|
/// Title for tile
|
||||||
|
final String? title;
|
||||||
|
|
||||||
|
/// Leading widget (start)
|
||||||
|
final Widget? leading;
|
||||||
|
|
||||||
|
/// Trailing widget (end)
|
||||||
|
final Widget? trailing;
|
||||||
|
|
||||||
|
/// Callback when tile is tapped
|
||||||
|
final VoidCallback? onTap;
|
||||||
|
|
||||||
|
/// Title color
|
||||||
|
final Color? titleColor;
|
||||||
|
|
||||||
|
/// Background tile color
|
||||||
|
final Color? tileColor;
|
||||||
|
|
||||||
|
/// Separator color
|
||||||
|
final Color? separatorColor;
|
||||||
|
|
||||||
|
/// [TextStyle] to apply to [title]
|
||||||
|
final TextStyle? titleTextStyle;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => Column(
|
||||||
return Column(
|
children: [
|
||||||
children: [
|
Container(
|
||||||
Container(
|
color: separatorColor ??
|
||||||
color: separatorColor ??
|
StreamChatTheme.of(context).colorTheme.greyGainsboro,
|
||||||
StreamChatTheme.of(context).colorTheme.greyGainsboro,
|
height: 1,
|
||||||
height: 1,
|
),
|
||||||
),
|
Material(
|
||||||
Material(
|
color: tileColor ?? StreamChatTheme.of(context).colorTheme.white,
|
||||||
color: tileColor ?? StreamChatTheme.of(context).colorTheme.white,
|
child: SizedBox(
|
||||||
child: Container(
|
height: 63,
|
||||||
height: 63,
|
child: InkWell(
|
||||||
child: InkWell(
|
onTap: onTap,
|
||||||
onTap: onTap,
|
child: Row(
|
||||||
child: Row(
|
children: [
|
||||||
children: [
|
if (leading != null) Center(child: leading),
|
||||||
if (leading != null) Center(child: leading),
|
if (leading == null)
|
||||||
if (leading == null)
|
const SizedBox(
|
||||||
SizedBox(
|
width: 16,
|
||||||
width: 16,
|
),
|
||||||
),
|
Expanded(
|
||||||
Expanded(
|
flex: 4,
|
||||||
flex: 4,
|
child: Text(
|
||||||
child: Text(
|
title!,
|
||||||
title!,
|
style: titleTextStyle ??
|
||||||
style: titleTextStyle ??
|
(titleColor == null
|
||||||
(titleColor == null
|
? StreamChatTheme.of(context).textTheme.bodyBold
|
||||||
? StreamChatTheme.of(context).textTheme.bodyBold
|
: StreamChatTheme.of(context)
|
||||||
: StreamChatTheme.of(context)
|
.textTheme
|
||||||
.textTheme
|
.bodyBold
|
||||||
.bodyBold
|
.copyWith(
|
||||||
.copyWith(
|
color: titleColor,
|
||||||
color: titleColor,
|
)),
|
||||||
)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 16),
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: trailing ?? Container(),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
Expanded(
|
||||||
],
|
flex: 2,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 16),
|
||||||
|
child: Align(
|
||||||
|
alignment: Alignment.centerRight,
|
||||||
|
child: trailing ?? Container(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,29 +4,25 @@ import 'package:cached_network_image/cached_network_image.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||||
import 'package:video_player/video_player.dart';
|
import 'package:video_player/video_player.dart';
|
||||||
|
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
import 'package:stream_chat_flutter/src/extension.dart';
|
||||||
|
|
||||||
import 'attachment/attachment.dart';
|
/// Widget builder for quoted message attachment thumnail
|
||||||
import 'extension.dart';
|
|
||||||
import 'message_text.dart';
|
|
||||||
import 'stream_chat_theme.dart';
|
|
||||||
import 'user_avatar.dart';
|
|
||||||
import 'utils.dart';
|
|
||||||
|
|
||||||
typedef QuotedMessageAttachmentThumbnailBuilder = Widget Function(
|
typedef QuotedMessageAttachmentThumbnailBuilder = Widget Function(
|
||||||
BuildContext,
|
BuildContext,
|
||||||
Attachment,
|
Attachment,
|
||||||
);
|
);
|
||||||
|
|
||||||
class _VideoAttachmentThumbnail extends StatefulWidget {
|
class _VideoAttachmentThumbnail extends StatefulWidget {
|
||||||
final Size size;
|
|
||||||
final Attachment attachment;
|
|
||||||
|
|
||||||
const _VideoAttachmentThumbnail({
|
const _VideoAttachmentThumbnail({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.attachment,
|
required this.attachment,
|
||||||
this.size = const Size(32, 32),
|
this.size = const Size(32, 32),
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
final Size size;
|
||||||
|
final Attachment attachment;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_VideoAttachmentThumbnailState createState() =>
|
_VideoAttachmentThumbnailState createState() =>
|
||||||
_VideoAttachmentThumbnailState();
|
_VideoAttachmentThumbnailState();
|
||||||
@@ -51,18 +47,30 @@ class _VideoAttachmentThumbnailState extends State<_VideoAttachmentThumbnail> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => SizedBox(
|
||||||
return Container(
|
|
||||||
height: widget.size.height,
|
height: widget.size.height,
|
||||||
width: widget.size.width,
|
width: widget.size.width,
|
||||||
child: _controller.value.isInitialized
|
child: _controller.value.isInitialized
|
||||||
? VideoPlayer(_controller)
|
? VideoPlayer(_controller)
|
||||||
: CircularProgressIndicator());
|
: const CircularProgressIndicator(),
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
class QuotedMessageWidget extends StatelessWidget {
|
class QuotedMessageWidget extends StatelessWidget {
|
||||||
|
///
|
||||||
|
const QuotedMessageWidget({
|
||||||
|
Key? key,
|
||||||
|
required this.message,
|
||||||
|
required this.messageTheme,
|
||||||
|
this.reverse = false,
|
||||||
|
this.showBorder = false,
|
||||||
|
this.textLimit = 170,
|
||||||
|
this.attachmentThumbnailBuilders,
|
||||||
|
this.padding = const EdgeInsets.all(8),
|
||||||
|
this.onTap,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The message
|
/// The message
|
||||||
final Message message;
|
final Message message;
|
||||||
|
|
||||||
@@ -82,23 +90,12 @@ class QuotedMessageWidget extends StatelessWidget {
|
|||||||
final Map<String, QuotedMessageAttachmentThumbnailBuilder>?
|
final Map<String, QuotedMessageAttachmentThumbnailBuilder>?
|
||||||
attachmentThumbnailBuilders;
|
attachmentThumbnailBuilders;
|
||||||
|
|
||||||
|
/// Padding around the widget
|
||||||
final EdgeInsetsGeometry padding;
|
final EdgeInsetsGeometry padding;
|
||||||
|
|
||||||
|
/// Callback for tap on widget
|
||||||
final GestureTapCallback? onTap;
|
final GestureTapCallback? onTap;
|
||||||
|
|
||||||
///
|
|
||||||
const QuotedMessageWidget({
|
|
||||||
Key? key,
|
|
||||||
required this.message,
|
|
||||||
required this.messageTheme,
|
|
||||||
this.reverse = false,
|
|
||||||
this.showBorder = false,
|
|
||||||
this.textLimit = 170,
|
|
||||||
this.attachmentThumbnailBuilders,
|
|
||||||
this.padding = const EdgeInsets.all(8),
|
|
||||||
this.onTap,
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
bool get _hasAttachments => message.attachments.isNotEmpty == true;
|
bool get _hasAttachments => message.attachments.isNotEmpty == true;
|
||||||
|
|
||||||
bool get _containsScrapeUrl =>
|
bool get _containsScrapeUrl =>
|
||||||
@@ -107,23 +104,21 @@ class QuotedMessageWidget extends StatelessWidget {
|
|||||||
bool get _containsText => message.text?.isNotEmpty == true;
|
bool get _containsText => message.text?.isNotEmpty == true;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => Padding(
|
||||||
return Padding(
|
padding: padding,
|
||||||
padding: padding,
|
child: InkWell(
|
||||||
child: InkWell(
|
onTap: onTap,
|
||||||
onTap: onTap,
|
child: Row(
|
||||||
child: Row(
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisSize: MainAxisSize.min,
|
children: [
|
||||||
children: [
|
Flexible(child: _buildMessage(context)),
|
||||||
Flexible(child: _buildMessage(context)),
|
const SizedBox(width: 8),
|
||||||
SizedBox(width: 8),
|
if (message.user != null) _buildUserAvatar(),
|
||||||
if (message.user != null) _buildUserAvatar(),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildMessage(BuildContext context) {
|
Widget _buildMessage(BuildContext context) {
|
||||||
final isOnlyEmoji = message.text!.isOnlyEmoji;
|
final isOnlyEmoji = message.text!.isOnlyEmoji;
|
||||||
@@ -165,7 +160,7 @@ class QuotedMessageWidget extends StatelessWidget {
|
|||||||
color: StreamChatTheme.of(context).colorTheme.greyGainsboro,
|
color: StreamChatTheme.of(context).colorTheme.greyGainsboro,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
topRight: Radius.circular(12),
|
topRight: Radius.circular(12),
|
||||||
topLeft: Radius.circular(12),
|
topLeft: Radius.circular(12),
|
||||||
bottomLeft: Radius.circular(12),
|
bottomLeft: Radius.circular(12),
|
||||||
@@ -183,7 +178,7 @@ class QuotedMessageWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildUrlAttachment(Attachment attachment) {
|
Widget _buildUrlAttachment(Attachment attachment) {
|
||||||
final size = Size(32, 32);
|
const size = Size(32, 32);
|
||||||
if (attachment.thumbUrl != null) {
|
if (attachment.thumbUrl != null) {
|
||||||
return Container(
|
return Container(
|
||||||
height: size.height,
|
height: size.height,
|
||||||
@@ -198,7 +193,7 @@ class QuotedMessageWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return AttachmentError(size: size);
|
return const AttachmentError(size: size);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _parseAttachments(BuildContext context) {
|
Widget _parseAttachments(BuildContext context) {
|
||||||
@@ -217,7 +212,7 @@ class QuotedMessageWidget extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
attachmentBuilder = _defaultAttachmentBuilder[attachment.type];
|
attachmentBuilder = _defaultAttachmentBuilder[attachment.type];
|
||||||
if (attachmentBuilder == null) {
|
if (attachmentBuilder == null) {
|
||||||
child = Offstage();
|
child = const Offstage();
|
||||||
} else {
|
} else {
|
||||||
child = attachmentBuilder(context, attachment);
|
child = attachmentBuilder(context, attachment);
|
||||||
}
|
}
|
||||||
@@ -235,77 +230,63 @@ class QuotedMessageWidget extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShapeBorder _getDefaultShape(BuildContext context) {
|
ShapeBorder _getDefaultShape(BuildContext context) => RoundedRectangleBorder(
|
||||||
return RoundedRectangleBorder(
|
side: const BorderSide(width: 0, color: Colors.transparent),
|
||||||
side: BorderSide(width: 0, color: Colors.transparent),
|
borderRadius: BorderRadius.circular(8),
|
||||||
borderRadius: BorderRadius.circular(8),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildUserAvatar() {
|
Widget _buildUserAvatar() => Transform(
|
||||||
return Transform(
|
transform: Matrix4.rotationY(reverse ? pi : 0),
|
||||||
transform: Matrix4.rotationY(reverse ? pi : 0),
|
alignment: Alignment.center,
|
||||||
alignment: Alignment.center,
|
child: UserAvatar(
|
||||||
child: UserAvatar(
|
user: message.user!,
|
||||||
user: message.user!,
|
constraints: const BoxConstraints.tightFor(
|
||||||
constraints: BoxConstraints.tightFor(
|
height: 24,
|
||||||
height: 24,
|
width: 24,
|
||||||
width: 24,
|
),
|
||||||
|
showOnlineStatus: false,
|
||||||
),
|
),
|
||||||
showOnlineStatus: false,
|
);
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, QuotedMessageAttachmentThumbnailBuilder>
|
Map<String, QuotedMessageAttachmentThumbnailBuilder>
|
||||||
get _defaultAttachmentBuilder {
|
get _defaultAttachmentBuilder => {
|
||||||
return {
|
'image': (_, attachment) => ImageAttachment(
|
||||||
'image': (_, attachment) {
|
attachment: attachment,
|
||||||
return ImageAttachment(
|
message: message,
|
||||||
attachment: attachment,
|
messageTheme: messageTheme,
|
||||||
message: message,
|
size: const Size(32, 32),
|
||||||
messageTheme: messageTheme,
|
),
|
||||||
size: Size(32, 32),
|
'video': (_, attachment) => _VideoAttachmentThumbnail(
|
||||||
);
|
key: ValueKey(attachment.assetUrl),
|
||||||
},
|
attachment: attachment,
|
||||||
'video': (_, attachment) {
|
),
|
||||||
return _VideoAttachmentThumbnail(
|
'giphy': (_, attachment) {
|
||||||
key: ValueKey(attachment.assetUrl),
|
const size = Size(32, 32);
|
||||||
attachment: attachment,
|
return CachedNetworkImage(
|
||||||
);
|
height: size.height,
|
||||||
},
|
width: size.width,
|
||||||
'giphy': (_, attachment) {
|
placeholder: (_, __) => SizedBox(
|
||||||
final size = Size(32, 32);
|
width: size.width,
|
||||||
return CachedNetworkImage(
|
height: size.height,
|
||||||
height: size.height,
|
child: const Center(
|
||||||
width: size.width,
|
child: CircularProgressIndicator(),
|
||||||
placeholder: (_, __) {
|
),
|
||||||
return Container(
|
),
|
||||||
width: size.width,
|
imageUrl: attachment.thumbUrl ??
|
||||||
height: size.height,
|
attachment.imageUrl ??
|
||||||
child: Center(
|
attachment.assetUrl!,
|
||||||
child: CircularProgressIndicator(),
|
errorWidget: (context, url, error) =>
|
||||||
),
|
const AttachmentError(size: size),
|
||||||
);
|
fit: BoxFit.cover,
|
||||||
},
|
);
|
||||||
imageUrl: attachment.thumbUrl ??
|
},
|
||||||
attachment.imageUrl ??
|
'file': (_, attachment) => SizedBox(
|
||||||
attachment.assetUrl!,
|
height: 32,
|
||||||
errorWidget: (context, url, error) {
|
width: 32,
|
||||||
return AttachmentError(size: size);
|
child: getFileTypeImage(
|
||||||
},
|
attachment.extraData['mime_type'] as String?),
|
||||||
fit: BoxFit.cover,
|
),
|
||||||
);
|
};
|
||||||
},
|
|
||||||
'file': (_, attachment) {
|
|
||||||
return Container(
|
|
||||||
height: 32,
|
|
||||||
width: 32,
|
|
||||||
child: getFileTypeImage(attachment.extraData['mime_type'] as String?),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Color? _getBackgroundColor(BuildContext context) {
|
Color? _getBackgroundColor(BuildContext context) {
|
||||||
if (_containsScrapeUrl) {
|
if (_containsScrapeUrl) {
|
||||||
|
|||||||
Reference in New Issue
Block a user