Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add community search #1108

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 38 additions & 21 deletions lib/feed/widgets/feed_page_app_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:lemmy_api_client/v3.dart';
import 'package:share_plus/share_plus.dart';
import 'package:swipeable_page_route/swipeable_page_route.dart';
import 'package:thunder/account/bloc/account_bloc.dart';

import 'package:thunder/community/bloc/anonymous_subscriptions_bloc.dart';
Expand All @@ -17,8 +18,11 @@ import 'package:thunder/feed/bloc/feed_bloc.dart';
import 'package:thunder/feed/utils/community.dart';
import 'package:thunder/feed/utils/utils.dart';
import 'package:thunder/feed/view/feed_page.dart';
import 'package:thunder/search/bloc/search_bloc.dart';
import 'package:thunder/search/pages/search_page.dart';
import 'package:thunder/shared/snackbar.dart';
import 'package:thunder/shared/sort_picker.dart';
import 'package:thunder/shared/thunder_popup_menu_item.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';

class FeedPageAppBar extends StatelessWidget {
Expand Down Expand Up @@ -119,38 +123,51 @@ class FeedPageAppBar extends StatelessWidget {
if (feedState.feedType == FeedType.community)
PopupMenuButton(
itemBuilder: (context) => [
PopupMenuItem(
ThunderPopupMenuItem(
onTap: () => triggerRefresh(context),
child: ListTile(
dense: true,
horizontalTitleGap: 5,
leading: const Icon(Icons.refresh_rounded, size: 20),
title: Text(l10n.refresh),
),
icon: Icons.refresh_rounded,
title: l10n.refresh,
),
if (_getSubscriptionStatus(context) == SubscribedType.subscribed)
PopupMenuItem(
ThunderPopupMenuItem(
onTap: () async {
final Community community = context.read<FeedBloc>().state.fullCommunityView!.communityView.community;
bool isFavorite = _getFavoriteStatus(context);
await toggleFavoriteCommunity(context, community, isFavorite);
},
child: ListTile(
dense: true,
horizontalTitleGap: 5,
leading: Icon(_getFavoriteStatus(context) ? Icons.star_rounded : Icons.star_border_rounded, size: 20),
title: Text(_getFavoriteStatus(context) ? l10n.removeFromFavorites : l10n.addToFavorites),
),
icon: _getFavoriteStatus(context) ? Icons.star_rounded : Icons.star_border_rounded,
title: _getFavoriteStatus(context) ? l10n.removeFromFavorites : l10n.addToFavorites,
),
if (feedBloc.state.fullCommunityView?.communityView.community.actorId != null)
PopupMenuItem(
ThunderPopupMenuItem(
onTap: () => Share.share(feedBloc.state.fullCommunityView!.communityView.community.actorId),
child: ListTile(
dense: true,
horizontalTitleGap: 5,
leading: const Icon(Icons.share_rounded, size: 20),
title: Text(l10n.share),
),
icon: Icons.share_rounded,
title: l10n.share,
),
if (feedBloc.state.fullCommunityView?.communityView != null)
ThunderPopupMenuItem(
onTap: () async {
final ThunderState state = context.read<ThunderBloc>().state;
final bool reduceAnimations = state.reduceAnimations;

await Navigator.of(context).push(
SwipeablePageRoute(
transitionDuration: reduceAnimations ? const Duration(milliseconds: 100) : null,
backGestureDetectionWidth: 45,
canOnlySwipeFromEdge: true,
builder: (context) => MultiBlocProvider(
providers: [
// Create a new SearchBloc so it doesn't conflict with the main one
BlocProvider.value(value: SearchBloc()),
BlocProvider.value(value: thunderBloc),
],
child: SearchPage(communityToSearch: feedBloc.state.fullCommunityView!.communityView),
),
),
);
},
icon: Icons.search_rounded,
title: l10n.search,
),
],
),
Expand Down
4 changes: 1 addition & 3 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,7 @@
"@noLanguage": {
"description": "The entry for no language when selecting a post language"
},
"noPosts": "No posts found.",
"@noPosts": {},
"noPostsFound": "No posts found",
"noPostsFound": "No posts found.",
"@noPostsFound": {},
"noResultsFound": "No results found.",
"@noResultsFound": {},
Expand Down
11 changes: 4 additions & 7 deletions lib/post/pages/post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'package:thunder/shared/cross_posts.dart';
import 'package:thunder/shared/error_message.dart';
import 'package:thunder/shared/input_dialogs.dart';
import 'package:thunder/shared/snackbar.dart';
import 'package:thunder/shared/thunder_popup_menu_item.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

Expand Down Expand Up @@ -204,20 +205,16 @@ class _PostPageState extends State<PostPage> {
),
PopupMenuButton(
itemBuilder: (context) => [
PopupMenuItem(
ThunderPopupMenuItem(
onTap: () => createCrossPost(
context,
title: widget.postView?.postView.post.name ?? state.postView?.postView.post.name ?? '',
url: widget.postView?.postView.post.url ?? state.postView?.postView.post.url,
text: widget.postView?.postView.post.body ?? state.postView?.postView.post.body,
postUrl: widget.postView?.postView.post.apId ?? state.postView?.postView.post.apId,
),
child: ListTile(
dense: true,
horizontalTitleGap: 5,
leading: const Icon(Icons.repeat_rounded, size: 20),
title: Text(l10n.createNewCrossPost),
),
icon: Icons.repeat_rounded,
title: l10n.createNewCrossPost,
),
],
),
Expand Down
Loading
Loading