修改下载名称显示为书籍名称

This commit is contained in:
rang 2025-10-21 14:43:48 +08:00
parent 699b7de311
commit e0deb84123
4 changed files with 7 additions and 58 deletions

View file

@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:vaani/api/library_item_provider.dart';
import 'package:vaani/features/downloads/providers/download_manager.dart';
class DownloadsPage extends HookConsumerWidget {
@ -7,7 +8,7 @@ class DownloadsPage extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final manager = ref.read(simpleDownloadManagerProvider);
// final manager = ref.read(simpleDownloadManagerProvider);
final downloadHistory = ref.watch(downloadHistoryProvider());
return Scaffold(
@ -25,8 +26,10 @@ class DownloadsPage extends HookConsumerWidget {
itemBuilder: (context, index) {
final group = uniqueGroups.elementAt(index);
final groupRecords = records.where((e) => e.group == group);
final item = ref.watch(libraryItemProvider(group)).valueOrNull;
return ExpansionTile(
title: Text(group ?? 'No Group'),
title: Text(item?.media.metadata.title ?? group),
children: groupRecords
.map(
(e) => ListTile(

View file

@ -235,57 +235,3 @@ class AudiobookChapterProgressBar extends HookConsumerWidget {
// ! TODO remove onTap
void onTap() {}
class ProportionalAdjuster {
final double minValue;
final double maxValue;
ProportionalAdjuster({this.minValue = 0.0, this.maxValue = 1.0});
double adjust(double value, double ratio, {AdjustMethod method = AdjustMethod.linear}) {
switch (method) {
case AdjustMethod.linear:
return _linearAdjust(value, ratio);
case AdjustMethod.exponential:
return _exponentialAdjust(value, ratio);
case AdjustMethod.smooth:
return _smoothAdjust(value, ratio);
}
}
double _linearAdjust(double value, double ratio) {
if (value <= minValue) return minValue;
if (value >= maxValue) return maxValue;
double newValue;
if (ratio > 1) {
newValue = value + (maxValue - value) * (ratio - 1);
} else {
newValue = value * ratio;
}
return newValue.clamp(minValue, maxValue);
}
double _exponentialAdjust(double value, double ratio) {
if (value <= minValue) return minValue;
if (value >= maxValue) return maxValue;
double newValue;
if (ratio > 1) {
newValue = maxValue - (maxValue - value) / ratio;
} else {
newValue = value * ratio;
}
return newValue.clamp(minValue, maxValue);
}
double _smoothAdjust(double value, double progress) {
progress = progress.clamp(0.0, 1.0);
double target = value > (minValue + maxValue) / 2 ? maxValue : minValue;
return value + (target - value) * progress;
}
}
enum AdjustMethod { linear, exponential, smooth }

View file

@ -133,7 +133,7 @@ class PlayerWhenExpanded extends HookConsumerWidget {
opacity: earlyPercentage,
child: Padding(
padding: EdgeInsets.only(
top: AppElementSizes.paddingLarge * earlyPercentage,
top: AppElementSizes.paddingRegular * earlyPercentage,
// horizontal: 16.0,
),
// child: SizedBox(
@ -204,6 +204,7 @@ class PlayerWhenExpanded extends HookConsumerWidget {
opacity: earlyPercentage,
child: SizedBox(
width: imageSize,
height: AppElementSizes.iconSizeRegular,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [

View file

@ -129,7 +129,6 @@ class PlayerWhenMinimized extends HookConsumerWidget {
),
],
),
const Spacer(),
SizedBox(
height: barHeight,
child: LinearProgressIndicator(