chore: run dart format
Some checks are pending
Flutter CI & Release / Test (push) Waiting to run
Flutter CI & Release / Build Android APKs (push) Blocked by required conditions
Flutter CI & Release / build_linux (push) Blocked by required conditions
Flutter CI & Release / Create GitHub Release (push) Blocked by required conditions

This commit is contained in:
Dr.Blank 2026-01-10 16:51:05 +05:30
parent a520136e01
commit e23c0b6c5f
No known key found for this signature in database
GPG key ID: BA5F87FF0560C57B
84 changed files with 1565 additions and 1945 deletions

View file

@ -28,18 +28,14 @@ class ExplorePage extends HookConsumerWidget {
final settings = ref.watch(appSettingsProvider);
final api = ref.watch(authenticatedApiProvider);
return Scaffold(
appBar: AppBar(
title: const Text('Explore'),
),
appBar: AppBar(title: const Text('Explore')),
body: const MySearchBar(),
);
}
}
class MySearchBar extends HookConsumerWidget {
const MySearchBar({
super.key,
});
const MySearchBar({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
@ -61,8 +57,11 @@ class MySearchBar extends HookConsumerWidget {
currentQuery = query;
// In a real application, there should be some error handling here.
final options = await api.libraries
.search(libraryId: settings.activeLibraryId!, query: query, limit: 3);
final options = await api.libraries.search(
libraryId: settings.activeLibraryId!,
query: query,
limit: 3,
);
// If another search happened after this one, throw away these options.
if (currentQuery != query) {
@ -97,11 +96,10 @@ class MySearchBar extends HookConsumerWidget {
// opacity: 0.5 for the hint text
hintStyle: WidgetStatePropertyAll(
Theme.of(context).textTheme.bodyMedium!.copyWith(
color: Theme.of(context)
.colorScheme
.onSurface
.withValues(alpha: 0.5),
),
color: Theme.of(
context,
).colorScheme.onSurface.withValues(alpha: 0.5),
),
),
textInputAction: TextInputAction.search,
onTapOutside: (_) {
@ -120,12 +118,7 @@ class MySearchBar extends HookConsumerWidget {
);
},
viewOnSubmitted: (value) {
context.pushNamed(
Routes.search.name,
queryParameters: {
'q': value,
},
);
context.pushNamed(Routes.search.name, queryParameters: {'q': value});
},
suggestionsBuilder: (context, controller) async {
// check if the search controller is empty
@ -191,14 +184,12 @@ List<Widget> buildBookSearchResult(
SearchResultMiniSection(
// title: 'Books',
category: SearchResultCategory.books,
options: options.book.map(
(result) {
// convert result to a book object
final book = result.libraryItem.media.asBookExpanded;
final metadata = book.metadata.asBookMetadataExpanded;
return BookSearchResultMini(book: book, metadata: metadata);
},
),
options: options.book.map((result) {
// convert result to a book object
final book = result.libraryItem.media.asBookExpanded;
final metadata = book.metadata.asBookMetadataExpanded;
return BookSearchResultMini(book: book, metadata: metadata);
}),
),
);
}
@ -207,11 +198,9 @@ List<Widget> buildBookSearchResult(
SearchResultMiniSection(
// title: 'Authors',
category: SearchResultCategory.authors,
options: options.authors.map(
(result) {
return ListTile(title: Text(result.name));
},
),
options: options.authors.map((result) {
return ListTile(title: Text(result.name));
}),
),
);
}
@ -245,10 +234,7 @@ class BookSearchResultMini extends HookConsumerWidget {
child: ClipRRect(
borderRadius: BorderRadius.circular(5),
child: image.when(
data: (bytes) => Image.memory(
bytes,
fit: BoxFit.cover,
),
data: (bytes) => Image.memory(bytes, fit: BoxFit.cover),
loading: () => const BookCoverSkeleton(),
error: (error, _) => const Icon(Icons.error),
),
@ -259,11 +245,7 @@ class BookSearchResultMini extends HookConsumerWidget {
subtitle: Text(
maxLines: 1,
overflow: TextOverflow.ellipsis,
metadata.authors
.map(
(author) => author.name,
)
.join(', '),
metadata.authors.map((author) => author.name).join(', '),
),
onTap: () {
// navigate to the book details page