refactor: extract shared mixins and helpers, drop dead abstractions
Introduces shared seams for paginated views, D-pad reorder, media control routing, async singletons and the device method channel, then points the open-coded copies at them. Also removes unused models and duplicated provider/server plumbing, folds the twice-implemented artifact store in the server, and factors the repeated Flutter toolchain prologue in CI into a composite action.
This commit is contained in:
@@ -5,7 +5,6 @@ import '../media/media_kind.dart';
|
||||
import '../media/media_server_client.dart';
|
||||
import '../services/jellyfin_client.dart';
|
||||
import '../utils/jellyfin_time.dart';
|
||||
import '../utils/media_image_helper.dart';
|
||||
import 'metadata_edit_models.dart';
|
||||
|
||||
class JellyfinMetadataEditAdapter extends MetadataEditAdapter {
|
||||
@@ -39,7 +38,11 @@ class JellyfinMetadataEditAdapter extends MetadataEditAdapter {
|
||||
List<MetadataEditSection> buildSchema(MetadataEditDraft draft) {
|
||||
final kind = draft.sourceItem.kind;
|
||||
return [
|
||||
MetadataEditSection(id: 'basic', title: t.metadataEdit.basicInfo, fields: _basicFields(kind)),
|
||||
MetadataEditSection(
|
||||
id: 'basic',
|
||||
title: t.metadataEdit.basicInfo,
|
||||
fields: metadataBasicFields(kind, studioType: MetadataEditFieldType.stringList),
|
||||
),
|
||||
if (_tagFields(kind).isNotEmpty)
|
||||
MetadataEditSection(id: 'tags', title: t.metadataEdit.tags, fields: _tagFields(kind)),
|
||||
MetadataEditSection(id: 'artwork', title: t.metadataEdit.artwork, fields: _artworkFields(kind)),
|
||||
@@ -53,11 +56,11 @@ class JellyfinMetadataEditAdapter extends MetadataEditAdapter {
|
||||
final dto = Map<String, dynamic>.from(raw);
|
||||
|
||||
dto['ProviderIds'] = _stringMap(dto['ProviderIds']);
|
||||
dto['Tags'] = _stringList(dto['Tags']);
|
||||
dto['Genres'] = _stringList(dto['Genres']);
|
||||
dto['Tags'] = metadataStringList(dto['Tags']);
|
||||
dto['Genres'] = metadataStringList(dto['Genres']);
|
||||
dto['People'] = _mapList(dto['People']);
|
||||
dto['Studios'] = _mapList(dto['Studios']);
|
||||
dto['LockedFields'] = _stringList(dto['LockedFields']);
|
||||
dto['LockedFields'] = metadataStringList(dto['LockedFields']);
|
||||
dto['LockData'] = dto['LockData'] == true;
|
||||
dto.remove('Trickplay');
|
||||
|
||||
@@ -71,29 +74,29 @@ class JellyfinMetadataEditAdapter extends MetadataEditAdapter {
|
||||
final value = draft.value<String>('originallyAvailableAt') ?? '';
|
||||
dto['PremiereDate'] = _jellyfinDate(value, raw['PremiereDate']);
|
||||
}
|
||||
if (_fieldChanged(draft, 'studio')) {
|
||||
if (_listFieldChanged(draft, 'studio')) {
|
||||
dto['Studios'] = _replaceNamePairs(_mapList(dto['Studios']), metadataStringList(draft.values['studio']));
|
||||
}
|
||||
if (draft.fieldChanged('tagline')) {
|
||||
final tagline = metadataEmptyToNull(draft.value<String>('tagline'));
|
||||
final existing = _stringList(dto['Taglines']);
|
||||
final existing = metadataStringList(dto['Taglines']);
|
||||
dto['Taglines'] = tagline == null ? <String>[] : <String>[tagline, ...existing.skip(1)];
|
||||
}
|
||||
if (_fieldChanged(draft, 'genre')) dto['Genres'] = metadataStringList(draft.values['genre']);
|
||||
if (_fieldChanged(draft, 'country')) dto['ProductionLocations'] = metadataStringList(draft.values['country']);
|
||||
if (_fieldChanged(draft, 'label')) dto['Tags'] = metadataStringList(draft.values['label']);
|
||||
if (_listFieldChanged(draft, 'genre')) dto['Genres'] = metadataStringList(draft.values['genre']);
|
||||
if (_listFieldChanged(draft, 'country')) dto['ProductionLocations'] = metadataStringList(draft.values['country']);
|
||||
if (_listFieldChanged(draft, 'label')) dto['Tags'] = metadataStringList(draft.values['label']);
|
||||
|
||||
var peopleChanged = false;
|
||||
var people = _mapList(dto['People']);
|
||||
if (_fieldChanged(draft, 'director')) {
|
||||
if (_listFieldChanged(draft, 'director')) {
|
||||
people = _replacePeopleByType(people, 'Director', metadataStringList(draft.values['director']));
|
||||
peopleChanged = true;
|
||||
}
|
||||
if (_fieldChanged(draft, 'writer')) {
|
||||
if (_listFieldChanged(draft, 'writer')) {
|
||||
people = _replacePeopleByType(people, 'Writer', metadataStringList(draft.values['writer']));
|
||||
peopleChanged = true;
|
||||
}
|
||||
if (_fieldChanged(draft, 'producer')) {
|
||||
if (_listFieldChanged(draft, 'producer')) {
|
||||
people = _replacePeopleByType(people, 'Producer', metadataStringList(draft.values['producer']));
|
||||
peopleChanged = true;
|
||||
}
|
||||
@@ -132,11 +135,6 @@ class JellyfinMetadataEditAdapter extends MetadataEditAdapter {
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> applyArtworkOption(MetadataEditDraft draft, MetadataEditField field, MetadataArtworkOption option) {
|
||||
return applyArtworkFromUrl(draft, field, option.sourceUrl);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> applyArtworkFromUrl(MetadataEditDraft draft, MetadataEditField field, String url) async {
|
||||
final imageType = field.artwork?.key;
|
||||
@@ -180,12 +178,12 @@ class JellyfinMetadataEditAdapter extends MetadataEditAdapter {
|
||||
? metadataFirstString(raw['Taglines'])
|
||||
: item.tagline ?? '';
|
||||
values['summary'] = raw['Overview'] as String? ?? item.summary ?? '';
|
||||
values['genre'] = _stringList(raw['Genres']);
|
||||
values['genre'] = metadataStringList(raw['Genres']);
|
||||
values['director'] = _peopleByType(raw['People'], 'Director');
|
||||
values['writer'] = _peopleByType(raw['People'], 'Writer');
|
||||
values['producer'] = _peopleByType(raw['People'], 'Producer');
|
||||
values['country'] = _stringList(raw['ProductionLocations']);
|
||||
values['label'] = _stringList(raw['Tags']);
|
||||
values['country'] = metadataStringList(raw['ProductionLocations']);
|
||||
values['label'] = metadataStringList(raw['Tags']);
|
||||
}
|
||||
|
||||
void _writeArtworkValues(Map<String, Object?> values, MediaItem item) {
|
||||
@@ -194,29 +192,6 @@ class JellyfinMetadataEditAdapter extends MetadataEditAdapter {
|
||||
values['artwork:Logo'] = item.clearLogoPath;
|
||||
}
|
||||
|
||||
List<MetadataEditField> _basicFields(MediaKind kind) {
|
||||
return [
|
||||
MetadataEditField(id: 'title', label: t.metadataEdit.title, type: MetadataEditFieldType.text),
|
||||
if (kind != MediaKind.season)
|
||||
MetadataEditField(id: 'titleSort', label: t.metadataEdit.sortTitle, type: MetadataEditFieldType.text),
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show)
|
||||
MetadataEditField(id: 'originalTitle', label: t.metadataEdit.originalTitle, type: MetadataEditFieldType.text),
|
||||
if (kind != MediaKind.season)
|
||||
MetadataEditField(
|
||||
id: 'originallyAvailableAt',
|
||||
label: t.metadataEdit.releaseDate,
|
||||
type: MetadataEditFieldType.date,
|
||||
),
|
||||
if (kind != MediaKind.season)
|
||||
MetadataEditField(id: 'contentRating', label: t.metadataEdit.contentRating, type: MetadataEditFieldType.text),
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show)
|
||||
MetadataEditField(id: 'studio', label: t.metadataEdit.studio, type: MetadataEditFieldType.stringList),
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show)
|
||||
MetadataEditField(id: 'tagline', label: t.metadataEdit.tagline, type: MetadataEditFieldType.text),
|
||||
MetadataEditField(id: 'summary', label: t.metadataEdit.summary, type: MetadataEditFieldType.multilineText),
|
||||
];
|
||||
}
|
||||
|
||||
List<MetadataEditField> _tagFields(MediaKind kind) {
|
||||
MetadataEditField tag(String id, String label) =>
|
||||
MetadataEditField(id: id, label: label, type: MetadataEditFieldType.stringList);
|
||||
@@ -234,100 +209,20 @@ class JellyfinMetadataEditAdapter extends MetadataEditAdapter {
|
||||
};
|
||||
}
|
||||
|
||||
List<MetadataEditField> _artworkFields(MediaKind kind) {
|
||||
final fields = <MetadataEditField>[
|
||||
// Episode "posters" are 16:9 thumbnails, not 2:3 poster art.
|
||||
kind == MediaKind.episode
|
||||
? _artworkField(
|
||||
'Primary',
|
||||
t.metadataEdit.poster,
|
||||
t.metadataEdit.selectPoster,
|
||||
80,
|
||||
45,
|
||||
2,
|
||||
16 / 9,
|
||||
imageType: ImageType.thumb,
|
||||
)
|
||||
: _artworkField('Primary', t.metadataEdit.poster, t.metadataEdit.selectPoster, 40, 60, 3, 2 / 3),
|
||||
];
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show || kind == MediaKind.episode) {
|
||||
fields.add(
|
||||
_artworkField(
|
||||
'Backdrop',
|
||||
t.metadataEdit.background,
|
||||
t.metadataEdit.selectBackground,
|
||||
80,
|
||||
45,
|
||||
2,
|
||||
16 / 9,
|
||||
imageType: ImageType.art,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show) {
|
||||
fields.add(
|
||||
_artworkField(
|
||||
'Logo',
|
||||
t.metadataEdit.logo,
|
||||
t.metadataEdit.selectLogo,
|
||||
80,
|
||||
32,
|
||||
2,
|
||||
2.5,
|
||||
fit: MetadataArtworkFit.contain,
|
||||
imageType: ImageType.logo,
|
||||
),
|
||||
);
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
MetadataEditField _artworkField(
|
||||
String key,
|
||||
String label,
|
||||
String title,
|
||||
double width,
|
||||
double height,
|
||||
int columns,
|
||||
double aspectRatio, {
|
||||
MetadataArtworkFit fit = MetadataArtworkFit.cover,
|
||||
ImageType imageType = ImageType.poster,
|
||||
}) {
|
||||
return MetadataEditField(
|
||||
id: 'artwork:$key',
|
||||
label: label,
|
||||
type: MetadataEditFieldType.artwork,
|
||||
saveMode: MetadataEditSaveMode.immediate,
|
||||
artwork: MetadataArtworkConfig(
|
||||
key: key,
|
||||
selectTitle: title,
|
||||
previewWidth: width,
|
||||
previewHeight: height,
|
||||
gridColumns: columns,
|
||||
gridAspectRatio: aspectRatio,
|
||||
fit: fit,
|
||||
imageType: imageType,
|
||||
),
|
||||
);
|
||||
}
|
||||
List<MetadataEditField> _artworkFields(MediaKind kind) =>
|
||||
metadataArtworkFields(kind, posterKey: 'Primary', backdropKey: 'Backdrop', logoKey: 'Logo');
|
||||
|
||||
void _setChangedString(Map<String, dynamic> dto, MetadataEditDraft draft, String fieldId, String dtoKey) {
|
||||
if (!draft.fieldChanged(fieldId)) return;
|
||||
dto[dtoKey] = metadataEmptyToNull(draft.value<String>(fieldId));
|
||||
}
|
||||
|
||||
bool _fieldChanged(MetadataEditDraft draft, String fieldId) {
|
||||
for (final section in schemaFor(draft)) {
|
||||
for (final field in section.fields) {
|
||||
if (field.id == fieldId) return metadataEditFieldChanged(draft, field);
|
||||
}
|
||||
}
|
||||
return draft.fieldChanged(fieldId);
|
||||
}
|
||||
/// Every id passed here names a `stringList` field, so the comparison is
|
||||
/// order-insensitive regardless of which kind's schema is in play.
|
||||
bool _listFieldChanged(MetadataEditDraft draft, String fieldId) =>
|
||||
!metadataEditStringListEquals(draft.values[fieldId], draft.originalValues[fieldId]);
|
||||
}
|
||||
|
||||
List<String> _stringList(Object? value) => metadataStringList(value);
|
||||
|
||||
Map<String, String> _stringMap(Object? value) {
|
||||
if (value is! Map) return <String, String>{};
|
||||
return value.map((key, value) => MapEntry(key.toString(), value?.toString() ?? ''));
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../i18n/strings.g.dart';
|
||||
import '../media/media_backend.dart';
|
||||
import '../media/media_item.dart';
|
||||
import '../media/media_kind.dart';
|
||||
@@ -147,7 +148,9 @@ abstract class MetadataEditAdapter {
|
||||
|
||||
Future<List<MetadataArtworkOption>> fetchArtwork(MetadataEditDraft draft, MetadataEditField field);
|
||||
|
||||
Future<bool> applyArtworkOption(MetadataEditDraft draft, MetadataEditField field, MetadataArtworkOption option);
|
||||
Future<bool> applyArtworkOption(MetadataEditDraft draft, MetadataEditField field, MetadataArtworkOption option) {
|
||||
return applyArtworkFromUrl(draft, field, option.sourceUrl);
|
||||
}
|
||||
|
||||
Future<bool> applyArtworkFromUrl(MetadataEditDraft draft, MetadataEditField field, String url);
|
||||
|
||||
@@ -160,6 +163,133 @@ abstract class MetadataEditAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
/// Basic-info fields shared by every backend; only the studio field type differs.
|
||||
List<MetadataEditField> metadataBasicFields(
|
||||
MediaKind kind, {
|
||||
MetadataEditFieldType studioType = MetadataEditFieldType.text,
|
||||
}) {
|
||||
return [
|
||||
MetadataEditField(id: 'title', label: t.metadataEdit.title, type: MetadataEditFieldType.text),
|
||||
if (kind != MediaKind.season)
|
||||
MetadataEditField(id: 'titleSort', label: t.metadataEdit.sortTitle, type: MetadataEditFieldType.text),
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show)
|
||||
MetadataEditField(id: 'originalTitle', label: t.metadataEdit.originalTitle, type: MetadataEditFieldType.text),
|
||||
if (kind != MediaKind.season)
|
||||
MetadataEditField(
|
||||
id: 'originallyAvailableAt',
|
||||
label: t.metadataEdit.releaseDate,
|
||||
type: MetadataEditFieldType.date,
|
||||
),
|
||||
if (kind != MediaKind.season)
|
||||
MetadataEditField(id: 'contentRating', label: t.metadataEdit.contentRating, type: MetadataEditFieldType.text),
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show)
|
||||
MetadataEditField(id: 'studio', label: t.metadataEdit.studio, type: studioType),
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show)
|
||||
MetadataEditField(id: 'tagline', label: t.metadataEdit.tagline, type: MetadataEditFieldType.text),
|
||||
MetadataEditField(id: 'summary', label: t.metadataEdit.summary, type: MetadataEditFieldType.multilineText),
|
||||
];
|
||||
}
|
||||
|
||||
/// Artwork fields shared by every backend; each backend supplies its own artwork
|
||||
/// key names, which kinds carry a logo, and whether square art exists.
|
||||
List<MetadataEditField> metadataArtworkFields(
|
||||
MediaKind kind, {
|
||||
required String posterKey,
|
||||
required String backdropKey,
|
||||
required String logoKey,
|
||||
String? squareKey,
|
||||
Set<MediaKind> logoKinds = const {MediaKind.movie, MediaKind.show},
|
||||
}) {
|
||||
final fields = <MetadataEditField>[
|
||||
// Episode "posters" are 16:9 thumbnails, not 2:3 poster art.
|
||||
kind == MediaKind.episode
|
||||
? metadataArtworkField(
|
||||
posterKey,
|
||||
t.metadataEdit.poster,
|
||||
t.metadataEdit.selectPoster,
|
||||
80,
|
||||
45,
|
||||
2,
|
||||
16 / 9,
|
||||
imageType: ImageType.thumb,
|
||||
)
|
||||
: metadataArtworkField(posterKey, t.metadataEdit.poster, t.metadataEdit.selectPoster, 40, 60, 3, 2 / 3),
|
||||
];
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show || kind == MediaKind.episode) {
|
||||
fields.add(
|
||||
metadataArtworkField(
|
||||
backdropKey,
|
||||
t.metadataEdit.background,
|
||||
t.metadataEdit.selectBackground,
|
||||
80,
|
||||
45,
|
||||
2,
|
||||
16 / 9,
|
||||
imageType: ImageType.art,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (logoKinds.contains(kind)) {
|
||||
fields.add(
|
||||
metadataArtworkField(
|
||||
logoKey,
|
||||
t.metadataEdit.logo,
|
||||
t.metadataEdit.selectLogo,
|
||||
80,
|
||||
32,
|
||||
2,
|
||||
2.5,
|
||||
fit: MetadataArtworkFit.contain,
|
||||
imageType: ImageType.logo,
|
||||
),
|
||||
);
|
||||
if (squareKey != null) {
|
||||
fields.add(
|
||||
metadataArtworkField(
|
||||
squareKey,
|
||||
t.metadataEdit.squareArt,
|
||||
t.metadataEdit.selectSquareArt,
|
||||
50,
|
||||
50,
|
||||
3,
|
||||
1,
|
||||
imageType: ImageType.avatar,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
MetadataEditField metadataArtworkField(
|
||||
String key,
|
||||
String label,
|
||||
String title,
|
||||
double width,
|
||||
double height,
|
||||
int columns,
|
||||
double aspectRatio, {
|
||||
MetadataArtworkFit fit = MetadataArtworkFit.cover,
|
||||
ImageType imageType = ImageType.poster,
|
||||
}) {
|
||||
return MetadataEditField(
|
||||
id: 'artwork:$key',
|
||||
label: label,
|
||||
type: MetadataEditFieldType.artwork,
|
||||
saveMode: MetadataEditSaveMode.immediate,
|
||||
artwork: MetadataArtworkConfig(
|
||||
key: key,
|
||||
selectTitle: title,
|
||||
previewWidth: width,
|
||||
previewHeight: height,
|
||||
gridColumns: columns,
|
||||
gridAspectRatio: aspectRatio,
|
||||
fit: fit,
|
||||
imageType: imageType,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
bool metadataEditValueEquals(Object? a, Object? b) {
|
||||
if (identical(a, b)) return true;
|
||||
if (a is List && b is List) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import '../media/media_server_client.dart';
|
||||
import '../services/plex_client.dart';
|
||||
import '../utils/app_logger.dart';
|
||||
import '../utils/language_codes.dart';
|
||||
import '../utils/media_image_helper.dart';
|
||||
import 'metadata_edit_models.dart';
|
||||
|
||||
class PlexMetadataEditAdapter extends MetadataEditAdapter {
|
||||
@@ -60,7 +59,7 @@ class PlexMetadataEditAdapter extends MetadataEditAdapter {
|
||||
List<MetadataEditSection> buildSchema(MetadataEditDraft draft) {
|
||||
final kind = draft.sourceItem.kind;
|
||||
return [
|
||||
MetadataEditSection(id: 'basic', title: t.metadataEdit.basicInfo, fields: _basicFields(kind)),
|
||||
MetadataEditSection(id: 'basic', title: t.metadataEdit.basicInfo, fields: metadataBasicFields(kind)),
|
||||
if (_tagFields(kind).isNotEmpty)
|
||||
MetadataEditSection(id: 'tags', title: t.metadataEdit.tags, fields: _tagFields(kind)),
|
||||
MetadataEditSection(id: 'artwork', title: t.metadataEdit.artwork, fields: _artworkFields(kind)),
|
||||
@@ -133,11 +132,6 @@ class PlexMetadataEditAdapter extends MetadataEditAdapter {
|
||||
.toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> applyArtworkOption(MetadataEditDraft draft, MetadataEditField field, MetadataArtworkOption option) {
|
||||
return applyArtworkFromUrl(draft, field, option.sourceUrl);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> applyArtworkFromUrl(MetadataEditDraft draft, MetadataEditField field, String url) async {
|
||||
final element = field.artwork?.key;
|
||||
@@ -213,29 +207,6 @@ class PlexMetadataEditAdapter extends MetadataEditAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
List<MetadataEditField> _basicFields(MediaKind kind) {
|
||||
return [
|
||||
MetadataEditField(id: 'title', label: t.metadataEdit.title, type: MetadataEditFieldType.text),
|
||||
if (kind != MediaKind.season)
|
||||
MetadataEditField(id: 'titleSort', label: t.metadataEdit.sortTitle, type: MetadataEditFieldType.text),
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show)
|
||||
MetadataEditField(id: 'originalTitle', label: t.metadataEdit.originalTitle, type: MetadataEditFieldType.text),
|
||||
if (kind != MediaKind.season)
|
||||
MetadataEditField(
|
||||
id: 'originallyAvailableAt',
|
||||
label: t.metadataEdit.releaseDate,
|
||||
type: MetadataEditFieldType.date,
|
||||
),
|
||||
if (kind != MediaKind.season)
|
||||
MetadataEditField(id: 'contentRating', label: t.metadataEdit.contentRating, type: MetadataEditFieldType.text),
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show)
|
||||
MetadataEditField(id: 'studio', label: t.metadataEdit.studio, type: MetadataEditFieldType.text),
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show)
|
||||
MetadataEditField(id: 'tagline', label: t.metadataEdit.tagline, type: MetadataEditFieldType.text),
|
||||
MetadataEditField(id: 'summary', label: t.metadataEdit.summary, type: MetadataEditFieldType.multilineText),
|
||||
];
|
||||
}
|
||||
|
||||
List<MetadataEditField> _tagFields(MediaKind kind) {
|
||||
MetadataEditField tag(String id, String label) =>
|
||||
MetadataEditField(id: id, label: label, type: MetadataEditFieldType.stringList);
|
||||
@@ -267,94 +238,14 @@ class PlexMetadataEditAdapter extends MetadataEditAdapter {
|
||||
};
|
||||
}
|
||||
|
||||
List<MetadataEditField> _artworkFields(MediaKind kind) {
|
||||
final fields = <MetadataEditField>[
|
||||
// Episode "posters" are 16:9 thumbnails, not 2:3 poster art.
|
||||
kind == MediaKind.episode
|
||||
? _artworkField(
|
||||
'posters',
|
||||
t.metadataEdit.poster,
|
||||
t.metadataEdit.selectPoster,
|
||||
80,
|
||||
45,
|
||||
2,
|
||||
16 / 9,
|
||||
imageType: ImageType.thumb,
|
||||
)
|
||||
: _artworkField('posters', t.metadataEdit.poster, t.metadataEdit.selectPoster, 40, 60, 3, 2 / 3),
|
||||
];
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show || kind == MediaKind.episode) {
|
||||
fields.add(
|
||||
_artworkField(
|
||||
'arts',
|
||||
t.metadataEdit.background,
|
||||
t.metadataEdit.selectBackground,
|
||||
80,
|
||||
45,
|
||||
2,
|
||||
16 / 9,
|
||||
imageType: ImageType.art,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (kind == MediaKind.movie || kind == MediaKind.show || kind == MediaKind.collection) {
|
||||
fields.add(
|
||||
_artworkField(
|
||||
'clearLogos',
|
||||
t.metadataEdit.logo,
|
||||
t.metadataEdit.selectLogo,
|
||||
80,
|
||||
32,
|
||||
2,
|
||||
2.5,
|
||||
fit: MetadataArtworkFit.contain,
|
||||
imageType: ImageType.logo,
|
||||
),
|
||||
);
|
||||
fields.add(
|
||||
_artworkField(
|
||||
'squareArts',
|
||||
t.metadataEdit.squareArt,
|
||||
t.metadataEdit.selectSquareArt,
|
||||
50,
|
||||
50,
|
||||
3,
|
||||
1,
|
||||
imageType: ImageType.avatar,
|
||||
),
|
||||
);
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
MetadataEditField _artworkField(
|
||||
String key,
|
||||
String label,
|
||||
String title,
|
||||
double width,
|
||||
double height,
|
||||
int columns,
|
||||
double aspectRatio, {
|
||||
MetadataArtworkFit fit = MetadataArtworkFit.cover,
|
||||
ImageType imageType = ImageType.poster,
|
||||
}) {
|
||||
return MetadataEditField(
|
||||
id: 'artwork:$key',
|
||||
label: label,
|
||||
type: MetadataEditFieldType.artwork,
|
||||
saveMode: MetadataEditSaveMode.immediate,
|
||||
artwork: MetadataArtworkConfig(
|
||||
key: key,
|
||||
selectTitle: title,
|
||||
previewWidth: width,
|
||||
previewHeight: height,
|
||||
gridColumns: columns,
|
||||
gridAspectRatio: aspectRatio,
|
||||
fit: fit,
|
||||
imageType: imageType,
|
||||
),
|
||||
);
|
||||
}
|
||||
List<MetadataEditField> _artworkFields(MediaKind kind) => metadataArtworkFields(
|
||||
kind,
|
||||
posterKey: 'posters',
|
||||
backdropKey: 'arts',
|
||||
logoKey: 'clearLogos',
|
||||
squareKey: 'squareArts',
|
||||
logoKinds: const {MediaKind.movie, MediaKind.show, MediaKind.collection},
|
||||
);
|
||||
|
||||
List<MetadataEditField> _advancedFields(MediaKind kind) {
|
||||
final fields = <MetadataEditField>[];
|
||||
|
||||
Reference in New Issue
Block a user