Skip to content

Commit

Permalink
feat: click artist to search
Browse files Browse the repository at this point in the history
  • Loading branch information
Yesterday17 committed Sep 16, 2024
1 parent d8408d1 commit b3b3d60
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/ui/page/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class SearchPage extends HookConsumerWidget {
const SearchPage({super.key});
final String? keyword;

const SearchPage({super.key, this.keyword});

@override
Widget build(BuildContext context, final WidgetRef ref) {
Expand Down Expand Up @@ -43,6 +45,13 @@ class SearchPage extends HookConsumerWidget {
}
}

useEffect(() {
if (keyword != null) {
search(anniv.client!, keyword!);
}
return null;
}, [keyword]);

return Scaffold(
body: SafeArea(
child: Padding(
Expand All @@ -55,6 +64,7 @@ class SearchPage extends HookConsumerWidget {
icon: const Icon(Icons.search),
hintText: t.search,
),
controller: TextEditingController(text: keyword),
onSubmitted: (final keyword) => search(anniv.client!, keyword),
),
Expanded(
Expand Down Expand Up @@ -100,6 +110,7 @@ class _SearchResultWidget extends HookConsumerWidget {
padding: const EdgeInsets.all(8.0),
child: OverflowBar(
alignment: MainAxisAlignment.start,
spacing: 8.0,
children: [
if ((result.value?.tracks?.length ?? 0) > 0)
FilterChip(
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/route/delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ class AnnixRouterDelegate extends RouterDelegate<List<RouteSettings>>
playlistInfo: routeSettings.arguments as PlaylistInfo);
break;
case '/search':
child = const SearchPage();
final keyword = routeSettings.arguments as String?;
child = SearchPage(keyword: keyword);
break;
case '/settings':
child = const SettingsScreen();
Expand Down
5 changes: 5 additions & 0 deletions lib/ui/widgets/artist_text.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:annix/ui/route/delegate.dart';
import 'package:annix/utils/context_extension.dart';
import 'package:flutter/material.dart';

Expand Down Expand Up @@ -94,6 +95,10 @@ class _ArtistTextState extends State<ArtistText> {
@override
Widget build(final BuildContext context) {
return GestureDetector(
onTap: () {
AnnixRouterDelegate.of(context)
.off(name: '/search', arguments: widget.artist);
},
onLongPress: toggleExtend,
child: Row(
mainAxisSize: MainAxisSize.min,
Expand Down

0 comments on commit b3b3d60

Please sign in to comment.