mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-17 03:06:39 -07:00
feature: Improved sync capability
This commit is contained in:
parent
f3e920ac79
commit
c5c7f71b84
31 changed files with 500 additions and 344 deletions
|
|
@ -1,13 +1,17 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:iconsax_plus/iconsax_plus.dart';
|
||||
|
||||
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/shared/flat_button.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';
|
||||
import 'package:fladder/widgets/shared/icon_button_await.dart';
|
||||
|
||||
class SyncedSeasonPoster extends ConsumerStatefulWidget {
|
||||
const SyncedSeasonPoster({
|
||||
|
|
@ -29,14 +33,21 @@ class _SyncedSeasonPosterState extends ConsumerState<SyncedSeasonPoster> {
|
|||
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,
|
||||
final unSyncedChildren = children.where((child) => child.status == SyncStatus.partially).toList();
|
||||
return ExpansionTile(
|
||||
tilePadding: EdgeInsets.zero,
|
||||
title: Row(
|
||||
spacing: 6,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 75,
|
||||
child: AspectRatio(
|
||||
aspectRatio: 0.65,
|
||||
child: FlatButton(
|
||||
onTap: () {
|
||||
season.navigateTo(context);
|
||||
return context.maybePop();
|
||||
},
|
||||
child: Card(
|
||||
child: FladderImage(
|
||||
image: season.getPosters?.primary ??
|
||||
|
|
@ -46,50 +57,47 @@ class _SyncedSeasonPosterState extends ConsumerState<SyncedSeasonPoster> {
|
|||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
season.name,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
)
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
expanded = !expanded;
|
||||
});
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
season.name,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (unSyncedChildren.isNotEmpty)
|
||||
IconButtonAwait(
|
||||
onPressed: () async {
|
||||
for (var i = 0; i < unSyncedChildren.length; i++) {
|
||||
final childSyncedItem = unSyncedChildren[i];
|
||||
await ref.read(syncProvider.notifier).syncFile(childSyncedItem, false);
|
||||
}
|
||||
},
|
||||
icon: Icon(!expanded ? Icons.keyboard_arrow_down_rounded : Icons.keyboard_arrow_up_rounded),
|
||||
)
|
||||
].addPadding(const EdgeInsets.symmetric(horizontal: 6)),
|
||||
),
|
||||
AnimatedFadeSize(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
child: expanded && children.isNotEmpty
|
||||
? ListView(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
children: <Widget>[
|
||||
const 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(const EdgeInsets.symmetric(vertical: 10)),
|
||||
)
|
||||
: Container(),
|
||||
)
|
||||
].addPadding(EdgeInsets.only(top: 10, bottom: expanded ? 10 : 0)),
|
||||
icon: const Icon(IconsaxPlusLinear.cloud_change),
|
||||
),
|
||||
],
|
||||
),
|
||||
children: children.map(
|
||||
(item) {
|
||||
final baseItem = ref.read(syncProvider.notifier).getItem(item);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: IntrinsicHeight(
|
||||
child: SyncedEpisodeItem(
|
||||
episode: baseItem as EpisodeModel,
|
||||
syncedItem: item,
|
||||
hasFile: item.videoFile.existsSync(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
).toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue