@@ -60,6 +60,7 @@ class ChannelListView extends StatefulWidget {
|
|||||||
this.channelPreviewBuilder,
|
this.channelPreviewBuilder,
|
||||||
this.errorBuilder,
|
this.errorBuilder,
|
||||||
this.onImageTap,
|
this.onImageTap,
|
||||||
|
this.pullToRefresh = true,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The builder that will be used in case of error
|
/// The builder that will be used in case of error
|
||||||
@@ -105,6 +106,9 @@ class ChannelListView extends StatefulWidget {
|
|||||||
/// The function called when the image is tapped
|
/// The function called when the image is tapped
|
||||||
final Function(Channel) onImageTap;
|
final Function(Channel) onImageTap;
|
||||||
|
|
||||||
|
/// Set it to false to disable the pull-to-refresh widget
|
||||||
|
final bool pullToRefresh;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ChannelListViewState createState() => _ChannelListViewState();
|
_ChannelListViewState createState() => _ChannelListViewState();
|
||||||
}
|
}
|
||||||
@@ -115,19 +119,30 @@ class _ChannelListViewState extends State<ChannelListView>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final channelsProvider = ChannelsBloc.of(context);
|
final channelsBloc = ChannelsBloc.of(context);
|
||||||
|
|
||||||
|
if (!widget.pullToRefresh) {
|
||||||
|
return _buildListView(channelsBloc);
|
||||||
|
}
|
||||||
|
|
||||||
return RefreshIndicator(
|
return RefreshIndicator(
|
||||||
onRefresh: () async {
|
onRefresh: () async {
|
||||||
return channelsProvider.queryChannels(
|
return channelsBloc.queryChannels(
|
||||||
filter: widget.filter,
|
filter: widget.filter,
|
||||||
sortOptions: widget.sort,
|
sortOptions: widget.sort,
|
||||||
paginationParams: widget.pagination,
|
paginationParams: widget.pagination,
|
||||||
options: widget.options,
|
options: widget.options,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: StreamBuilder<List<Channel>>(
|
child: _buildListView(channelsBloc),
|
||||||
stream: channelsProvider.channelsStream,
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
StreamBuilder<List<Channel>> _buildListView(
|
||||||
|
ChannelsBlocState channelsBlocState,
|
||||||
|
) {
|
||||||
|
return StreamBuilder<List<Channel>>(
|
||||||
|
stream: channelsBlocState.channelsStream,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.hasError) {
|
if (snapshot.hasError) {
|
||||||
if (snapshot.error is Error) {
|
if (snapshot.error is Error) {
|
||||||
@@ -175,7 +190,7 @@ class _ChannelListViewState extends State<ChannelListView>
|
|||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
channelsProvider.queryChannels(
|
channelsBlocState.queryChannels(
|
||||||
filter: widget.filter,
|
filter: widget.filter,
|
||||||
sortOptions: widget.sort,
|
sortOptions: widget.sort,
|
||||||
paginationParams: widget.pagination,
|
paginationParams: widget.pagination,
|
||||||
@@ -212,8 +227,7 @@ class _ChannelListViewState extends State<ChannelListView>
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _itemBuilder(context, int i, List<Channel> channels) {
|
Widget _itemBuilder(context, int i, List<Channel> channels) {
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ class MessageText extends StatelessWidget {
|
|||||||
@required this.message,
|
@required this.message,
|
||||||
@required this.messageTheme,
|
@required this.messageTheme,
|
||||||
this.onMentionTap,
|
this.onMentionTap,
|
||||||
|
this.onLinkTap,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
final Message message;
|
final Message message;
|
||||||
final void Function(User) onMentionTap;
|
final void Function(User) onMentionTap;
|
||||||
|
final void Function(String) onLinkTap;
|
||||||
final MessageTheme messageTheme;
|
final MessageTheme messageTheme;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -34,9 +36,13 @@ class MessageText extends StatelessWidget {
|
|||||||
} else {
|
} else {
|
||||||
print('tap on ${mentionedUser.name}');
|
print('tap on ${mentionedUser.name}');
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (onLinkTap != null) {
|
||||||
|
onLinkTap(link);
|
||||||
} else {
|
} else {
|
||||||
launchURL(context, link);
|
launchURL(context, link);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
styleSheet: MarkdownStyleSheet.fromTheme(
|
styleSheet: MarkdownStyleSheet.fromTheme(
|
||||||
Theme.of(context).copyWith(
|
Theme.of(context).copyWith(
|
||||||
|
|||||||
@@ -97,6 +97,9 @@ class MessageWidget extends StatefulWidget {
|
|||||||
/// The function called when tapping on UserAvatar
|
/// The function called when tapping on UserAvatar
|
||||||
final void Function(User) onUserAvatarTap;
|
final void Function(User) onUserAvatarTap;
|
||||||
|
|
||||||
|
/// The function called when tapping on a link
|
||||||
|
final void Function(String) onLinkTap;
|
||||||
|
|
||||||
final List<Read> readList;
|
final List<Read> readList;
|
||||||
|
|
||||||
/// If true show the users username next to the timestamp of the message
|
/// If true show the users username next to the timestamp of the message
|
||||||
@@ -128,6 +131,7 @@ class MessageWidget extends StatefulWidget {
|
|||||||
this.showDeleteMessage = true,
|
this.showDeleteMessage = true,
|
||||||
this.showEditMessage = true,
|
this.showEditMessage = true,
|
||||||
this.onUserAvatarTap,
|
this.onUserAvatarTap,
|
||||||
|
this.onLinkTap,
|
||||||
this.onMessageActions,
|
this.onMessageActions,
|
||||||
this.editMessageInputBuilder,
|
this.editMessageInputBuilder,
|
||||||
this.textBuilder,
|
this.textBuilder,
|
||||||
@@ -764,6 +768,7 @@ class _MessageWidgetState extends State<MessageWidget> {
|
|||||||
return widget.textBuilder != null
|
return widget.textBuilder != null
|
||||||
? widget.textBuilder(context, widget.message)
|
? widget.textBuilder(context, widget.message)
|
||||||
: MessageText(
|
: MessageText(
|
||||||
|
onLinkTap: widget.onLinkTap,
|
||||||
message: widget.message,
|
message: widget.message,
|
||||||
onMentionTap: widget.onMentionTap,
|
onMentionTap: widget.onMentionTap,
|
||||||
messageTheme: widget.messageTheme,
|
messageTheme: widget.messageTheme,
|
||||||
|
|||||||
Reference in New Issue
Block a user