lint changes message
This commit is contained in:
@@ -5,9 +5,11 @@ import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
|||||||
|
|
||||||
/// It shows the current [Message] preview.
|
/// It shows the current [Message] preview.
|
||||||
///
|
///
|
||||||
/// Usually you don't use this widget as it's the default item used by [MessageSearchListView].
|
/// Usually you don't use this widget as it's the default item used by
|
||||||
|
/// [MessageSearchListView].
|
||||||
///
|
///
|
||||||
/// The widget renders the ui based on the first ancestor of type [StreamChatTheme].
|
/// The widget renders the ui based on the first ancestor of type
|
||||||
|
/// [StreamChatTheme].
|
||||||
/// Modify it to change the widget appearance.
|
/// Modify it to change the widget appearance.
|
||||||
class MessageSearchItem extends StatelessWidget {
|
class MessageSearchItem extends StatelessWidget {
|
||||||
/// Instantiate a new MessageSearchItem
|
/// Instantiate a new MessageSearchItem
|
||||||
@@ -38,7 +40,7 @@ class MessageSearchItem extends StatelessWidget {
|
|||||||
leading: UserAvatar(
|
leading: UserAvatar(
|
||||||
user: user,
|
user: user,
|
||||||
showOnlineStatus: showOnlineStatus,
|
showOnlineStatus: showOnlineStatus,
|
||||||
constraints: BoxConstraints.tightFor(
|
constraints: const BoxConstraints.tightFor(
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 40,
|
width: 40,
|
||||||
),
|
),
|
||||||
@@ -69,7 +71,7 @@ class MessageSearchItem extends StatelessWidget {
|
|||||||
subtitle: Row(
|
subtitle: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(child: _buildSubtitle(context, message)),
|
Expanded(child: _buildSubtitle(context, message)),
|
||||||
SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
_buildDate(context, message),
|
_buildDate(context, message),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -149,7 +151,7 @@ class MessageSearchItem extends StatelessWidget {
|
|||||||
TextStyle? mentionsTextStyle) {
|
TextStyle? mentionsTextStyle) {
|
||||||
final textList = text.split(' ');
|
final textList = text.split(' ');
|
||||||
final resList = <TextSpan>[];
|
final resList = <TextSpan>[];
|
||||||
for (var e in textList) {
|
for (final e in textList) {
|
||||||
if (mentions.isNotEmpty &&
|
if (mentions.isNotEmpty &&
|
||||||
mentions.any((element) => '@${element.name}' == e)) {
|
mentions.any((element) => '@${element.name}' == e)) {
|
||||||
resList.add(TextSpan(
|
resList.add(TextSpan(
|
||||||
|
|||||||
@@ -2,8 +2,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:stream_chat_flutter/src/info_tile.dart';
|
import 'package:stream_chat_flutter/src/info_tile.dart';
|
||||||
import 'package:stream_chat_flutter/src/message_search_item.dart';
|
import 'package:stream_chat_flutter/src/message_search_item.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:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
import '../stream_chat_flutter.dart';
|
|
||||||
|
|
||||||
/// Callback called when tapping on a user
|
/// Callback called when tapping on a user
|
||||||
typedef MessageSearchItemTapCallback = void Function(GetMessageResponse);
|
typedef MessageSearchItemTapCallback = void Function(GetMessageResponse);
|
||||||
@@ -43,10 +42,12 @@ typedef EmptyMessageSearchBuilder = Widget Function(
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// Make sure to have a [MessageSearchBloc] ancestor in order to provide the information about the messages.
|
/// Make sure to have a [MessageSearchBloc] ancestor in order to provide the
|
||||||
|
/// information about the messages.
|
||||||
/// The widget uses a [ListView.separated] to render the list of messages.
|
/// The widget uses a [ListView.separated] to render the list of messages.
|
||||||
///
|
///
|
||||||
/// The widget components render the ui based on the first ancestor of type [StreamChatTheme].
|
/// The widget components render the ui based on the first ancestor of type
|
||||||
|
/// [StreamChatTheme].
|
||||||
/// Modify it to change the widget appearance.
|
/// Modify it to change the widget appearance.
|
||||||
class MessageSearchListView extends StatefulWidget {
|
class MessageSearchListView extends StatefulWidget {
|
||||||
/// Instantiate a new MessageSearchListView
|
/// Instantiate a new MessageSearchListView
|
||||||
@@ -78,8 +79,10 @@ class MessageSearchListView extends StatefulWidget {
|
|||||||
final Filter filters;
|
final Filter filters;
|
||||||
|
|
||||||
/// The sorting used for the channels matching the filters.
|
/// The sorting used for the channels matching the filters.
|
||||||
/// Sorting is based on field and direction, multiple sorting options can be provided.
|
/// Sorting is based on field and direction, multiple sorting options
|
||||||
/// You can sort based on last_updated, last_message_at, updated_at, created_at or member_count.
|
/// can be provided.
|
||||||
|
/// You can sort based on last_updated, last_message_at, updated_at,
|
||||||
|
/// created_at or member_count.
|
||||||
/// Direction can be ascending or descending.
|
/// Direction can be ascending or descending.
|
||||||
final List<SortOption>? sortOptions;
|
final List<SortOption>? sortOptions;
|
||||||
|
|
||||||
@@ -109,6 +112,7 @@ class MessageSearchListView extends StatefulWidget {
|
|||||||
/// Set it to false to disable the pull-to-refresh widget
|
/// Set it to false to disable the pull-to-refresh widget
|
||||||
final bool pullToRefresh;
|
final bool pullToRefresh;
|
||||||
|
|
||||||
|
/// Show error tile on top
|
||||||
final bool showErrorTile;
|
final bool showErrorTile;
|
||||||
|
|
||||||
/// The builder that is used when the search messages are fetched
|
/// The builder that is used when the search messages are fetched
|
||||||
@@ -132,73 +136,63 @@ class _MessageSearchListViewState extends State<MessageSearchListView> {
|
|||||||
MessageSearchListController();
|
MessageSearchListController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) => MessageSearchListCore(
|
||||||
return MessageSearchListCore(
|
filters: widget.filters,
|
||||||
filters: widget.filters,
|
sortOptions: widget.sortOptions,
|
||||||
sortOptions: widget.sortOptions,
|
messageQuery: widget.messageQuery,
|
||||||
messageQuery: widget.messageQuery,
|
paginationParams: widget.paginationParams,
|
||||||
paginationParams: widget.paginationParams,
|
messageFilters: widget.messageFilters,
|
||||||
messageFilters: widget.messageFilters,
|
messageSearchListController: _messageSearchListController,
|
||||||
messageSearchListController: _messageSearchListController,
|
emptyBuilder: widget.emptyBuilder ??
|
||||||
emptyBuilder: widget.emptyBuilder ??
|
(context) => LayoutBuilder(
|
||||||
(context) {
|
builder: (context, viewportConstraints) =>
|
||||||
return LayoutBuilder(
|
SingleChildScrollView(
|
||||||
builder: (context, viewportConstraints) {
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
return SingleChildScrollView(
|
child: ConstrainedBox(
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
constraints: BoxConstraints(
|
||||||
child: ConstrainedBox(
|
minHeight: viewportConstraints.maxHeight,
|
||||||
constraints: BoxConstraints(
|
),
|
||||||
minHeight: viewportConstraints.maxHeight,
|
child: const Center(
|
||||||
),
|
child: Text('There are no messages currently'),
|
||||||
child: Center(
|
),
|
||||||
child: Text('There are no messages currently'),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
errorBuilder: widget.errorBuilder ??
|
||||||
);
|
(BuildContext context, dynamic error) {
|
||||||
},
|
if (error is Error) {
|
||||||
errorBuilder: widget.errorBuilder ??
|
print(error.stackTrace);
|
||||||
(BuildContext context, dynamic error) {
|
}
|
||||||
if (error is Error) {
|
return InfoTile(
|
||||||
print(error.stackTrace);
|
showMessage: widget.showErrorTile,
|
||||||
}
|
tileAnchor: Alignment.topCenter,
|
||||||
return InfoTile(
|
childAnchor: Alignment.topCenter,
|
||||||
showMessage: widget.showErrorTile,
|
message: 'An error occurred.',
|
||||||
tileAnchor: Alignment.topCenter,
|
child: Container(),
|
||||||
childAnchor: Alignment.topCenter,
|
);
|
||||||
message: 'An error occurred.',
|
},
|
||||||
child: Container(),
|
loadingBuilder: widget.loadingBuilder ??
|
||||||
);
|
(context) => LayoutBuilder(
|
||||||
},
|
builder: (context, viewportConstraints) =>
|
||||||
loadingBuilder: widget.loadingBuilder ??
|
SingleChildScrollView(
|
||||||
(context) {
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
return LayoutBuilder(
|
child: ConstrainedBox(
|
||||||
builder: (context, viewportConstraints) {
|
constraints: BoxConstraints(
|
||||||
return SingleChildScrollView(
|
minHeight: viewportConstraints.maxHeight,
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
),
|
||||||
child: ConstrainedBox(
|
child: const Center(
|
||||||
constraints: BoxConstraints(
|
child: CircularProgressIndicator(),
|
||||||
minHeight: viewportConstraints.maxHeight,
|
),
|
||||||
),
|
|
||||||
child: Center(
|
|
||||||
child: CircularProgressIndicator(),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
childBuilder: widget.childBuilder ?? _buildListView,
|
||||||
);
|
);
|
||||||
},
|
|
||||||
childBuilder: widget.childBuilder ?? _buildListView,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _separatorBuilder(BuildContext context, int index) {
|
Widget _separatorBuilder(BuildContext context, int index) => Container(
|
||||||
return Container(
|
height: 1,
|
||||||
height: 1,
|
color: StreamChatTheme.of(context).colorTheme.greyWhisper,
|
||||||
color: StreamChatTheme.of(context).colorTheme.greyWhisper,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _listItemBuilder(
|
Widget _listItemBuilder(
|
||||||
BuildContext context, GetMessageResponse getMessageResponse) {
|
BuildContext context, GetMessageResponse getMessageResponse) {
|
||||||
@@ -224,8 +218,8 @@ class _MessageSearchListViewState extends State<MessageSearchListView> {
|
|||||||
.colorTheme
|
.colorTheme
|
||||||
.accentRed
|
.accentRed
|
||||||
.withOpacity(.2),
|
.withOpacity(.2),
|
||||||
child: Padding(
|
child: const Padding(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
padding: EdgeInsets.symmetric(vertical: 16),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text('Error loading messages'),
|
child: Text('Error loading messages'),
|
||||||
),
|
),
|
||||||
@@ -234,9 +228,11 @@ class _MessageSearchListViewState extends State<MessageSearchListView> {
|
|||||||
}
|
}
|
||||||
return Container(
|
return Container(
|
||||||
height: 100,
|
height: 100,
|
||||||
padding: EdgeInsets.all(32),
|
padding: const EdgeInsets.all(32),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: snapshot.data! ? CircularProgressIndicator() : Container(),
|
child: snapshot.data!
|
||||||
|
? const CircularProgressIndicator()
|
||||||
|
: Container(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -246,7 +242,7 @@ class _MessageSearchListViewState extends State<MessageSearchListView> {
|
|||||||
final items = data;
|
final items = data;
|
||||||
|
|
||||||
Widget child = ListView.separated(
|
Widget child = ListView.separated(
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
itemCount: items.isNotEmpty ? items.length + 1 : items.length,
|
itemCount: items.isNotEmpty ? items.length + 1 : items.length,
|
||||||
separatorBuilder: (_, index) {
|
separatorBuilder: (_, index) {
|
||||||
if (widget.separatorBuilder != null) {
|
if (widget.separatorBuilder != null) {
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import 'package:collection/collection.dart' show IterableExtension;
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
import 'package:flutter_markdown/flutter_markdown.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:stream_chat_flutter/stream_chat_flutter.dart';
|
||||||
|
|
||||||
import 'stream_chat_theme.dart';
|
import '../stream_chat_flutter.dart';
|
||||||
import 'utils.dart';
|
|
||||||
|
|
||||||
|
/// Text widget to display in message
|
||||||
class MessageText extends StatelessWidget {
|
class MessageText extends StatelessWidget {
|
||||||
|
/// Constructor for creating a [MessageText] widget
|
||||||
const MessageText({
|
const MessageText({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.message,
|
required this.message,
|
||||||
@@ -15,9 +17,16 @@ class MessageText extends StatelessWidget {
|
|||||||
this.onLinkTap,
|
this.onLinkTap,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
|
/// Message whose text is to be displayed
|
||||||
final Message message;
|
final Message message;
|
||||||
|
|
||||||
|
/// Callback for when mention is tapped
|
||||||
final void Function(User)? onMentionTap;
|
final void Function(User)? onMentionTap;
|
||||||
|
|
||||||
|
/// Callback for when link is tapped
|
||||||
final void Function(String)? onLinkTap;
|
final void Function(String)? onLinkTap;
|
||||||
|
|
||||||
|
/// [MessageTheme] whose text theme is to be applied
|
||||||
final MessageTheme messageTheme;
|
final MessageTheme messageTheme;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -71,6 +80,7 @@ class MessageText extends StatelessWidget {
|
|||||||
|
|
||||||
String _replaceMentions(String text) {
|
String _replaceMentions(String text) {
|
||||||
message.mentionedUsers.map((u) => u.name).toSet().forEach((userName) {
|
message.mentionedUsers.map((u) => u.name).toSet().forEach((userName) {
|
||||||
|
// ignore: parameter_assignments
|
||||||
text = text.replaceAll(
|
text = text.replaceAll(
|
||||||
'@$userName', '[@$userName](@${userName.replaceAll(' ', '')})');
|
'@$userName', '[@$userName](@${userName.replaceAll(' ', '')})');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user