mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-09 23:48:14 -07:00
feat: UI 2.0 and other Improvements (#357)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
9ca06eaa37
commit
e7b5bb40ff
169 changed files with 4584 additions and 3626 deletions
|
|
@ -1,20 +1,66 @@
|
|||
// ignore_for_file: public_member_api_docs, sort_constructors_first
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:fladder/jellyfin/jellyfin_open_api.swagger.dart';
|
||||
import 'package:fladder/models/item_base_model.dart';
|
||||
import 'package:fladder/util/localization_helper.dart';
|
||||
|
||||
sealed class NameSwitch {
|
||||
const NameSwitch();
|
||||
|
||||
String label(BuildContext context);
|
||||
}
|
||||
|
||||
class NextUp extends NameSwitch {
|
||||
const NextUp();
|
||||
|
||||
@override
|
||||
String label(BuildContext context) => context.localized.nextUp;
|
||||
}
|
||||
|
||||
class Latest extends NameSwitch {
|
||||
const Latest();
|
||||
|
||||
@override
|
||||
String label(BuildContext context) => context.localized.latest;
|
||||
}
|
||||
|
||||
class Other extends NameSwitch {
|
||||
final String customLabel;
|
||||
|
||||
const Other(this.customLabel);
|
||||
|
||||
@override
|
||||
String label(BuildContext context) => customLabel;
|
||||
}
|
||||
|
||||
extension RecommendationTypeExtenstion on RecommendationType {
|
||||
String label(BuildContext context) => switch (this) {
|
||||
RecommendationType.similartorecentlyplayed => context.localized.similarToRecentlyPlayed,
|
||||
RecommendationType.similartolikeditem => context.localized.similarToLikedItem,
|
||||
RecommendationType.hasdirectorfromrecentlyplayed => context.localized.hasDirectorFromRecentlyPlayed,
|
||||
RecommendationType.hasactorfromrecentlyplayed => context.localized.hasActorFromRecentlyPlayed,
|
||||
RecommendationType.haslikeddirector => context.localized.hasLikedDirector,
|
||||
RecommendationType.haslikedactor => context.localized.hasLikedActor,
|
||||
_ => "",
|
||||
};
|
||||
}
|
||||
|
||||
class RecommendedModel {
|
||||
final String name;
|
||||
final NameSwitch name;
|
||||
final List<ItemBaseModel> posters;
|
||||
final String type;
|
||||
final RecommendationType? type;
|
||||
RecommendedModel({
|
||||
required this.name,
|
||||
required this.posters,
|
||||
required this.type,
|
||||
this.type,
|
||||
});
|
||||
|
||||
RecommendedModel copyWith({
|
||||
String? name,
|
||||
NameSwitch? name,
|
||||
List<ItemBaseModel>? posters,
|
||||
String? type,
|
||||
RecommendationType? type,
|
||||
}) {
|
||||
return RecommendedModel(
|
||||
name: name ?? this.name,
|
||||
|
|
@ -22,4 +68,12 @@ class RecommendedModel {
|
|||
type: type ?? this.type,
|
||||
);
|
||||
}
|
||||
|
||||
factory RecommendedModel.fromBaseDto(RecommendationDto e, Ref ref) {
|
||||
return RecommendedModel(
|
||||
name: Other(e.baselineItemName ?? ""),
|
||||
posters: e.items?.map((e) => ItemBaseModel.fromBaseDto(e, ref)).toList() ?? [],
|
||||
type: e.recommendationType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue