Init repo

This commit is contained in:
PartyDonut 2024-09-15 14:12:28 +02:00
commit 764b6034e3
566 changed files with 212335 additions and 0 deletions

View file

@ -0,0 +1,41 @@
import 'package:background_downloader/background_downloader.dart' as dl;
class DownloadStream {
final String id;
final dl.DownloadTask? task;
final double progress;
final dl.TaskStatus status;
DownloadStream({
required this.id,
this.task,
required this.progress,
required this.status,
});
DownloadStream.empty()
: id = '',
task = null,
progress = -1,
status = dl.TaskStatus.notFound;
bool get hasDownload => progress != -1.0 && status != dl.TaskStatus.notFound && status != dl.TaskStatus.complete;
DownloadStream copyWith({
String? id,
dl.DownloadTask? task,
double? progress,
dl.TaskStatus? status,
}) {
return DownloadStream(
id: id ?? this.id,
task: task ?? this.task,
progress: progress ?? this.progress,
status: status ?? this.status,
);
}
@override
String toString() {
return 'DownloadStream(id: $id, task: $task, progress: $progress, status: $status)';
}
}

View file

@ -0,0 +1,75 @@
import 'dart:convert';
import 'package:fladder/models/syncing/sync_item.dart';
import 'package:isar/isar.dart';
part 'i_synced_item.g.dart';
// extension IsarExtensions on String? {
// int get fastHash {
// if (this == null) return 0;
// var hash = 0xcbf29ce484222325;
// var i = 0;
// while (i < this!.length) {
// final codeUnit = this!.codeUnitAt(i++);
// hash ^= codeUnit >> 8;
// hash *= 0x100000001b3;
// hash ^= codeUnit & 0xFF;
// hash *= 0x100000001b3;
// }
// return hash;
// }
// }
@collection
class ISyncedItem {
String? userId;
String id;
int? sortKey;
String? parentId;
String? path;
int? fileSize;
String? videoFileName;
String? trickPlayModel;
String? introOutroSkipModel;
String? images;
List<String>? chapters;
List<String>? subtitles;
String? userData;
ISyncedItem({
this.userId,
required this.id,
this.sortKey,
this.parentId,
this.path,
this.fileSize,
this.videoFileName,
this.trickPlayModel,
this.introOutroSkipModel,
this.images,
this.chapters,
this.subtitles,
this.userData,
});
factory ISyncedItem.fromSynced(SyncedItem syncedItem, String? path) {
return ISyncedItem(
id: syncedItem.id,
parentId: syncedItem.parentId,
userId: syncedItem.userId,
path: syncedItem.path?.replaceAll(path ?? "", '').substring(1),
fileSize: syncedItem.fileSize,
sortKey: syncedItem.sortKey,
videoFileName: syncedItem.videoFileName,
trickPlayModel: syncedItem.fTrickPlayModel != null ? jsonEncode(syncedItem.fTrickPlayModel?.toJson()) : null,
introOutroSkipModel:
syncedItem.introOutSkipModel != null ? jsonEncode(syncedItem.introOutSkipModel?.toJson()) : null,
images: syncedItem.fImages != null ? jsonEncode(syncedItem.fImages?.toJson()) : null,
chapters: syncedItem.fChapters.map((e) => jsonEncode(e.toJson())).toList(),
subtitles: syncedItem.subtitles.map((e) => jsonEncode(e.toJson())).toList(),
userData: syncedItem.userData != null ? jsonEncode(syncedItem.userData?.toJson()) : null,
);
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,197 @@
import 'dart:convert';
import 'dart:io';
import 'package:background_downloader/background_downloader.dart';
import 'package:ficonsax/ficonsax.dart';
import 'package:fladder/jellyfin/jellyfin_open_api.swagger.dart';
import 'package:fladder/models/item_base_model.dart';
import 'package:fladder/models/items/chapters_model.dart';
import 'package:fladder/models/items/images_models.dart';
import 'package:fladder/models/items/intro_skip_model.dart';
import 'package:fladder/models/items/item_shared_models.dart';
import 'package:fladder/models/items/media_streams_model.dart';
import 'package:fladder/models/items/trick_play_model.dart';
import 'package:fladder/models/syncing/i_synced_item.dart';
import 'package:fladder/providers/sync/sync_provider_helpers.dart';
import 'package:fladder/providers/sync_provider.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:path/path.dart';
part 'sync_item.freezed.dart';
part 'sync_item.g.dart';
@freezed
class SyncedItem with _$SyncedItem {
const SyncedItem._();
factory SyncedItem({
required String id,
String? parentId,
required String userId,
String? path,
@Default(false) bool markedForDelete,
int? sortKey,
int? fileSize,
String? videoFileName,
IntroOutSkipModel? introOutSkipModel,
TrickPlayModel? fTrickPlayModel,
ImagesData? fImages,
@Default([]) List<Chapter> fChapters,
@Default([]) List<SubStreamModel> subtitles,
@UserDataJsonSerializer() UserData? userData,
}) = _SyncItem;
static String trickPlayPath = "TrickPlay";
List<Chapter> get chapters => fChapters.map((e) => e.copyWith(imageUrl: joinAll({"$path", e.imageUrl}))).toList();
ImagesData? get images => fImages?.copyWith(
primary: () => fImages?.primary?.copyWith(path: joinAll(["$path", "${fImages?.primary?.path}"])),
logo: () => fImages?.logo?.copyWith(path: joinAll(["$path", "${fImages?.logo?.path}"])),
backDrop: () => fImages?.backDrop?.map((e) => e.copyWith(path: joinAll(["$path", (e.path)]))).toList(),
);
TrickPlayModel? get trickPlayModel => fTrickPlayModel?.copyWith(
images: fTrickPlayModel?.images
.map(
(trickPlayPath) => joinAll(["$path", trickPlayPath]),
)
.toList() ??
[]);
File get dataFile => File(joinAll(["$path", "data.json"]));
Directory get trickPlayDirectory => Directory(joinAll(["$path", trickPlayPath]));
File get videoFile => File(joinAll(["$path", "$videoFileName"]));
Directory get directory => Directory(path ?? "");
SyncStatus get status => switch (videoFile.existsSync()) {
true => SyncStatus.complete,
_ => SyncStatus.partially,
};
String? get taskId => null;
bool get childHasTask => false;
double get totalProgress => 0.0;
bool get hasVideoFile => videoFileName?.isNotEmpty == true && (fileSize ?? 0) > 0;
TaskStatus get anyStatus {
return TaskStatus.notFound;
}
double get downloadProgress => 0.0;
TaskStatus get downloadStatus => TaskStatus.notFound;
DownloadTask? get task => null;
Future<bool> deleteDatFiles(Ref ref) async {
try {
await videoFile.delete();
await Directory(joinAll([directory.path, trickPlayPath])).delete(recursive: true);
} catch (e) {
return false;
}
return true;
}
List<SyncedItem> nestedChildren(WidgetRef ref) => ref.watch(syncChildrenProvider(this));
List<SyncedItem> getChildren(Ref ref) => ref.read(syncProvider.notifier).getChildren(this);
List<SyncedItem> getNestedChildren(Ref ref) => ref.read(syncProvider.notifier).getNestedChildren(this);
Future<int> get getDirSize async {
var files = await directory.list(recursive: true).toList();
var dirSize = files.fold(0, (int sum, file) => sum + file.statSync().size);
return dirSize;
}
ItemBaseModel? createItemModel(Ref ref) {
if (!dataFile.existsSync()) return null;
final BaseItemDto itemDto = BaseItemDto.fromJson(jsonDecode(dataFile.readAsStringSync()));
final itemModel = ItemBaseModel.fromBaseDto(itemDto, ref);
return itemModel.copyWith(
images: images,
userData: userData,
);
}
factory SyncedItem.fromJson(Map<String, dynamic> json) => _$SyncedItemFromJson(json);
factory SyncedItem.fromIsar(ISyncedItem isarSyncedItem, String savePath) {
return SyncedItem(
id: isarSyncedItem.id,
parentId: isarSyncedItem.parentId,
userId: isarSyncedItem.userId ?? "",
sortKey: isarSyncedItem.sortKey,
path: joinAll([savePath, isarSyncedItem.path ?? ""]),
fileSize: isarSyncedItem.fileSize,
videoFileName: isarSyncedItem.videoFileName,
introOutSkipModel: isarSyncedItem.introOutroSkipModel != null
? IntroOutSkipModel.fromJson(jsonDecode(isarSyncedItem.introOutroSkipModel!))
: null,
fTrickPlayModel: isarSyncedItem.trickPlayModel != null
? TrickPlayModel.fromJson(jsonDecode(isarSyncedItem.trickPlayModel!))
: null,
fImages: isarSyncedItem.images != null ? ImagesData.fromJson(jsonDecode(isarSyncedItem.images!)) : null,
fChapters: isarSyncedItem.chapters
?.map(
(e) => Chapter.fromJson(jsonDecode(e)),
)
.toList() ??
[],
subtitles: isarSyncedItem.subtitles
?.map(
(e) => SubStreamModel.fromJson(jsonDecode(e)),
)
.toList() ??
[],
userData: isarSyncedItem.userData != null ? UserData.fromJson(jsonDecode(isarSyncedItem.userData!)) : null,
);
}
}
enum SyncStatus {
complete(
"Synced",
Color.fromARGB(255, 141, 214, 58),
IconsaxOutline.tick_circle,
),
partially(
"Partially",
Color.fromARGB(255, 221, 135, 23),
IconsaxOutline.more_circle,
),
;
const SyncStatus(this.label, this.color, this.icon);
final Color color;
final String label;
final IconData icon;
}
extension StatusExtension on TaskStatus {
Color color(BuildContext context) => switch (this) {
TaskStatus.enqueued => Colors.blueAccent,
TaskStatus.running => Colors.limeAccent,
TaskStatus.complete => Colors.limeAccent,
TaskStatus.canceled || TaskStatus.notFound || TaskStatus.failed => Theme.of(context).colorScheme.error,
TaskStatus.waitingToRetry => Colors.yellowAccent,
TaskStatus.paused => Colors.orangeAccent,
};
String get name => switch (this) {
TaskStatus.enqueued => 'Enqueued',
TaskStatus.running => 'Running',
TaskStatus.complete => 'Complete',
TaskStatus.notFound => 'Not Found',
TaskStatus.failed => 'Failed',
TaskStatus.canceled => 'Canceled',
TaskStatus.waitingToRetry => 'Waiting To Retry',
TaskStatus.paused => 'Paused',
};
}

View file

@ -0,0 +1,494 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'sync_item.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
SyncedItem _$SyncedItemFromJson(Map<String, dynamic> json) {
return _SyncItem.fromJson(json);
}
/// @nodoc
mixin _$SyncedItem {
String get id => throw _privateConstructorUsedError;
String? get parentId => throw _privateConstructorUsedError;
String get userId => throw _privateConstructorUsedError;
String? get path => throw _privateConstructorUsedError;
bool get markedForDelete => throw _privateConstructorUsedError;
int? get sortKey => throw _privateConstructorUsedError;
int? get fileSize => throw _privateConstructorUsedError;
String? get videoFileName => throw _privateConstructorUsedError;
IntroOutSkipModel? get introOutSkipModel =>
throw _privateConstructorUsedError;
TrickPlayModel? get fTrickPlayModel => throw _privateConstructorUsedError;
ImagesData? get fImages => throw _privateConstructorUsedError;
List<Chapter> get fChapters => throw _privateConstructorUsedError;
List<SubStreamModel> get subtitles => throw _privateConstructorUsedError;
@UserDataJsonSerializer()
UserData? get userData => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SyncedItemCopyWith<SyncedItem> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SyncedItemCopyWith<$Res> {
factory $SyncedItemCopyWith(
SyncedItem value, $Res Function(SyncedItem) then) =
_$SyncedItemCopyWithImpl<$Res, SyncedItem>;
@useResult
$Res call(
{String id,
String? parentId,
String userId,
String? path,
bool markedForDelete,
int? sortKey,
int? fileSize,
String? videoFileName,
IntroOutSkipModel? introOutSkipModel,
TrickPlayModel? fTrickPlayModel,
ImagesData? fImages,
List<Chapter> fChapters,
List<SubStreamModel> subtitles,
@UserDataJsonSerializer() UserData? userData});
$IntroOutSkipModelCopyWith<$Res>? get introOutSkipModel;
$TrickPlayModelCopyWith<$Res>? get fTrickPlayModel;
}
/// @nodoc
class _$SyncedItemCopyWithImpl<$Res, $Val extends SyncedItem>
implements $SyncedItemCopyWith<$Res> {
_$SyncedItemCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? parentId = freezed,
Object? userId = null,
Object? path = freezed,
Object? markedForDelete = null,
Object? sortKey = freezed,
Object? fileSize = freezed,
Object? videoFileName = freezed,
Object? introOutSkipModel = freezed,
Object? fTrickPlayModel = freezed,
Object? fImages = freezed,
Object? fChapters = null,
Object? subtitles = null,
Object? userData = freezed,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
parentId: freezed == parentId
? _value.parentId
: parentId // ignore: cast_nullable_to_non_nullable
as String?,
userId: null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
path: freezed == path
? _value.path
: path // ignore: cast_nullable_to_non_nullable
as String?,
markedForDelete: null == markedForDelete
? _value.markedForDelete
: markedForDelete // ignore: cast_nullable_to_non_nullable
as bool,
sortKey: freezed == sortKey
? _value.sortKey
: sortKey // ignore: cast_nullable_to_non_nullable
as int?,
fileSize: freezed == fileSize
? _value.fileSize
: fileSize // ignore: cast_nullable_to_non_nullable
as int?,
videoFileName: freezed == videoFileName
? _value.videoFileName
: videoFileName // ignore: cast_nullable_to_non_nullable
as String?,
introOutSkipModel: freezed == introOutSkipModel
? _value.introOutSkipModel
: introOutSkipModel // ignore: cast_nullable_to_non_nullable
as IntroOutSkipModel?,
fTrickPlayModel: freezed == fTrickPlayModel
? _value.fTrickPlayModel
: fTrickPlayModel // ignore: cast_nullable_to_non_nullable
as TrickPlayModel?,
fImages: freezed == fImages
? _value.fImages
: fImages // ignore: cast_nullable_to_non_nullable
as ImagesData?,
fChapters: null == fChapters
? _value.fChapters
: fChapters // ignore: cast_nullable_to_non_nullable
as List<Chapter>,
subtitles: null == subtitles
? _value.subtitles
: subtitles // ignore: cast_nullable_to_non_nullable
as List<SubStreamModel>,
userData: freezed == userData
? _value.userData
: userData // ignore: cast_nullable_to_non_nullable
as UserData?,
) as $Val);
}
@override
@pragma('vm:prefer-inline')
$IntroOutSkipModelCopyWith<$Res>? get introOutSkipModel {
if (_value.introOutSkipModel == null) {
return null;
}
return $IntroOutSkipModelCopyWith<$Res>(_value.introOutSkipModel!, (value) {
return _then(_value.copyWith(introOutSkipModel: value) as $Val);
});
}
@override
@pragma('vm:prefer-inline')
$TrickPlayModelCopyWith<$Res>? get fTrickPlayModel {
if (_value.fTrickPlayModel == null) {
return null;
}
return $TrickPlayModelCopyWith<$Res>(_value.fTrickPlayModel!, (value) {
return _then(_value.copyWith(fTrickPlayModel: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$SyncItemImplCopyWith<$Res>
implements $SyncedItemCopyWith<$Res> {
factory _$$SyncItemImplCopyWith(
_$SyncItemImpl value, $Res Function(_$SyncItemImpl) then) =
__$$SyncItemImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String id,
String? parentId,
String userId,
String? path,
bool markedForDelete,
int? sortKey,
int? fileSize,
String? videoFileName,
IntroOutSkipModel? introOutSkipModel,
TrickPlayModel? fTrickPlayModel,
ImagesData? fImages,
List<Chapter> fChapters,
List<SubStreamModel> subtitles,
@UserDataJsonSerializer() UserData? userData});
@override
$IntroOutSkipModelCopyWith<$Res>? get introOutSkipModel;
@override
$TrickPlayModelCopyWith<$Res>? get fTrickPlayModel;
}
/// @nodoc
class __$$SyncItemImplCopyWithImpl<$Res>
extends _$SyncedItemCopyWithImpl<$Res, _$SyncItemImpl>
implements _$$SyncItemImplCopyWith<$Res> {
__$$SyncItemImplCopyWithImpl(
_$SyncItemImpl _value, $Res Function(_$SyncItemImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? parentId = freezed,
Object? userId = null,
Object? path = freezed,
Object? markedForDelete = null,
Object? sortKey = freezed,
Object? fileSize = freezed,
Object? videoFileName = freezed,
Object? introOutSkipModel = freezed,
Object? fTrickPlayModel = freezed,
Object? fImages = freezed,
Object? fChapters = null,
Object? subtitles = null,
Object? userData = freezed,
}) {
return _then(_$SyncItemImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
parentId: freezed == parentId
? _value.parentId
: parentId // ignore: cast_nullable_to_non_nullable
as String?,
userId: null == userId
? _value.userId
: userId // ignore: cast_nullable_to_non_nullable
as String,
path: freezed == path
? _value.path
: path // ignore: cast_nullable_to_non_nullable
as String?,
markedForDelete: null == markedForDelete
? _value.markedForDelete
: markedForDelete // ignore: cast_nullable_to_non_nullable
as bool,
sortKey: freezed == sortKey
? _value.sortKey
: sortKey // ignore: cast_nullable_to_non_nullable
as int?,
fileSize: freezed == fileSize
? _value.fileSize
: fileSize // ignore: cast_nullable_to_non_nullable
as int?,
videoFileName: freezed == videoFileName
? _value.videoFileName
: videoFileName // ignore: cast_nullable_to_non_nullable
as String?,
introOutSkipModel: freezed == introOutSkipModel
? _value.introOutSkipModel
: introOutSkipModel // ignore: cast_nullable_to_non_nullable
as IntroOutSkipModel?,
fTrickPlayModel: freezed == fTrickPlayModel
? _value.fTrickPlayModel
: fTrickPlayModel // ignore: cast_nullable_to_non_nullable
as TrickPlayModel?,
fImages: freezed == fImages
? _value.fImages
: fImages // ignore: cast_nullable_to_non_nullable
as ImagesData?,
fChapters: null == fChapters
? _value._fChapters
: fChapters // ignore: cast_nullable_to_non_nullable
as List<Chapter>,
subtitles: null == subtitles
? _value._subtitles
: subtitles // ignore: cast_nullable_to_non_nullable
as List<SubStreamModel>,
userData: freezed == userData
? _value.userData
: userData // ignore: cast_nullable_to_non_nullable
as UserData?,
));
}
}
/// @nodoc
@JsonSerializable()
class _$SyncItemImpl extends _SyncItem {
_$SyncItemImpl(
{required this.id,
this.parentId,
required this.userId,
this.path,
this.markedForDelete = false,
this.sortKey,
this.fileSize,
this.videoFileName,
this.introOutSkipModel,
this.fTrickPlayModel,
this.fImages,
final List<Chapter> fChapters = const [],
final List<SubStreamModel> subtitles = const [],
@UserDataJsonSerializer() this.userData})
: _fChapters = fChapters,
_subtitles = subtitles,
super._();
factory _$SyncItemImpl.fromJson(Map<String, dynamic> json) =>
_$$SyncItemImplFromJson(json);
@override
final String id;
@override
final String? parentId;
@override
final String userId;
@override
final String? path;
@override
@JsonKey()
final bool markedForDelete;
@override
final int? sortKey;
@override
final int? fileSize;
@override
final String? videoFileName;
@override
final IntroOutSkipModel? introOutSkipModel;
@override
final TrickPlayModel? fTrickPlayModel;
@override
final ImagesData? fImages;
final List<Chapter> _fChapters;
@override
@JsonKey()
List<Chapter> get fChapters {
if (_fChapters is EqualUnmodifiableListView) return _fChapters;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_fChapters);
}
final List<SubStreamModel> _subtitles;
@override
@JsonKey()
List<SubStreamModel> get subtitles {
if (_subtitles is EqualUnmodifiableListView) return _subtitles;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_subtitles);
}
@override
@UserDataJsonSerializer()
final UserData? userData;
@override
String toString() {
return 'SyncedItem(id: $id, parentId: $parentId, userId: $userId, path: $path, markedForDelete: $markedForDelete, sortKey: $sortKey, fileSize: $fileSize, videoFileName: $videoFileName, introOutSkipModel: $introOutSkipModel, fTrickPlayModel: $fTrickPlayModel, fImages: $fImages, fChapters: $fChapters, subtitles: $subtitles, userData: $userData)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SyncItemImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.parentId, parentId) ||
other.parentId == parentId) &&
(identical(other.userId, userId) || other.userId == userId) &&
(identical(other.path, path) || other.path == path) &&
(identical(other.markedForDelete, markedForDelete) ||
other.markedForDelete == markedForDelete) &&
(identical(other.sortKey, sortKey) || other.sortKey == sortKey) &&
(identical(other.fileSize, fileSize) ||
other.fileSize == fileSize) &&
(identical(other.videoFileName, videoFileName) ||
other.videoFileName == videoFileName) &&
(identical(other.introOutSkipModel, introOutSkipModel) ||
other.introOutSkipModel == introOutSkipModel) &&
(identical(other.fTrickPlayModel, fTrickPlayModel) ||
other.fTrickPlayModel == fTrickPlayModel) &&
(identical(other.fImages, fImages) || other.fImages == fImages) &&
const DeepCollectionEquality()
.equals(other._fChapters, _fChapters) &&
const DeepCollectionEquality()
.equals(other._subtitles, _subtitles) &&
(identical(other.userData, userData) ||
other.userData == userData));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(
runtimeType,
id,
parentId,
userId,
path,
markedForDelete,
sortKey,
fileSize,
videoFileName,
introOutSkipModel,
fTrickPlayModel,
fImages,
const DeepCollectionEquality().hash(_fChapters),
const DeepCollectionEquality().hash(_subtitles),
userData);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$SyncItemImplCopyWith<_$SyncItemImpl> get copyWith =>
__$$SyncItemImplCopyWithImpl<_$SyncItemImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$SyncItemImplToJson(
this,
);
}
}
abstract class _SyncItem extends SyncedItem {
factory _SyncItem(
{required final String id,
final String? parentId,
required final String userId,
final String? path,
final bool markedForDelete,
final int? sortKey,
final int? fileSize,
final String? videoFileName,
final IntroOutSkipModel? introOutSkipModel,
final TrickPlayModel? fTrickPlayModel,
final ImagesData? fImages,
final List<Chapter> fChapters,
final List<SubStreamModel> subtitles,
@UserDataJsonSerializer() final UserData? userData}) = _$SyncItemImpl;
_SyncItem._() : super._();
factory _SyncItem.fromJson(Map<String, dynamic> json) =
_$SyncItemImpl.fromJson;
@override
String get id;
@override
String? get parentId;
@override
String get userId;
@override
String? get path;
@override
bool get markedForDelete;
@override
int? get sortKey;
@override
int? get fileSize;
@override
String? get videoFileName;
@override
IntroOutSkipModel? get introOutSkipModel;
@override
TrickPlayModel? get fTrickPlayModel;
@override
ImagesData? get fImages;
@override
List<Chapter> get fChapters;
@override
List<SubStreamModel> get subtitles;
@override
@UserDataJsonSerializer()
UserData? get userData;
@override
@JsonKey(ignore: true)
_$$SyncItemImplCopyWith<_$SyncItemImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View file

@ -0,0 +1,71 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'sync_item.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$SyncItemImpl _$$SyncItemImplFromJson(Map<String, dynamic> json) =>
_$SyncItemImpl(
id: json['id'] as String,
parentId: json['parentId'] as String?,
userId: json['userId'] as String,
path: json['path'] as String?,
markedForDelete: json['markedForDelete'] as bool? ?? false,
sortKey: (json['sortKey'] as num?)?.toInt(),
fileSize: (json['fileSize'] as num?)?.toInt(),
videoFileName: json['videoFileName'] as String?,
introOutSkipModel: json['introOutSkipModel'] == null
? null
: IntroOutSkipModel.fromJson(
json['introOutSkipModel'] as Map<String, dynamic>),
fTrickPlayModel: json['fTrickPlayModel'] == null
? null
: TrickPlayModel.fromJson(
json['fTrickPlayModel'] as Map<String, dynamic>),
fImages: json['fImages'] == null
? null
: ImagesData.fromJson(json['fImages'] as String),
fChapters: (json['fChapters'] as List<dynamic>?)
?.map((e) => Chapter.fromJson(e as String))
.toList() ??
const [],
subtitles: (json['subtitles'] as List<dynamic>?)
?.map((e) => SubStreamModel.fromJson(e as String))
.toList() ??
const [],
userData: _$JsonConverterFromJson<String, UserData>(
json['userData'], const UserDataJsonSerializer().fromJson),
);
Map<String, dynamic> _$$SyncItemImplToJson(_$SyncItemImpl instance) =>
<String, dynamic>{
'id': instance.id,
'parentId': instance.parentId,
'userId': instance.userId,
'path': instance.path,
'markedForDelete': instance.markedForDelete,
'sortKey': instance.sortKey,
'fileSize': instance.fileSize,
'videoFileName': instance.videoFileName,
'introOutSkipModel': instance.introOutSkipModel,
'fTrickPlayModel': instance.fTrickPlayModel,
'fImages': instance.fImages,
'fChapters': instance.fChapters,
'subtitles': instance.subtitles,
'userData': _$JsonConverterToJson<String, UserData>(
instance.userData, const UserDataJsonSerializer().toJson),
};
Value? _$JsonConverterFromJson<Json, Value>(
Object? json,
Value? Function(Json json) fromJson,
) =>
json == null ? null : fromJson(json as Json);
Json? _$JsonConverterToJson<Json, Value>(
Value? value,
Json? Function(Value value) toJson,
) =>
value == null ? null : toJson(value);

View file

@ -0,0 +1,16 @@
// ignore_for_file: invalid_annotation_target
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:fladder/models/syncing/sync_item.dart';
part 'sync_settings_model.freezed.dart';
@Freezed(toJson: false, fromJson: false)
class SyncSettingsModel with _$SyncSettingsModel {
const SyncSettingsModel._();
factory SyncSettingsModel({
@Default([]) List<SyncedItem> items,
}) = _SyncSettignsModel;
}

View file

@ -0,0 +1,144 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'sync_settings_model.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
/// @nodoc
mixin _$SyncSettingsModel {
List<SyncedItem> get items => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SyncSettingsModelCopyWith<SyncSettingsModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SyncSettingsModelCopyWith<$Res> {
factory $SyncSettingsModelCopyWith(
SyncSettingsModel value, $Res Function(SyncSettingsModel) then) =
_$SyncSettingsModelCopyWithImpl<$Res, SyncSettingsModel>;
@useResult
$Res call({List<SyncedItem> items});
}
/// @nodoc
class _$SyncSettingsModelCopyWithImpl<$Res, $Val extends SyncSettingsModel>
implements $SyncSettingsModelCopyWith<$Res> {
_$SyncSettingsModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? items = null,
}) {
return _then(_value.copyWith(
items: null == items
? _value.items
: items // ignore: cast_nullable_to_non_nullable
as List<SyncedItem>,
) as $Val);
}
}
/// @nodoc
abstract class _$$SyncSettignsModelImplCopyWith<$Res>
implements $SyncSettingsModelCopyWith<$Res> {
factory _$$SyncSettignsModelImplCopyWith(_$SyncSettignsModelImpl value,
$Res Function(_$SyncSettignsModelImpl) then) =
__$$SyncSettignsModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({List<SyncedItem> items});
}
/// @nodoc
class __$$SyncSettignsModelImplCopyWithImpl<$Res>
extends _$SyncSettingsModelCopyWithImpl<$Res, _$SyncSettignsModelImpl>
implements _$$SyncSettignsModelImplCopyWith<$Res> {
__$$SyncSettignsModelImplCopyWithImpl(_$SyncSettignsModelImpl _value,
$Res Function(_$SyncSettignsModelImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? items = null,
}) {
return _then(_$SyncSettignsModelImpl(
items: null == items
? _value._items
: items // ignore: cast_nullable_to_non_nullable
as List<SyncedItem>,
));
}
}
/// @nodoc
class _$SyncSettignsModelImpl extends _SyncSettignsModel {
_$SyncSettignsModelImpl({final List<SyncedItem> items = const []})
: _items = items,
super._();
final List<SyncedItem> _items;
@override
@JsonKey()
List<SyncedItem> get items {
if (_items is EqualUnmodifiableListView) return _items;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_items);
}
@override
String toString() {
return 'SyncSettingsModel(items: $items)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$SyncSettignsModelImpl &&
const DeepCollectionEquality().equals(other._items, _items));
}
@override
int get hashCode =>
Object.hash(runtimeType, const DeepCollectionEquality().hash(_items));
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$SyncSettignsModelImplCopyWith<_$SyncSettignsModelImpl> get copyWith =>
__$$SyncSettignsModelImplCopyWithImpl<_$SyncSettignsModelImpl>(
this, _$identity);
}
abstract class _SyncSettignsModel extends SyncSettingsModel {
factory _SyncSettignsModel({final List<SyncedItem> items}) =
_$SyncSettignsModelImpl;
_SyncSettignsModel._() : super._();
@override
List<SyncedItem> get items;
@override
@JsonKey(ignore: true)
_$$SyncSettignsModelImplCopyWith<_$SyncSettignsModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}