mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-01-14 06:09:32 +00:00
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
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:
parent
a520136e01
commit
e23c0b6c5f
84 changed files with 1565 additions and 1945 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -5,13 +5,7 @@ import 'package:vaani/features/explore/providers/search_result_provider.dart';
|
|||
import 'package:vaani/features/explore/view/explore_page.dart';
|
||||
import 'package:vaani/shared/extensions/model_conversions.dart';
|
||||
|
||||
enum SearchResultCategory {
|
||||
books,
|
||||
authors,
|
||||
series,
|
||||
tags,
|
||||
narrators,
|
||||
}
|
||||
enum SearchResultCategory { books, authors, series, tags, narrators }
|
||||
|
||||
class SearchResultPage extends HookConsumerWidget {
|
||||
const SearchResultPage({
|
||||
|
|
@ -41,9 +35,7 @@ class SearchResultPage extends HookConsumerWidget {
|
|||
body: results.when(
|
||||
data: (options) {
|
||||
if (options == null) {
|
||||
return Container(
|
||||
child: const Text('No data found'),
|
||||
);
|
||||
return Container(child: const Text('No data found'));
|
||||
}
|
||||
if (options is BookLibrarySearchResponse) {
|
||||
if (category == null) {
|
||||
|
|
@ -51,18 +43,15 @@ class SearchResultPage extends HookConsumerWidget {
|
|||
}
|
||||
return switch (category!) {
|
||||
SearchResultCategory.books => ListView.builder(
|
||||
itemCount: options.book.length,
|
||||
itemBuilder: (context, index) {
|
||||
final book =
|
||||
options.book[index].libraryItem.media.asBookExpanded;
|
||||
final metadata = book.metadata.asBookMetadataExpanded;
|
||||
itemCount: options.book.length,
|
||||
itemBuilder: (context, index) {
|
||||
final book =
|
||||
options.book[index].libraryItem.media.asBookExpanded;
|
||||
final metadata = book.metadata.asBookMetadataExpanded;
|
||||
|
||||
return BookSearchResultMini(
|
||||
book: book,
|
||||
metadata: metadata,
|
||||
);
|
||||
},
|
||||
),
|
||||
return BookSearchResultMini(book: book, metadata: metadata);
|
||||
},
|
||||
),
|
||||
SearchResultCategory.authors => Container(),
|
||||
SearchResultCategory.series => Container(),
|
||||
SearchResultCategory.tags => Container(),
|
||||
|
|
@ -71,12 +60,8 @@ class SearchResultPage extends HookConsumerWidget {
|
|||
}
|
||||
return null;
|
||||
},
|
||||
loading: () => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error: (error, stackTrace) => Center(
|
||||
child: Text('Error: $error'),
|
||||
),
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (error, stackTrace) => Center(child: Text('Error: $error')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue