mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-08 23:18:16 -07:00
chore: Lots of bug fixes and navigation improvements
This commit is contained in:
parent
9bb5e81812
commit
92d5391b93
35 changed files with 513 additions and 455 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:iconsax_plus/iconsax_plus.dart';
|
||||
|
|
@ -5,6 +7,7 @@ import 'package:iconsax_plus/iconsax_plus.dart';
|
|||
import 'package:fladder/jellyfin/jellyfin_open_api.enums.swagger.dart';
|
||||
import 'package:fladder/jellyfin/jellyfin_open_api.swagger.dart';
|
||||
import 'package:fladder/models/item_base_model.dart';
|
||||
import 'package:fladder/models/library_filter_model.dart';
|
||||
|
||||
extension CollectionTypeExtension on CollectionType {
|
||||
IconData get iconOutlined {
|
||||
|
|
@ -30,11 +33,6 @@ extension CollectionTypeExtension on CollectionType {
|
|||
}
|
||||
}
|
||||
|
||||
bool get searchRecursive => switch (this) {
|
||||
CollectionType.homevideos || CollectionType.photos => false,
|
||||
_ => true,
|
||||
};
|
||||
|
||||
IconData getIconType(bool outlined) {
|
||||
switch (this) {
|
||||
case CollectionType.music:
|
||||
|
|
@ -58,6 +56,16 @@ extension CollectionTypeExtension on CollectionType {
|
|||
}
|
||||
}
|
||||
|
||||
LibraryFilterModel get defaultFilters {
|
||||
log(name);
|
||||
return switch (this) {
|
||||
CollectionType.homevideos || CollectionType.photos => const LibraryFilterModel(recursive: false),
|
||||
_ => const LibraryFilterModel(
|
||||
recursive: true,
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
double? get aspectRatio => switch (this) {
|
||||
CollectionType.music ||
|
||||
CollectionType.homevideos ||
|
||||
|
|
|
|||
|
|
@ -22,12 +22,14 @@ import 'package:fladder/models/items/season_model.dart';
|
|||
import 'package:fladder/models/items/series_model.dart';
|
||||
import 'package:fladder/models/library_search/library_search_options.dart';
|
||||
import 'package:fladder/models/playlist_model.dart';
|
||||
import 'package:fladder/providers/api_provider.dart';
|
||||
import 'package:fladder/routes/auto_router.gr.dart';
|
||||
import 'package:fladder/screens/details_screens/book_detail_screen.dart';
|
||||
import 'package:fladder/screens/details_screens/details_screens.dart';
|
||||
import 'package:fladder/screens/details_screens/episode_detail_screen.dart';
|
||||
import 'package:fladder/screens/details_screens/season_detail_screen.dart';
|
||||
import 'package:fladder/screens/library_search/library_search_screen.dart';
|
||||
import 'package:fladder/screens/photo_viewer/photo_viewer_screen.dart';
|
||||
import 'package:fladder/util/localization_helper.dart';
|
||||
import 'package:fladder/util/string_extensions.dart';
|
||||
|
||||
|
|
@ -140,15 +142,14 @@ class ItemBaseModel with ItemBaseModelMappable {
|
|||
case SeasonModel _:
|
||||
return SeasonDetailScreen(item: this);
|
||||
case FolderModel _:
|
||||
case PhotoAlbumModel _:
|
||||
case BoxSetModel _:
|
||||
case PlaylistModel _:
|
||||
case PhotoAlbumModel _:
|
||||
return LibrarySearchScreen(folderId: [id]);
|
||||
case PhotoModel _:
|
||||
final photo = this as PhotoModel;
|
||||
return LibrarySearchScreen(
|
||||
folderId: [photo.albumId ?? photo.parentId ?? ""],
|
||||
photoToView: photo,
|
||||
return PhotoViewerScreen(
|
||||
items: [photo],
|
||||
);
|
||||
case BookModel book:
|
||||
return BookDetailScreen(item: book);
|
||||
|
|
@ -163,7 +164,37 @@ class ItemBaseModel with ItemBaseModelMappable {
|
|||
}
|
||||
}
|
||||
|
||||
Future<void> navigateTo(BuildContext context) async => context.router.push(DetailsRoute(id: id, item: this));
|
||||
Future<void> navigateTo(BuildContext context, {WidgetRef? ref}) async {
|
||||
switch (this) {
|
||||
case FolderModel _:
|
||||
case BoxSetModel _:
|
||||
case PlaylistModel _:
|
||||
context.router.push(LibrarySearchRoute(folderId: [id], recursive: true));
|
||||
break;
|
||||
case PhotoAlbumModel _:
|
||||
context.router.push(LibrarySearchRoute(folderId: [id], recursive: false));
|
||||
break;
|
||||
case PhotoModel _:
|
||||
final photo = this as PhotoModel;
|
||||
context.router.push(
|
||||
PhotoViewerRoute(
|
||||
items: [photo],
|
||||
loadingItems: ref?.read(jellyApiProvider).itemsGetAlbumPhotos(albumId: photo.albumId),
|
||||
selected: photo.id,
|
||||
),
|
||||
);
|
||||
break;
|
||||
case BookModel _:
|
||||
case MovieModel _:
|
||||
case EpisodeModel _:
|
||||
case SeriesModel _:
|
||||
case SeasonModel _:
|
||||
case PersonModel _:
|
||||
default:
|
||||
context.router.push(DetailsRoute(id: id, item: this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
factory ItemBaseModel.fromBaseDto(dto.BaseItemDto item, Ref ref) {
|
||||
return switch (item.type) {
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ abstract class LibraryFilterModel with _$LibraryFilterModel {
|
|||
Map<FladderItemType, bool> types,
|
||||
@Default(SortingOptions.sortName) SortingOptions sortingOption,
|
||||
@Default(SortingOrder.ascending) SortingOrder sortOrder,
|
||||
@Default(false) bool favourites,
|
||||
@Default(false) bool? favourites,
|
||||
@Default(true) bool hideEmptyShows,
|
||||
@Default(true) bool recursive,
|
||||
@Default(true) bool? recursive,
|
||||
@Default(GroupBy.none) GroupBy groupBy,
|
||||
}) = _LibraryFilterModel;
|
||||
|
||||
|
|
@ -64,8 +64,8 @@ abstract class LibraryFilterModel with _$LibraryFilterModel {
|
|||
officialRatings.hasEnabled ||
|
||||
hideEmptyShows ||
|
||||
itemFilters.hasEnabled ||
|
||||
!recursive ||
|
||||
favourites;
|
||||
recursive == false ||
|
||||
favourites == true;
|
||||
}
|
||||
|
||||
LibraryFilterModel loadModel(LibraryFilterModel model) {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ mixin _$LibraryFilterModel implements DiagnosticableTreeMixin {
|
|||
Map<FladderItemType, bool> get types;
|
||||
SortingOptions get sortingOption;
|
||||
SortingOrder get sortOrder;
|
||||
bool get favourites;
|
||||
bool? get favourites;
|
||||
bool get hideEmptyShows;
|
||||
bool get recursive;
|
||||
bool? get recursive;
|
||||
GroupBy get groupBy;
|
||||
|
||||
/// Create a copy of LibraryFilterModel
|
||||
|
|
@ -81,9 +81,9 @@ abstract mixin class $LibraryFilterModelCopyWith<$Res> {
|
|||
Map<FladderItemType, bool> types,
|
||||
SortingOptions sortingOption,
|
||||
SortingOrder sortOrder,
|
||||
bool favourites,
|
||||
bool? favourites,
|
||||
bool hideEmptyShows,
|
||||
bool recursive,
|
||||
bool? recursive,
|
||||
GroupBy groupBy});
|
||||
}
|
||||
|
||||
|
|
@ -109,9 +109,9 @@ class _$LibraryFilterModelCopyWithImpl<$Res>
|
|||
Object? types = null,
|
||||
Object? sortingOption = null,
|
||||
Object? sortOrder = null,
|
||||
Object? favourites = null,
|
||||
Object? favourites = freezed,
|
||||
Object? hideEmptyShows = null,
|
||||
Object? recursive = null,
|
||||
Object? recursive = freezed,
|
||||
Object? groupBy = null,
|
||||
}) {
|
||||
return _then(_self.copyWith(
|
||||
|
|
@ -151,18 +151,18 @@ class _$LibraryFilterModelCopyWithImpl<$Res>
|
|||
? _self.sortOrder
|
||||
: sortOrder // ignore: cast_nullable_to_non_nullable
|
||||
as SortingOrder,
|
||||
favourites: null == favourites
|
||||
favourites: freezed == favourites
|
||||
? _self.favourites
|
||||
: favourites // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
as bool?,
|
||||
hideEmptyShows: null == hideEmptyShows
|
||||
? _self.hideEmptyShows
|
||||
: hideEmptyShows // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
recursive: null == recursive
|
||||
recursive: freezed == recursive
|
||||
? _self.recursive
|
||||
: recursive // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
as bool?,
|
||||
groupBy: null == groupBy
|
||||
? _self.groupBy
|
||||
: groupBy // ignore: cast_nullable_to_non_nullable
|
||||
|
|
@ -274,9 +274,9 @@ extension LibraryFilterModelPatterns on LibraryFilterModel {
|
|||
Map<FladderItemType, bool> types,
|
||||
SortingOptions sortingOption,
|
||||
SortingOrder sortOrder,
|
||||
bool favourites,
|
||||
bool? favourites,
|
||||
bool hideEmptyShows,
|
||||
bool recursive,
|
||||
bool? recursive,
|
||||
GroupBy groupBy)?
|
||||
$default, {
|
||||
required TResult orElse(),
|
||||
|
|
@ -328,9 +328,9 @@ extension LibraryFilterModelPatterns on LibraryFilterModel {
|
|||
Map<FladderItemType, bool> types,
|
||||
SortingOptions sortingOption,
|
||||
SortingOrder sortOrder,
|
||||
bool favourites,
|
||||
bool? favourites,
|
||||
bool hideEmptyShows,
|
||||
bool recursive,
|
||||
bool? recursive,
|
||||
GroupBy groupBy)
|
||||
$default,
|
||||
) {
|
||||
|
|
@ -380,9 +380,9 @@ extension LibraryFilterModelPatterns on LibraryFilterModel {
|
|||
Map<FladderItemType, bool> types,
|
||||
SortingOptions sortingOption,
|
||||
SortingOrder sortOrder,
|
||||
bool favourites,
|
||||
bool? favourites,
|
||||
bool hideEmptyShows,
|
||||
bool recursive,
|
||||
bool? recursive,
|
||||
GroupBy groupBy)?
|
||||
$default,
|
||||
) {
|
||||
|
|
@ -529,13 +529,13 @@ class _LibraryFilterModel extends LibraryFilterModel
|
|||
final SortingOrder sortOrder;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool favourites;
|
||||
final bool? favourites;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool hideEmptyShows;
|
||||
@override
|
||||
@JsonKey()
|
||||
final bool recursive;
|
||||
final bool? recursive;
|
||||
@override
|
||||
@JsonKey()
|
||||
final GroupBy groupBy;
|
||||
|
|
@ -598,9 +598,9 @@ abstract mixin class _$LibraryFilterModelCopyWith<$Res>
|
|||
Map<FladderItemType, bool> types,
|
||||
SortingOptions sortingOption,
|
||||
SortingOrder sortOrder,
|
||||
bool favourites,
|
||||
bool? favourites,
|
||||
bool hideEmptyShows,
|
||||
bool recursive,
|
||||
bool? recursive,
|
||||
GroupBy groupBy});
|
||||
}
|
||||
|
||||
|
|
@ -626,9 +626,9 @@ class __$LibraryFilterModelCopyWithImpl<$Res>
|
|||
Object? types = null,
|
||||
Object? sortingOption = null,
|
||||
Object? sortOrder = null,
|
||||
Object? favourites = null,
|
||||
Object? favourites = freezed,
|
||||
Object? hideEmptyShows = null,
|
||||
Object? recursive = null,
|
||||
Object? recursive = freezed,
|
||||
Object? groupBy = null,
|
||||
}) {
|
||||
return _then(_LibraryFilterModel(
|
||||
|
|
@ -668,18 +668,18 @@ class __$LibraryFilterModelCopyWithImpl<$Res>
|
|||
? _self.sortOrder
|
||||
: sortOrder // ignore: cast_nullable_to_non_nullable
|
||||
as SortingOrder,
|
||||
favourites: null == favourites
|
||||
favourites: freezed == favourites
|
||||
? _self.favourites
|
||||
: favourites // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
as bool?,
|
||||
hideEmptyShows: null == hideEmptyShows
|
||||
? _self.hideEmptyShows
|
||||
: hideEmptyShows // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
recursive: null == recursive
|
||||
recursive: freezed == recursive
|
||||
? _self.recursive
|
||||
: recursive // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
as bool?,
|
||||
groupBy: null == groupBy
|
||||
? _self.groupBy
|
||||
: groupBy // ignore: cast_nullable_to_non_nullable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue