mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-01-15 14:49: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
|
|
@ -52,7 +52,8 @@ class AddNewServer extends HookConsumerWidget {
|
|||
// do nothing
|
||||
appLogger.severe('Error parsing URI: $e');
|
||||
}
|
||||
final canSubmit = !readOnly &&
|
||||
final canSubmit =
|
||||
!readOnly &&
|
||||
(isServerAliveValue || (allowEmpty && newServerURI.text.isEmpty));
|
||||
return TextFormField(
|
||||
readOnly: readOnly,
|
||||
|
|
@ -71,8 +72,9 @@ class AddNewServer extends HookConsumerWidget {
|
|||
color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.8),
|
||||
),
|
||||
border: const OutlineInputBorder(),
|
||||
prefixText:
|
||||
myController.text.startsWith(httpUrlRegExp) ? '' : 'https://',
|
||||
prefixText: myController.text.startsWith(httpUrlRegExp)
|
||||
? ''
|
||||
: 'https://',
|
||||
prefixIcon: ServerAliveIcon(server: parsedUri),
|
||||
|
||||
// add server button
|
||||
|
|
@ -101,10 +103,7 @@ class AddNewServer extends HookConsumerWidget {
|
|||
}
|
||||
|
||||
class ServerAliveIcon extends HookConsumerWidget {
|
||||
const ServerAliveIcon({
|
||||
super.key,
|
||||
required this.server,
|
||||
});
|
||||
const ServerAliveIcon({super.key, required this.server});
|
||||
|
||||
final Uri server;
|
||||
|
||||
|
|
@ -121,8 +120,8 @@ class ServerAliveIcon extends HookConsumerWidget {
|
|||
message: server.toString().isEmpty
|
||||
? 'Server Status'
|
||||
: isServerAliveValue
|
||||
? 'Server connected'
|
||||
: 'Cannot connect to server',
|
||||
? 'Server connected'
|
||||
: 'Cannot connect to server',
|
||||
child: server.toString().isEmpty
|
||||
? Icon(
|
||||
Icons.cloud_outlined,
|
||||
|
|
|
|||
|
|
@ -4,9 +4,7 @@ import 'package:vaani/features/you/view/server_manager.dart';
|
|||
import 'package:vaani/router/router.dart';
|
||||
|
||||
class MyDrawer extends StatelessWidget {
|
||||
const MyDrawer({
|
||||
super.key,
|
||||
});
|
||||
const MyDrawer({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -16,10 +14,7 @@ class MyDrawer extends StatelessWidget {
|
|||
const DrawerHeader(
|
||||
child: Text(
|
||||
'Vaani',
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
fontSize: 30,
|
||||
),
|
||||
style: TextStyle(fontStyle: FontStyle.italic, fontSize: 30),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
|
|
|
|||
|
|
@ -55,10 +55,7 @@ class ExpandableDescription extends HookWidget {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
// header text
|
||||
Text(
|
||||
style: textTheme.titleMedium,
|
||||
title,
|
||||
),
|
||||
Text(style: textTheme.titleMedium, title),
|
||||
// carrot icon
|
||||
AnimatedRotation(
|
||||
turns: isDescExpanded.value ? 0.5 : 0,
|
||||
|
|
@ -79,11 +76,7 @@ class ExpandableDescription extends HookWidget {
|
|||
child: AnimatedSwitcher(
|
||||
duration: duration * 3,
|
||||
child: isDescExpanded.value
|
||||
? Text(
|
||||
style: textTheme.bodyMedium,
|
||||
content,
|
||||
maxLines: null,
|
||||
)
|
||||
? Text(style: textTheme.bodyMedium, content, maxLines: null)
|
||||
: Text(
|
||||
style: textTheme.bodyMedium,
|
||||
content,
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@ import 'package:flutter/material.dart';
|
|||
|
||||
void showNotImplementedToast(BuildContext context) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text("Not implemented"),
|
||||
showCloseIcon: true,
|
||||
),
|
||||
const SnackBar(content: Text("Not implemented"), showCloseIcon: true),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,11 +6,7 @@ import 'package:vaani/shared/widgets/shelves/home_shelf.dart';
|
|||
|
||||
/// A shelf that displays Authors on the home page
|
||||
class AuthorHomeShelf extends HookConsumerWidget {
|
||||
const AuthorHomeShelf({
|
||||
super.key,
|
||||
required this.shelf,
|
||||
required this.title,
|
||||
});
|
||||
const AuthorHomeShelf({super.key, required this.shelf, required this.title});
|
||||
|
||||
final String title;
|
||||
final AuthorShelf shelf;
|
||||
|
|
@ -20,9 +16,7 @@ class AuthorHomeShelf extends HookConsumerWidget {
|
|||
return SimpleHomeShelf(
|
||||
title: title,
|
||||
children: shelf.entities
|
||||
.map(
|
||||
(item) => AuthorOnShelf(item: item),
|
||||
)
|
||||
.map((item) => AuthorOnShelf(item: item))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
|
@ -30,10 +24,7 @@ class AuthorHomeShelf extends HookConsumerWidget {
|
|||
|
||||
// a widget to display a item on the shelf
|
||||
class AuthorOnShelf extends HookConsumerWidget {
|
||||
const AuthorOnShelf({
|
||||
super.key,
|
||||
required this.item,
|
||||
});
|
||||
const AuthorOnShelf({super.key, required this.item});
|
||||
|
||||
final Author item;
|
||||
|
||||
|
|
|
|||
|
|
@ -40,11 +40,11 @@ class BookHomeShelf extends HookConsumerWidget {
|
|||
.map(
|
||||
(item) => switch (item.mediaType) {
|
||||
MediaType.book => BookOnShelf(
|
||||
item: item,
|
||||
key: ValueKey(shelf.id + item.id),
|
||||
heroTagSuffix: shelf.id,
|
||||
showPlayButton: showPlayButton,
|
||||
),
|
||||
item: item,
|
||||
key: ValueKey(shelf.id + item.id),
|
||||
heroTagSuffix: shelf.id,
|
||||
showPlayButton: showPlayButton,
|
||||
),
|
||||
_ => Container(),
|
||||
},
|
||||
)
|
||||
|
|
@ -83,13 +83,8 @@ class BookOnShelf extends HookConsumerWidget {
|
|||
// open the book
|
||||
context.pushNamed(
|
||||
Routes.libraryItem.name,
|
||||
pathParameters: {
|
||||
Routes.libraryItem.pathParamName!: item.id,
|
||||
},
|
||||
extra: LibraryItemExtras(
|
||||
book: book,
|
||||
heroTagSuffix: heroTagSuffix,
|
||||
),
|
||||
pathParameters: {Routes.libraryItem.pathParamName!: item.id},
|
||||
extra: LibraryItemExtras(book: book, heroTagSuffix: heroTagSuffix),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -99,8 +94,11 @@ class BookOnShelf extends HookConsumerWidget {
|
|||
onTap: handleTapOnBook,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(bottom: 8.0, right: 4.0, left: 4.0),
|
||||
padding: const EdgeInsets.only(
|
||||
bottom: 8.0,
|
||||
right: 4.0,
|
||||
left: 4.0,
|
||||
),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
|
|
@ -112,7 +110,8 @@ class BookOnShelf extends HookConsumerWidget {
|
|||
alignment: Alignment.bottomRight,
|
||||
children: [
|
||||
Hero(
|
||||
tag: HeroTagPrefixes.bookCover +
|
||||
tag:
|
||||
HeroTagPrefixes.bookCover +
|
||||
item.id +
|
||||
heroTagSuffix,
|
||||
child: ClipRRect(
|
||||
|
|
@ -128,17 +127,19 @@ class BookOnShelf extends HookConsumerWidget {
|
|||
var imageWidget = Image.memory(
|
||||
image,
|
||||
fit: BoxFit.fill,
|
||||
cacheWidth: (height *
|
||||
1.2 *
|
||||
MediaQuery.of(context)
|
||||
.devicePixelRatio)
|
||||
.round(),
|
||||
cacheWidth:
|
||||
(height *
|
||||
1.2 *
|
||||
MediaQuery.of(
|
||||
context,
|
||||
).devicePixelRatio)
|
||||
.round(),
|
||||
);
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.colorScheme
|
||||
.onPrimaryContainer,
|
||||
color: Theme.of(
|
||||
context,
|
||||
).colorScheme.onPrimaryContainer,
|
||||
),
|
||||
child: imageWidget,
|
||||
);
|
||||
|
|
@ -157,9 +158,7 @@ class BookOnShelf extends HookConsumerWidget {
|
|||
),
|
||||
// a play button on the book cover
|
||||
if (showPlayButton)
|
||||
_BookOnShelfPlayButton(
|
||||
libraryItemId: item.id,
|
||||
),
|
||||
_BookOnShelfPlayButton(libraryItemId: item.id),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -202,9 +201,7 @@ class BookOnShelf extends HookConsumerWidget {
|
|||
}
|
||||
|
||||
class _BookOnShelfPlayButton extends HookConsumerWidget {
|
||||
const _BookOnShelfPlayButton({
|
||||
required this.libraryItemId,
|
||||
});
|
||||
const _BookOnShelfPlayButton({required this.libraryItemId});
|
||||
|
||||
/// the id of the library item of the book
|
||||
final String libraryItemId;
|
||||
|
|
@ -217,8 +214,9 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
|
|||
player.book?.libraryItemId == libraryItemId;
|
||||
final isPlayingThisBook = player.playing && isCurrentBookSetInPlayer;
|
||||
|
||||
final userProgress = me.value?.mediaProgress
|
||||
?.firstWhereOrNull((element) => element.libraryItemId == libraryItemId);
|
||||
final userProgress = me.value?.mediaProgress?.firstWhereOrNull(
|
||||
(element) => element.libraryItemId == libraryItemId,
|
||||
);
|
||||
final isBookCompleted = userProgress?.isFinished ?? false;
|
||||
|
||||
const size = 40.0;
|
||||
|
|
@ -226,8 +224,10 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
|
|||
// if there is user progress for this book show a circular progress indicator around the play button
|
||||
var strokeWidth = size / 8;
|
||||
|
||||
final useMaterialThemeOnItemPage =
|
||||
ref.watch(appSettingsProvider).themeSettings.useMaterialThemeOnItemPage;
|
||||
final useMaterialThemeOnItemPage = ref
|
||||
.watch(appSettingsProvider)
|
||||
.themeSettings
|
||||
.useMaterialThemeOnItemPage;
|
||||
|
||||
AsyncValue<ColorScheme?> coverColorScheme = const AsyncValue.loading();
|
||||
if (useMaterialThemeOnItemPage && isCurrentBookSetInPlayer) {
|
||||
|
|
@ -242,8 +242,7 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
|
|||
return Theme(
|
||||
// if current book is set in player, get theme from the cover image
|
||||
data: ThemeData(
|
||||
colorScheme:
|
||||
coverColorScheme.value ?? Theme.of(context).colorScheme,
|
||||
colorScheme: coverColorScheme.value ?? Theme.of(context).colorScheme,
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(strokeWidth / 2 + 2),
|
||||
|
|
@ -258,10 +257,9 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
|
|||
child: CircularProgressIndicator(
|
||||
value: userProgress.progress,
|
||||
strokeWidth: strokeWidth,
|
||||
backgroundColor: Theme.of(context)
|
||||
.colorScheme
|
||||
.onPrimary
|
||||
.withValues(alpha: 0.8),
|
||||
backgroundColor: Theme.of(
|
||||
context,
|
||||
).colorScheme.onPrimary.withValues(alpha: 0.8),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
|
|
@ -272,22 +270,18 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
|
|||
IconButton(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
style: ButtonStyle(
|
||||
padding: WidgetStateProperty.all(
|
||||
EdgeInsets.zero,
|
||||
),
|
||||
minimumSize: WidgetStateProperty.all(
|
||||
const Size(size, size),
|
||||
),
|
||||
padding: WidgetStateProperty.all(EdgeInsets.zero),
|
||||
minimumSize: WidgetStateProperty.all(const Size(size, size)),
|
||||
backgroundColor: WidgetStateProperty.all(
|
||||
Theme.of(context)
|
||||
.colorScheme
|
||||
.onPrimary
|
||||
.withValues(alpha: 0.9),
|
||||
Theme.of(
|
||||
context,
|
||||
).colorScheme.onPrimary.withValues(alpha: 0.9),
|
||||
),
|
||||
),
|
||||
onPressed: () async {
|
||||
final book =
|
||||
await ref.watch(libraryItemProvider(libraryItemId).future);
|
||||
final book = await ref.watch(
|
||||
libraryItemProvider(libraryItemId).future,
|
||||
);
|
||||
|
||||
libraryItemPlayButtonOnPressed(
|
||||
ref: ref,
|
||||
|
|
@ -313,9 +307,7 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
|
|||
|
||||
// a skeleton for the book cover
|
||||
class BookCoverSkeleton extends StatelessWidget {
|
||||
const BookCoverSkeleton({
|
||||
super.key,
|
||||
});
|
||||
const BookCoverSkeleton({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
@ -324,13 +316,13 @@ class BookCoverSkeleton extends StatelessWidget {
|
|||
child: SizedBox(
|
||||
width: 150,
|
||||
child: Shimmer.fromColors(
|
||||
baseColor:
|
||||
Theme.of(context).colorScheme.surface.withValues(alpha: 0.3),
|
||||
highlightColor:
|
||||
Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.1),
|
||||
child: Container(
|
||||
color: Theme.of(context).colorScheme.surface,
|
||||
),
|
||||
baseColor: Theme.of(
|
||||
context,
|
||||
).colorScheme.surface.withValues(alpha: 0.3),
|
||||
highlightColor: Theme.of(
|
||||
context,
|
||||
).colorScheme.onSurface.withValues(alpha: 0.1),
|
||||
child: Container(color: Theme.of(context).colorScheme.surface),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@ class HomeShelf extends HookConsumerWidget {
|
|||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return switch (shelf.type) {
|
||||
ShelfType.book => BookHomeShelf(
|
||||
title: title,
|
||||
shelf: shelf.asLibraryItemShelf,
|
||||
showPlayButton: showPlayButton,
|
||||
),
|
||||
title: title,
|
||||
shelf: shelf.asLibraryItemShelf,
|
||||
showPlayButton: showPlayButton,
|
||||
),
|
||||
ShelfType.authors => AuthorHomeShelf(
|
||||
title: title,
|
||||
shelf: shelf.asAuthorShelf,
|
||||
),
|
||||
title: title,
|
||||
shelf: shelf.asAuthorShelf,
|
||||
),
|
||||
_ => Container(),
|
||||
};
|
||||
}
|
||||
|
|
@ -75,9 +75,7 @@ class SimpleHomeShelf extends HookConsumerWidget {
|
|||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0 || index == children.length + 1) {
|
||||
return const SizedBox(
|
||||
width: 8,
|
||||
);
|
||||
return const SizedBox(width: 8);
|
||||
}
|
||||
return children[index - 1];
|
||||
},
|
||||
|
|
@ -88,7 +86,8 @@ class SimpleHomeShelf extends HookConsumerWidget {
|
|||
|
||||
return const SizedBox(width: 4);
|
||||
},
|
||||
itemCount: children.length +
|
||||
itemCount:
|
||||
children.length +
|
||||
2, // add some extra space at the start and end so that the first and last items are not at the edge
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue