mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
feature: Re-implemented syncing
This commit is contained in:
parent
c5c7f71b84
commit
86ff355e21
51 changed files with 3067 additions and 1147 deletions
|
|
@ -12,7 +12,6 @@ import 'package:fladder/models/syncing/sync_item.dart';
|
|||
import 'package:fladder/providers/sync/background_download_provider.dart';
|
||||
import 'package:fladder/providers/sync/sync_provider_helpers.dart';
|
||||
import 'package:fladder/providers/sync_provider.dart';
|
||||
import 'package:fladder/util/list_padding.dart';
|
||||
import 'package:fladder/util/localization_helper.dart';
|
||||
|
||||
const _cancellableStatuses = {
|
||||
|
|
@ -24,23 +23,23 @@ const _cancellableStatuses = {
|
|||
|
||||
class SyncLabel extends ConsumerWidget {
|
||||
final String? label;
|
||||
final SyncStatus status;
|
||||
final TaskStatus status;
|
||||
const SyncLabel({this.label, required this.status, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: status.color.withValues(alpha: 0.15),
|
||||
color: status.color(context).withValues(alpha: 0.15),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
child: Text(
|
||||
label ?? status.label(context),
|
||||
label ?? status.name(context),
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: status.color,
|
||||
color: status.color(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -68,6 +67,7 @@ class SyncProgressBar extends ConsumerWidget {
|
|||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Flexible(
|
||||
child: LinearProgressIndicator(
|
||||
|
|
@ -79,7 +79,7 @@ class SyncProgressBar extends ConsumerWidget {
|
|||
),
|
||||
Opacity(opacity: 0.75, child: Text("${(downloadProgress * 100).toStringAsFixed(0)}%")),
|
||||
if (downloadTask != null) ...{
|
||||
if (downloadStatus != TaskStatus.paused)
|
||||
if (downloadStatus != TaskStatus.paused && downloadStatus != TaskStatus.enqueued)
|
||||
IconButton(
|
||||
onPressed: () => ref.read(backgroundDownloaderProvider).pause(downloadTask),
|
||||
icon: const Icon(IconsaxPlusBold.pause),
|
||||
|
|
@ -101,7 +101,7 @@ class SyncProgressBar extends ConsumerWidget {
|
|||
),
|
||||
],
|
||||
},
|
||||
].addInBetween(const SizedBox(width: 8)),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
],
|
||||
|
|
@ -120,33 +120,46 @@ class SyncSubtitle extends ConsumerWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final baseItem = ref.read(syncProvider.notifier).getItem(syncItem);
|
||||
final syncStatus = ref.watch(syncStatusesProvider(syncItem, children)).value ?? SyncStatus.partially;
|
||||
final baseItem = syncItem.itemModel;
|
||||
final syncStatus = ref
|
||||
.watch(syncDownloadStatusProvider(syncItem, children).select((value) => value?.status ?? TaskStatus.notFound));
|
||||
return Container(
|
||||
decoration:
|
||||
BoxDecoration(color: syncStatus.color.withValues(alpha: 0.15), borderRadius: BorderRadius.circular(10)),
|
||||
decoration: BoxDecoration(
|
||||
color: syncStatus.color(context).withValues(alpha: 0.15), borderRadius: BorderRadius.circular(10)),
|
||||
child: Material(
|
||||
color: const Color.fromARGB(0, 208, 130, 130),
|
||||
textStyle:
|
||||
Theme.of(context).textTheme.bodyMedium?.copyWith(fontWeight: FontWeight.bold, color: syncStatus.color),
|
||||
textStyle: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyMedium
|
||||
?.copyWith(fontWeight: FontWeight.bold, color: syncStatus.color(context)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
child: switch (baseItem) {
|
||||
SeriesModel _ => Builder(
|
||||
SeasonModel _ => Builder(
|
||||
builder: (context) {
|
||||
final itemBaseModels = children.map((e) => ref.read(syncProvider.notifier).getItem(e));
|
||||
final seriesItemsSyncLeft = children.where((element) => element.taskId != null).length;
|
||||
final seasons = itemBaseModels.whereType<SeasonModel>().length;
|
||||
final itemBaseModels = children.map((e) => e.itemModel);
|
||||
final episodes = itemBaseModels.whereType<EpisodeModel>().length;
|
||||
return Text(
|
||||
[
|
||||
"${context.localized.season(seasons)}: $seasons",
|
||||
"${context.localized.episode(seasons)}: $episodes | ${context.localized.sync}: ${children.where((element) => element.videoFile.existsSync()).length}${seriesItemsSyncLeft > 0 ? " | Syncing: $seriesItemsSyncLeft" : ""}"
|
||||
"${context.localized.episode(2)}: $episodes | ${context.localized.syncStatusSynced}: ${children.where((element) => element.videoFile.existsSync()).length}"
|
||||
].join('\n'),
|
||||
);
|
||||
},
|
||||
),
|
||||
_ => Text(syncStatus.label(context)),
|
||||
SeriesModel _ => Builder(
|
||||
builder: (context) {
|
||||
final itemBaseModels = children.map((e) => e.itemModel);
|
||||
final seasons = itemBaseModels.whereType<SeasonModel>().length;
|
||||
final episodes = itemBaseModels.whereType<EpisodeModel>().length;
|
||||
return Text(
|
||||
[
|
||||
"${context.localized.season(2)}: $seasons",
|
||||
"${context.localized.episode(2)}: $episodes | ${context.localized.syncStatusSynced}: ${children.where((element) => element.videoFile.existsSync()).length}"
|
||||
].join('\n'),
|
||||
);
|
||||
},
|
||||
),
|
||||
_ => Text(syncStatus.name(context)),
|
||||
},
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue