格式化代码

This commit is contained in:
rang 2025-10-25 10:38:56 +08:00
parent a28547685b
commit b3a9d76c78
24 changed files with 611 additions and 451 deletions

View file

@ -99,7 +99,8 @@ 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: [
@ -111,7 +112,9 @@ class BookOnShelf extends HookConsumerWidget {
alignment: Alignment.bottomRight,
children: [
Hero(
tag: HeroTagPrefixes.bookCover + item.id + heroTagSuffix,
tag: HeroTagPrefixes.bookCover +
item.id +
heroTagSuffix,
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: AnimatedSwitcher(
@ -125,13 +128,17 @@ 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,
);
@ -206,7 +213,8 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final me = ref.watch(meProvider);
final player = ref.watch(audiobookPlayerProvider);
final isCurrentBookSetInPlayer = player.book?.libraryItemId == libraryItemId;
final isCurrentBookSetInPlayer =
player.book?.libraryItemId == libraryItemId;
final isPlayingThisBook = player.playing && isCurrentBookSetInPlayer;
final userProgress = me.valueOrNull?.mediaProgress
@ -234,7 +242,8 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
return Theme(
// if current book is set in player, get theme from the cover image
data: ThemeData(
colorScheme: coverColorScheme.valueOrNull ?? Theme.of(context).colorScheme,
colorScheme:
coverColorScheme.valueOrNull ?? Theme.of(context).colorScheme,
),
child: Padding(
padding: EdgeInsets.all(strokeWidth / 2 + 2),
@ -249,7 +258,10 @@ 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,
),
@ -267,11 +279,15 @@ class _BookOnShelfPlayButton extends HookConsumerWidget {
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,
@ -308,8 +324,10 @@ 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),
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,
),