mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-08 23:18:16 -07:00
Init repo
This commit is contained in:
commit
764b6034e3
566 changed files with 212335 additions and 0 deletions
41
lib/screens/syncing/widgets/sync_markedfordelete.dart
Normal file
41
lib/screens/syncing/widgets/sync_markedfordelete.dart
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import 'package:ficonsax/ficonsax.dart';
|
||||
import 'package:fladder/models/syncing/sync_item.dart';
|
||||
import 'package:fladder/util/list_padding.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class SyncMarkedForDelete extends ConsumerWidget {
|
||||
final SyncedItem syncedItem;
|
||||
final Widget child;
|
||||
const SyncMarkedForDelete({required this.syncedItem, required this.child, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return Stack(
|
||||
children: [
|
||||
child,
|
||||
if (syncedItem.markedForDelete)
|
||||
Positioned.fill(
|
||||
child: Card(
|
||||
elevation: 0,
|
||||
semanticContainer: false,
|
||||
color: Colors.black.withOpacity(0.6),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator.adaptive(
|
||||
strokeCap: StrokeCap.round,
|
||||
valueColor: AlwaysStoppedAnimation(Theme.of(context).colorScheme.error),
|
||||
),
|
||||
Text("Deleting"),
|
||||
Icon(IconsaxOutline.trash)
|
||||
].addPadding(EdgeInsets.symmetric(horizontal: 16)),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
17
lib/screens/syncing/widgets/sync_progress_builder.dart
Normal file
17
lib/screens/syncing/widgets/sync_progress_builder.dart
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import 'package:fladder/models/syncing/download_stream.dart';
|
||||
import 'package:fladder/models/syncing/sync_item.dart';
|
||||
import 'package:fladder/providers/sync/sync_provider_helpers.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class SyncProgressBuilder extends ConsumerWidget {
|
||||
final SyncedItem item;
|
||||
final Widget Function(BuildContext context, DownloadStream? combinedStream) builder;
|
||||
const SyncProgressBuilder({required this.item, required this.builder, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final syncStatus = ref.watch(syncDownloadStatusProvider(item));
|
||||
return builder(context, syncStatus);
|
||||
}
|
||||
}
|
||||
122
lib/screens/syncing/widgets/synced_episode_item.dart
Normal file
122
lib/screens/syncing/widgets/synced_episode_item.dart
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
import 'package:ficonsax/ficonsax.dart';
|
||||
import 'package:fladder/models/items/episode_model.dart';
|
||||
import 'package:fladder/models/syncing/sync_item.dart';
|
||||
import 'package:fladder/providers/sync/sync_provider_helpers.dart';
|
||||
import 'package:fladder/providers/sync_provider.dart';
|
||||
import 'package:fladder/screens/shared/default_alert_dialog.dart';
|
||||
import 'package:fladder/screens/shared/media/episode_posters.dart';
|
||||
import 'package:fladder/screens/syncing/sync_widgets.dart';
|
||||
import 'package:fladder/util/list_padding.dart';
|
||||
import 'package:fladder/util/localization_helper.dart';
|
||||
import 'package:fladder/util/size_formatting.dart';
|
||||
import 'package:fladder/widgets/shared/icon_button_await.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class SyncedEpisodeItem extends ConsumerStatefulWidget {
|
||||
const SyncedEpisodeItem({
|
||||
super.key,
|
||||
required this.episode,
|
||||
required this.syncedItem,
|
||||
required this.hasFile,
|
||||
});
|
||||
|
||||
final EpisodeModel episode;
|
||||
final SyncedItem syncedItem;
|
||||
final bool hasFile;
|
||||
|
||||
@override
|
||||
ConsumerState<SyncedEpisodeItem> createState() => _SyncedEpisodeItemState();
|
||||
}
|
||||
|
||||
class _SyncedEpisodeItemState extends ConsumerState<SyncedEpisodeItem> {
|
||||
late SyncedItem syncedItem = widget.syncedItem;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final downloadTask = ref.watch(downloadTasksProvider(syncedItem.id));
|
||||
final hasFile = widget.syncedItem.videoFile.existsSync();
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
IgnorePointer(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.3),
|
||||
child: SizedBox(
|
||||
width: 250,
|
||||
child: EpisodePoster(
|
||||
episode: widget.episode,
|
||||
syncedItem: syncedItem,
|
||||
actions: [],
|
||||
showLabel: false,
|
||||
isCurrentEpisode: false,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.episode.name,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
Opacity(
|
||||
opacity: 0.75,
|
||||
child: Text(
|
||||
widget.episode.seasonEpisodeLabel(context),
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!widget.hasFile && downloadTask.hasDownload)
|
||||
Flexible(
|
||||
child: SyncProgressBar(item: syncedItem, task: downloadTask),
|
||||
)
|
||||
else
|
||||
Flexible(
|
||||
child: SyncLabel(
|
||||
label: context.localized.totalSize(ref.watch(syncSizeProvider(syncedItem)).byteFormat ?? '--'),
|
||||
status: ref.watch(syncStatusesProvider(syncedItem)).value ?? SyncStatus.partially,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
if (!hasFile && !downloadTask.hasDownload)
|
||||
IconButtonAwait(
|
||||
onPressed: () async => await ref.read(syncProvider.notifier).syncVideoFile(syncedItem, false),
|
||||
icon: Icon(IconsaxOutline.cloud_change),
|
||||
)
|
||||
else if (hasFile)
|
||||
IconButtonAwait(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
onPressed: () async {
|
||||
await showDefaultAlertDialog(
|
||||
context,
|
||||
context.localized.syncRemoveDataTitle,
|
||||
context.localized.syncRemoveDataDesc,
|
||||
(context) async {
|
||||
await ref.read(syncProvider.notifier).deleteFullSyncFiles(syncedItem);
|
||||
Navigator.pop(context);
|
||||
},
|
||||
context.localized.delete,
|
||||
(context) => Navigator.pop(context),
|
||||
context.localized.cancel,
|
||||
);
|
||||
},
|
||||
icon: Icon(IconsaxOutline.trash),
|
||||
)
|
||||
].addInBetween(const SizedBox(width: 16)),
|
||||
);
|
||||
}
|
||||
}
|
||||
95
lib/screens/syncing/widgets/synced_season_poster.dart
Normal file
95
lib/screens/syncing/widgets/synced_season_poster.dart
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
import 'package:fladder/models/items/episode_model.dart';
|
||||
import 'package:fladder/models/items/season_model.dart';
|
||||
import 'package:fladder/models/syncing/sync_item.dart';
|
||||
import 'package:fladder/providers/sync_provider.dart';
|
||||
import 'package:fladder/screens/shared/animated_fade_size.dart';
|
||||
import 'package:fladder/screens/syncing/widgets/synced_episode_item.dart';
|
||||
import 'package:fladder/util/fladder_image.dart';
|
||||
import 'package:fladder/util/list_padding.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class SyncedSeasonPoster extends ConsumerStatefulWidget {
|
||||
const SyncedSeasonPoster({
|
||||
super.key,
|
||||
required this.syncedItem,
|
||||
required this.season,
|
||||
});
|
||||
|
||||
final SyncedItem syncedItem;
|
||||
final SeasonModel season;
|
||||
|
||||
@override
|
||||
ConsumerState<SyncedSeasonPoster> createState() => _SyncedSeasonPosterState();
|
||||
}
|
||||
|
||||
class _SyncedSeasonPosterState extends ConsumerState<SyncedSeasonPoster> {
|
||||
bool expanded = false;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final season = widget.season;
|
||||
final children = ref.read(syncProvider.notifier).getChildren(widget.syncedItem);
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 125,
|
||||
child: AspectRatio(
|
||||
aspectRatio: 0.65,
|
||||
child: Card(
|
||||
child: FladderImage(
|
||||
image: season.getPosters?.primary ??
|
||||
season.parentImages?.backDrop?.firstOrNull ??
|
||||
season.parentImages?.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
season.name,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
)
|
||||
],
|
||||
),
|
||||
Spacer(),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
expanded = !expanded;
|
||||
});
|
||||
},
|
||||
icon: Icon(!expanded ? Icons.keyboard_arrow_down_rounded : Icons.keyboard_arrow_up_rounded),
|
||||
)
|
||||
].addPadding(EdgeInsets.symmetric(horizontal: 6)),
|
||||
),
|
||||
AnimatedFadeSize(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
child: expanded && children.isNotEmpty
|
||||
? ListView(
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
children: <Widget>[
|
||||
Divider(),
|
||||
...children.map(
|
||||
(item) {
|
||||
final baseItem = ref.read(syncProvider.notifier).getItem(item);
|
||||
return IntrinsicHeight(
|
||||
child: SyncedEpisodeItem(
|
||||
episode: baseItem as EpisodeModel,
|
||||
syncedItem: item,
|
||||
hasFile: item.videoFile.existsSync(),
|
||||
),
|
||||
);
|
||||
},
|
||||
)
|
||||
].addPadding(EdgeInsets.symmetric(vertical: 10)),
|
||||
)
|
||||
: Container(),
|
||||
)
|
||||
].addPadding(EdgeInsets.only(top: 10, bottom: expanded ? 10 : 0)),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue