frosty/lib/screens/home/search/search_results_channels.dart

154 lines
5.4 KiB
Dart
Raw Normal View History

2022-01-02 19:12:39 -05:00
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
2022-01-05 09:38:05 -05:00
import 'package:flutter_mobx/flutter_mobx.dart';
import 'package:frosty/constants.dart';
2022-01-05 09:38:05 -05:00
import 'package:frosty/models/channel.dart';
import 'package:frosty/screens/channel/channel.dart';
import 'package:frosty/screens/home/search/search_store.dart';
import 'package:frosty/widgets/alert_message.dart';
import 'package:frosty/widgets/block_report_modal.dart';
2022-01-05 09:38:05 -05:00
import 'package:frosty/widgets/loading_indicator.dart';
2022-01-02 19:12:39 -05:00
import 'package:frosty/widgets/profile_picture.dart';
import 'package:frosty/widgets/uptime.dart';
2022-01-05 09:38:05 -05:00
import 'package:mobx/mobx.dart';
2022-01-02 19:12:39 -05:00
class SearchResultsChannels extends StatefulWidget {
2022-01-02 19:12:39 -05:00
final SearchStore searchStore;
2022-01-05 09:38:05 -05:00
final String query;
2022-01-02 19:12:39 -05:00
2022-01-05 09:38:05 -05:00
const SearchResultsChannels({
Key? key,
required this.searchStore,
required this.query,
}) : super(key: key);
2022-01-02 19:12:39 -05:00
@override
State<SearchResultsChannels> createState() => _SearchResultsChannelsState();
}
class _SearchResultsChannelsState extends State<SearchResultsChannels> {
2022-01-05 09:38:05 -05:00
Future<void> _handleSearch(BuildContext context, String search) async {
try {
final channelInfo = await widget.searchStore.searchChannel(search);
if (!mounted) return;
2022-01-05 09:38:05 -05:00
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => VideoChat(
userId: channelInfo.broadcasterId,
userName: channelInfo.broadcasterName,
userLogin: channelInfo.broadcasterLogin,
2022-01-02 19:12:39 -05:00
),
2022-01-05 09:38:05 -05:00
),
);
} catch (error) {
2022-01-15 13:16:43 -05:00
final snackBar = SnackBar(
Update to Material 3/You and other changes/fixes (#280) * Use adaptive refresh indicators * Add new message count indicator in chat * Sync pubspec.lock * Initial migration to material 3 * Restore default bottom sheet style * Remove FrostyListTile and reset styles * Use "Clear" button for all search history * Add `require_trailing_commas` lint rule * Exclude generated files from linter * Use ListView for safe area support in bottom sheet * Add initial dark theme * Make sizing and units consistent * Update onbaording spacings & copy * Migrate to default material 3 buttons * Add headers to chat details bottom sheet * Simplify token log in method * Use bottom sheet for account options * Remove `AnimateScale` widget * Tweak search paddings * Update message spacing divisions * Upgrade packages * Update message spacing divisions * Regenerate splash screens * Update Inter & add google fonts * Add initial material 3 themes * Use adaptive alert dialogs * Revert to oultined inputs * Fix tooltip message * Revert add google_fonts * Improve themes and various styling * Convert categories grid to list * Tweak stream card thumbnail radii * Tweak settings headers * Left align floating snackbars * Tweak search header padding * Fix profile pics occasionally not rounded * Use profile pic for settings button if logged in * Redesign sleep timer * Use divider theme and reduce thickness * Use 0 letter spacing for tab bar titles * Redesign category streams list * Add border to tooltips * Increase category card font weight * Use outlined icon btton for chat user modal * Reduce profile pic radius in search results * Fix scrolll to top button safe area * Add support for reply threads * Reduce tooltip and snackbar border thickness * Rebuild reply threads on new messages * Upgrade packages (iOS) * Reduce font weight for all chat alerts * Use tabbars for pageview * Add dividers everywhere * Revert "Add dividers everywhere" This reverts commit 5f0d349fdbb0afad313cfb88e8c359714b3ea87a. * Remove fill from inputs * Add dividers to settings * Use segmented button for settings list * Add scrollbar to lists with scrollcontroller * Redesign badge/emote tooltip * Remove outline from chat user modal buttons * Remove divider from reply thread * Use tap for chatters list and increase font weight * Constrain emote tooltip width
2023-10-22 18:38:32 -04:00
content: AlertMessage(
message: error.toString(),
centered: false,
),
2022-01-05 09:38:05 -05:00
);
2022-01-05 09:38:05 -05:00
ScaffoldMessenger.of(context).showSnackBar(snackBar);
2022-01-02 19:12:39 -05:00
}
2022-01-05 09:38:05 -05:00
}
@override
Widget build(BuildContext context) {
return Observer(
builder: (context) {
final future = widget.searchStore.channelFuture;
2022-01-02 19:12:39 -05:00
2022-01-05 14:33:01 -05:00
switch (future!.status) {
2022-01-05 09:38:05 -05:00
case FutureStatus.pending:
return const SliverToBoxAdapter(
child: LoadingIndicator(
subtitle: 'Loading channels...',
2022-01-05 09:38:05 -05:00
),
);
case FutureStatus.rejected:
return const SliverToBoxAdapter(
child: SizedBox(
height: 100.0,
child: AlertMessage(message: 'Failed to get channels'),
),
2022-01-05 09:38:05 -05:00
);
case FutureStatus.fulfilled:
final results = (future.result as List<ChannelQuery>).where(
Update to Material 3/You and other changes/fixes (#280) * Use adaptive refresh indicators * Add new message count indicator in chat * Sync pubspec.lock * Initial migration to material 3 * Restore default bottom sheet style * Remove FrostyListTile and reset styles * Use "Clear" button for all search history * Add `require_trailing_commas` lint rule * Exclude generated files from linter * Use ListView for safe area support in bottom sheet * Add initial dark theme * Make sizing and units consistent * Update onbaording spacings & copy * Migrate to default material 3 buttons * Add headers to chat details bottom sheet * Simplify token log in method * Use bottom sheet for account options * Remove `AnimateScale` widget * Tweak search paddings * Update message spacing divisions * Upgrade packages * Update message spacing divisions * Regenerate splash screens * Update Inter & add google fonts * Add initial material 3 themes * Use adaptive alert dialogs * Revert to oultined inputs * Fix tooltip message * Revert add google_fonts * Improve themes and various styling * Convert categories grid to list * Tweak stream card thumbnail radii * Tweak settings headers * Left align floating snackbars * Tweak search header padding * Fix profile pics occasionally not rounded * Use profile pic for settings button if logged in * Redesign sleep timer * Use divider theme and reduce thickness * Use 0 letter spacing for tab bar titles * Redesign category streams list * Add border to tooltips * Increase category card font weight * Use outlined icon btton for chat user modal * Reduce profile pic radius in search results * Fix scrolll to top button safe area * Add support for reply threads * Reduce tooltip and snackbar border thickness * Rebuild reply threads on new messages * Upgrade packages (iOS) * Reduce font weight for all chat alerts * Use tabbars for pageview * Add dividers everywhere * Revert "Add dividers everywhere" This reverts commit 5f0d349fdbb0afad313cfb88e8c359714b3ea87a. * Remove fill from inputs * Add dividers to settings * Use segmented button for settings list * Add scrollbar to lists with scrollcontroller * Redesign badge/emote tooltip * Remove outline from chat user modal buttons * Remove divider from reply thread * Use tap for chatters list and increase font weight * Constrain emote tooltip width
2023-10-22 18:38:32 -04:00
(channel) => !widget.searchStore.authStore.user.blockedUsers
.map((blockedUser) => blockedUser.userId)
.contains(channel.id),
);
2022-01-05 09:38:05 -05:00
return SliverList(
delegate: SliverChildListDelegate.fixed(
[
...results.map(
(channel) {
final displayName = regexEnglish
.hasMatch(channel.displayName)
? channel.displayName
: '${channel.displayName} (${channel.broadcasterLogin})';
Update to Material 3/You and other changes/fixes (#280) * Use adaptive refresh indicators * Add new message count indicator in chat * Sync pubspec.lock * Initial migration to material 3 * Restore default bottom sheet style * Remove FrostyListTile and reset styles * Use "Clear" button for all search history * Add `require_trailing_commas` lint rule * Exclude generated files from linter * Use ListView for safe area support in bottom sheet * Add initial dark theme * Make sizing and units consistent * Update onbaording spacings & copy * Migrate to default material 3 buttons * Add headers to chat details bottom sheet * Simplify token log in method * Use bottom sheet for account options * Remove `AnimateScale` widget * Tweak search paddings * Update message spacing divisions * Upgrade packages * Update message spacing divisions * Regenerate splash screens * Update Inter & add google fonts * Add initial material 3 themes * Use adaptive alert dialogs * Revert to oultined inputs * Fix tooltip message * Revert add google_fonts * Improve themes and various styling * Convert categories grid to list * Tweak stream card thumbnail radii * Tweak settings headers * Left align floating snackbars * Tweak search header padding * Fix profile pics occasionally not rounded * Use profile pic for settings button if logged in * Redesign sleep timer * Use divider theme and reduce thickness * Use 0 letter spacing for tab bar titles * Redesign category streams list * Add border to tooltips * Increase category card font weight * Use outlined icon btton for chat user modal * Reduce profile pic radius in search results * Fix scrolll to top button safe area * Add support for reply threads * Reduce tooltip and snackbar border thickness * Rebuild reply threads on new messages * Upgrade packages (iOS) * Reduce font weight for all chat alerts * Use tabbars for pageview * Add dividers everywhere * Revert "Add dividers everywhere" This reverts commit 5f0d349fdbb0afad313cfb88e8c359714b3ea87a. * Remove fill from inputs * Add dividers to settings * Use segmented button for settings list * Add scrollbar to lists with scrollcontroller * Redesign badge/emote tooltip * Remove outline from chat user modal buttons * Remove divider from reply thread * Use tap for chatters list and increase font weight * Constrain emote tooltip width
2023-10-22 18:38:32 -04:00
return InkWell(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => VideoChat(
userId: channel.id,
userName: channel.displayName,
userLogin: channel.broadcasterLogin,
),
),
),
onLongPress: () {
HapticFeedback.lightImpact();
showModalBottomSheet(
context: context,
builder: (context) => BlockReportModal(
authStore: widget.searchStore.authStore,
name: displayName,
userLogin: channel.broadcasterLogin,
userId: channel.id,
),
);
},
Update to Material 3/You and other changes/fixes (#280) * Use adaptive refresh indicators * Add new message count indicator in chat * Sync pubspec.lock * Initial migration to material 3 * Restore default bottom sheet style * Remove FrostyListTile and reset styles * Use "Clear" button for all search history * Add `require_trailing_commas` lint rule * Exclude generated files from linter * Use ListView for safe area support in bottom sheet * Add initial dark theme * Make sizing and units consistent * Update onbaording spacings & copy * Migrate to default material 3 buttons * Add headers to chat details bottom sheet * Simplify token log in method * Use bottom sheet for account options * Remove `AnimateScale` widget * Tweak search paddings * Update message spacing divisions * Upgrade packages * Update message spacing divisions * Regenerate splash screens * Update Inter & add google fonts * Add initial material 3 themes * Use adaptive alert dialogs * Revert to oultined inputs * Fix tooltip message * Revert add google_fonts * Improve themes and various styling * Convert categories grid to list * Tweak stream card thumbnail radii * Tweak settings headers * Left align floating snackbars * Tweak search header padding * Fix profile pics occasionally not rounded * Use profile pic for settings button if logged in * Redesign sleep timer * Use divider theme and reduce thickness * Use 0 letter spacing for tab bar titles * Redesign category streams list * Add border to tooltips * Increase category card font weight * Use outlined icon btton for chat user modal * Reduce profile pic radius in search results * Fix scrolll to top button safe area * Add support for reply threads * Reduce tooltip and snackbar border thickness * Rebuild reply threads on new messages * Upgrade packages (iOS) * Reduce font weight for all chat alerts * Use tabbars for pageview * Add dividers everywhere * Revert "Add dividers everywhere" This reverts commit 5f0d349fdbb0afad313cfb88e8c359714b3ea87a. * Remove fill from inputs * Add dividers to settings * Use segmented button for settings list * Add scrollbar to lists with scrollcontroller * Redesign badge/emote tooltip * Remove outline from chat user modal buttons * Remove divider from reply thread * Use tap for chatters list and increase font weight * Constrain emote tooltip width
2023-10-22 18:38:32 -04:00
child: ListTile(
title: Text(displayName),
leading: ProfilePicture(
Update to Material 3/You and other changes/fixes (#280) * Use adaptive refresh indicators * Add new message count indicator in chat * Sync pubspec.lock * Initial migration to material 3 * Restore default bottom sheet style * Remove FrostyListTile and reset styles * Use "Clear" button for all search history * Add `require_trailing_commas` lint rule * Exclude generated files from linter * Use ListView for safe area support in bottom sheet * Add initial dark theme * Make sizing and units consistent * Update onbaording spacings & copy * Migrate to default material 3 buttons * Add headers to chat details bottom sheet * Simplify token log in method * Use bottom sheet for account options * Remove `AnimateScale` widget * Tweak search paddings * Update message spacing divisions * Upgrade packages * Update message spacing divisions * Regenerate splash screens * Update Inter & add google fonts * Add initial material 3 themes * Use adaptive alert dialogs * Revert to oultined inputs * Fix tooltip message * Revert add google_fonts * Improve themes and various styling * Convert categories grid to list * Tweak stream card thumbnail radii * Tweak settings headers * Left align floating snackbars * Tweak search header padding * Fix profile pics occasionally not rounded * Use profile pic for settings button if logged in * Redesign sleep timer * Use divider theme and reduce thickness * Use 0 letter spacing for tab bar titles * Redesign category streams list * Add border to tooltips * Increase category card font weight * Use outlined icon btton for chat user modal * Reduce profile pic radius in search results * Fix scrolll to top button safe area * Add support for reply threads * Reduce tooltip and snackbar border thickness * Rebuild reply threads on new messages * Upgrade packages (iOS) * Reduce font weight for all chat alerts * Use tabbars for pageview * Add dividers everywhere * Revert "Add dividers everywhere" This reverts commit 5f0d349fdbb0afad313cfb88e8c359714b3ea87a. * Remove fill from inputs * Add dividers to settings * Use segmented button for settings list * Add scrollbar to lists with scrollcontroller * Redesign badge/emote tooltip * Remove outline from chat user modal buttons * Remove divider from reply thread * Use tap for chatters list and increase font weight * Constrain emote tooltip width
2023-10-22 18:38:32 -04:00
userLogin: channel.broadcasterLogin,
radius: 16,
),
subtitle: channel.isLive
? Row(
children: [
const Icon(
Icons.circle,
color: Colors.red,
size: 10,
),
const SizedBox(width: 5),
Uptime(startTime: channel.startedAt),
],
)
: null,
),
);
},
),
Update to Material 3/You and other changes/fixes (#280) * Use adaptive refresh indicators * Add new message count indicator in chat * Sync pubspec.lock * Initial migration to material 3 * Restore default bottom sheet style * Remove FrostyListTile and reset styles * Use "Clear" button for all search history * Add `require_trailing_commas` lint rule * Exclude generated files from linter * Use ListView for safe area support in bottom sheet * Add initial dark theme * Make sizing and units consistent * Update onbaording spacings & copy * Migrate to default material 3 buttons * Add headers to chat details bottom sheet * Simplify token log in method * Use bottom sheet for account options * Remove `AnimateScale` widget * Tweak search paddings * Update message spacing divisions * Upgrade packages * Update message spacing divisions * Regenerate splash screens * Update Inter & add google fonts * Add initial material 3 themes * Use adaptive alert dialogs * Revert to oultined inputs * Fix tooltip message * Revert add google_fonts * Improve themes and various styling * Convert categories grid to list * Tweak stream card thumbnail radii * Tweak settings headers * Left align floating snackbars * Tweak search header padding * Fix profile pics occasionally not rounded * Use profile pic for settings button if logged in * Redesign sleep timer * Use divider theme and reduce thickness * Use 0 letter spacing for tab bar titles * Redesign category streams list * Add border to tooltips * Increase category card font weight * Use outlined icon btton for chat user modal * Reduce profile pic radius in search results * Fix scrolll to top button safe area * Add support for reply threads * Reduce tooltip and snackbar border thickness * Rebuild reply threads on new messages * Upgrade packages (iOS) * Reduce font weight for all chat alerts * Use tabbars for pageview * Add dividers everywhere * Revert "Add dividers everywhere" This reverts commit 5f0d349fdbb0afad313cfb88e8c359714b3ea87a. * Remove fill from inputs * Add dividers to settings * Use segmented button for settings list * Add scrollbar to lists with scrollcontroller * Redesign badge/emote tooltip * Remove outline from chat user modal buttons * Remove divider from reply thread * Use tap for chatters list and increase font weight * Constrain emote tooltip width
2023-10-22 18:38:32 -04:00
ListTile(
title: Text('Go to channel "${widget.query}"'),
onTap: () => _handleSearch(context, widget.query),
trailing: const Icon(Icons.chevron_right_rounded),
Update to Material 3/You and other changes/fixes (#280) * Use adaptive refresh indicators * Add new message count indicator in chat * Sync pubspec.lock * Initial migration to material 3 * Restore default bottom sheet style * Remove FrostyListTile and reset styles * Use "Clear" button for all search history * Add `require_trailing_commas` lint rule * Exclude generated files from linter * Use ListView for safe area support in bottom sheet * Add initial dark theme * Make sizing and units consistent * Update onbaording spacings & copy * Migrate to default material 3 buttons * Add headers to chat details bottom sheet * Simplify token log in method * Use bottom sheet for account options * Remove `AnimateScale` widget * Tweak search paddings * Update message spacing divisions * Upgrade packages * Update message spacing divisions * Regenerate splash screens * Update Inter & add google fonts * Add initial material 3 themes * Use adaptive alert dialogs * Revert to oultined inputs * Fix tooltip message * Revert add google_fonts * Improve themes and various styling * Convert categories grid to list * Tweak stream card thumbnail radii * Tweak settings headers * Left align floating snackbars * Tweak search header padding * Fix profile pics occasionally not rounded * Use profile pic for settings button if logged in * Redesign sleep timer * Use divider theme and reduce thickness * Use 0 letter spacing for tab bar titles * Redesign category streams list * Add border to tooltips * Increase category card font weight * Use outlined icon btton for chat user modal * Reduce profile pic radius in search results * Fix scrolll to top button safe area * Add support for reply threads * Reduce tooltip and snackbar border thickness * Rebuild reply threads on new messages * Upgrade packages (iOS) * Reduce font weight for all chat alerts * Use tabbars for pageview * Add dividers everywhere * Revert "Add dividers everywhere" This reverts commit 5f0d349fdbb0afad313cfb88e8c359714b3ea87a. * Remove fill from inputs * Add dividers to settings * Use segmented button for settings list * Add scrollbar to lists with scrollcontroller * Redesign badge/emote tooltip * Remove outline from chat user modal buttons * Remove divider from reply thread * Use tap for chatters list and increase font weight * Constrain emote tooltip width
2023-10-22 18:38:32 -04:00
),
],
),
2022-01-05 09:38:05 -05:00
);
}
},
2022-01-02 19:12:39 -05:00
);
}
}