mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-14 17:55:58 -07:00
[Bugfix] Video player options
[Translation] Add translations for ends at
This commit is contained in:
parent
ae1446ddbb
commit
47771a0728
10 changed files with 175 additions and 160 deletions
|
|
@ -1,5 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:ficonsax/ficonsax.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:fladder/models/item_base_model.dart';
|
||||
import 'package:fladder/models/items/episode_model.dart';
|
||||
import 'package:fladder/models/playback/direct_playback_model.dart';
|
||||
|
|
@ -20,15 +24,14 @@ import 'package:fladder/util/string_extensions.dart';
|
|||
import 'package:fladder/widgets/shared/enum_selection.dart';
|
||||
import 'package:fladder/widgets/shared/modal_bottom_sheet.dart';
|
||||
import 'package:fladder/widgets/shared/spaced_list_tile.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
Future<void> showVideoPlayerOptions(BuildContext context) {
|
||||
Future<void> showVideoPlayerOptions(BuildContext context, Function() minimizePlayer) {
|
||||
return showBottomSheetPill(
|
||||
context: context,
|
||||
content: (context, scrollController) {
|
||||
return VideoOptions(
|
||||
controller: scrollController,
|
||||
minimizePlayer: minimizePlayer,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
@ -36,7 +39,8 @@ Future<void> showVideoPlayerOptions(BuildContext context) {
|
|||
|
||||
class VideoOptions extends ConsumerStatefulWidget {
|
||||
final ScrollController controller;
|
||||
const VideoOptions({required this.controller, super.key});
|
||||
final Function() minimizePlayer;
|
||||
const VideoOptions({required this.controller, required this.minimizePlayer, super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<ConsumerStatefulWidget> createState() => _VideoOptionsMobileState();
|
||||
|
|
@ -67,16 +71,10 @@ class _VideoOptionsMobileState extends ConsumerState<VideoOptions> {
|
|||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (currentItem?.title.isNotEmpty == true)
|
||||
Text(
|
||||
currentItem?.title ?? "",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
if (currentItem?.detailedName(context)?.isNotEmpty == true)
|
||||
Text(
|
||||
currentItem?.detailedName(context) ?? "",
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
)
|
||||
Text(
|
||||
currentItem?.title ?? "",
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
|
|
@ -173,86 +171,6 @@ class _VideoOptionsMobileState extends ConsumerState<VideoOptions> {
|
|||
],
|
||||
),
|
||||
),
|
||||
// ListTile(
|
||||
// title: const Text("Playback settings"),
|
||||
// onTap: () => setState(() => page = 1),
|
||||
// ),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget itemOptions() {
|
||||
final currentItem = ref.watch(playBackModel.select((value) => value?.item));
|
||||
return ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
navTitle("${currentItem?.title} \n${currentItem?.detailedName}"),
|
||||
if (currentItem != null) ...{
|
||||
if (currentItem.type == FladderItemType.episode)
|
||||
ListTile(
|
||||
onTap: () {
|
||||
//Pop twice once for sheet once for player
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
(this as EpisodeModel).parentBaseModel.navigateTo(context);
|
||||
},
|
||||
title: const Text("Open show"),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
//Pop twice once for sheet once for player
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
await currentItem.navigateTo(context);
|
||||
},
|
||||
title: const Text("Show details"),
|
||||
),
|
||||
if (currentItem.type != FladderItemType.boxset)
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
await addItemToCollection(context, [currentItem]);
|
||||
if (context.mounted) {
|
||||
context.refreshData();
|
||||
}
|
||||
},
|
||||
title: const Text("Add to collection"),
|
||||
),
|
||||
if (currentItem.type != FladderItemType.playlist)
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
await addItemToPlaylist(context, [currentItem]);
|
||||
if (context.mounted) {
|
||||
context.refreshData();
|
||||
}
|
||||
},
|
||||
title: const Text("Add to playlist"),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
final favourite = !(currentItem.userData.isFavourite == true);
|
||||
ref.read(userProvider.notifier).setAsFavorite(favourite, currentItem.id);
|
||||
final newUserData = currentItem.userData;
|
||||
final playbackModel = switch (ref.read(playBackModel)) {
|
||||
DirectPlaybackModel value => value.copyWith(item: currentItem.copyWith(userData: newUserData)),
|
||||
TranscodePlaybackModel value => value.copyWith(item: currentItem.copyWith(userData: newUserData)),
|
||||
OfflinePlaybackModel value => value.copyWith(item: currentItem.copyWith(userData: newUserData)),
|
||||
_ => null
|
||||
};
|
||||
if (playbackModel != null) {
|
||||
ref.read(playBackModel.notifier).update((state) => playbackModel);
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
title: Text(currentItem.userData.isFavourite == true ? "Remove from favorites" : "Add to favourites"),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showInfoScreen(context, currentItem);
|
||||
},
|
||||
title: const Text('Media info'),
|
||||
),
|
||||
}
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
@ -264,7 +182,7 @@ class _VideoOptionsMobileState extends ConsumerState<VideoOptions> {
|
|||
shrinkWrap: true,
|
||||
controller: widget.controller,
|
||||
children: [
|
||||
navTitle("Playback Settings"),
|
||||
navTitle("Playback Settings", null),
|
||||
if (playbackState?.queue.isNotEmpty == true)
|
||||
ListTile(
|
||||
leading: const Icon(Icons.video_collection_rounded),
|
||||
|
|
@ -294,7 +212,7 @@ class _VideoOptionsMobileState extends ConsumerState<VideoOptions> {
|
|||
duration: const Duration(milliseconds: 250),
|
||||
child: switch (page) {
|
||||
1 => playbackSettings(),
|
||||
2 => itemOptions(),
|
||||
2 => itemInfo(currentItem, context),
|
||||
_ => mainPage(),
|
||||
},
|
||||
),
|
||||
|
|
@ -304,7 +222,79 @@ class _VideoOptionsMobileState extends ConsumerState<VideoOptions> {
|
|||
);
|
||||
}
|
||||
|
||||
Widget navTitle(String title) {
|
||||
ListView itemInfo(ItemBaseModel? currentItem, BuildContext context) {
|
||||
return ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
navTitle(currentItem?.title, currentItem?.subTextShort(context)),
|
||||
if (currentItem != null) ...{
|
||||
if (currentItem.type == FladderItemType.episode)
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
widget.minimizePlayer();
|
||||
(this as EpisodeModel).parentBaseModel.navigateTo(context);
|
||||
},
|
||||
title: const Text("Open show"),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
Navigator.of(context).pop();
|
||||
widget.minimizePlayer();
|
||||
await currentItem.navigateTo(context);
|
||||
},
|
||||
title: const Text("Show details"),
|
||||
),
|
||||
if (currentItem.type != FladderItemType.boxset)
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
await addItemToCollection(context, [currentItem]);
|
||||
if (context.mounted) {
|
||||
context.refreshData();
|
||||
}
|
||||
},
|
||||
title: const Text("Add to collection"),
|
||||
),
|
||||
if (currentItem.type != FladderItemType.playlist)
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
await addItemToPlaylist(context, [currentItem]);
|
||||
if (context.mounted) {
|
||||
context.refreshData();
|
||||
}
|
||||
},
|
||||
title: const Text("Add to playlist"),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () async {
|
||||
final response = await ref
|
||||
.read(userProvider.notifier)
|
||||
.setAsFavorite(!(currentItem.userData.isFavourite == true), currentItem.id);
|
||||
final newItem = currentItem.copyWith(userData: response?.body);
|
||||
final playbackModel = switch (ref.read(playBackModel)) {
|
||||
DirectPlaybackModel value => value.copyWith(item: newItem),
|
||||
TranscodePlaybackModel value => value.copyWith(item: newItem),
|
||||
OfflinePlaybackModel value => value.copyWith(item: newItem),
|
||||
_ => null
|
||||
};
|
||||
ref.read(playBackModel.notifier).update((state) => playbackModel);
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
title: Text(currentItem.userData.isFavourite == true ? "Remove from favorites" : "Add to favourites"),
|
||||
),
|
||||
ListTile(
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
showInfoScreen(context, currentItem);
|
||||
},
|
||||
title: const Text('Media info'),
|
||||
),
|
||||
}
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget navTitle(String? title, String? subText) {
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
|
|
@ -314,10 +304,20 @@ class _VideoOptionsMobileState extends ConsumerState<VideoOptions> {
|
|||
onPressed: () => setState(() => page = 0),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
)
|
||||
Column(
|
||||
children: [
|
||||
if (title != null)
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
if (subText != null)
|
||||
Text(
|
||||
subText,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import 'package:fladder/screens/video_player/components/video_volume_slider.dart
|
|||
import 'package:fladder/util/adaptive_layout.dart';
|
||||
import 'package:fladder/util/duration_extensions.dart';
|
||||
import 'package:fladder/util/list_padding.dart';
|
||||
import 'package:fladder/util/localization_helper.dart';
|
||||
import 'package:fladder/util/string_extensions.dart';
|
||||
|
||||
class DesktopControls extends ConsumerStatefulWidget {
|
||||
|
|
@ -48,29 +49,6 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
late final double topPadding = MediaQuery.of(context).viewPadding.top;
|
||||
late final double bottomPadding = MediaQuery.of(context).viewPadding.bottom;
|
||||
|
||||
Future<void> clear() async {
|
||||
toggleOverlay(value: true);
|
||||
if (!AdaptiveLayout.of(context).isDesktop) {
|
||||
ScreenBrightness().resetScreenBrightness();
|
||||
} else {
|
||||
disableFullscreen();
|
||||
}
|
||||
|
||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: ref.read(clientSettingsProvider.select((value) => value.statusBarBrightness(context))),
|
||||
));
|
||||
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
void resetTimer() => timer.reset();
|
||||
|
||||
Future<void> closePlayer() async {
|
||||
clear();
|
||||
ref.read(videoPlayerProvider).stop();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mediaPlayback = ref.watch(mediaPlaybackProvider);
|
||||
|
|
@ -252,13 +230,7 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
clear();
|
||||
ref
|
||||
.read(mediaPlaybackProvider.notifier)
|
||||
.update((state) => state.copyWith(state: VideoPlayerState.minimized));
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
onPressed: () => minimizePlayer(context),
|
||||
icon: const Icon(
|
||||
IconsaxOutline.arrow_down_1,
|
||||
size: 24,
|
||||
|
|
@ -312,7 +284,8 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
child: Row(
|
||||
children: <Widget>[
|
||||
IconButton(
|
||||
onPressed: () => showVideoPlayerOptions(context), icon: const Icon(IconsaxOutline.more)),
|
||||
onPressed: () => showVideoPlayerOptions(context, () => minimizePlayer(context)),
|
||||
icon: const Icon(IconsaxOutline.more)),
|
||||
if (AdaptiveLayout.layoutOf(context) == LayoutState.tablet) ...[
|
||||
IconButton(
|
||||
onPressed: () => showSubSelection(context),
|
||||
|
|
@ -432,7 +405,7 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
final List<String?> details = [
|
||||
if (AdaptiveLayout.of(context).isDesktop) item?.label(context),
|
||||
mediaPlayback.duration.inMinutes > 1
|
||||
? 'ends at ${DateFormat('HH:mm').format(DateTime.now().add(mediaPlayback.duration - mediaPlayback.position))}'
|
||||
? context.localized.endsAt(DateTime.now().add(mediaPlayback.duration - mediaPlayback.position))
|
||||
: null
|
||||
];
|
||||
return Column(
|
||||
|
|
@ -627,6 +600,35 @@ class _DesktopControlsState extends ConsumerState<DesktopControls> {
|
|||
));
|
||||
}
|
||||
|
||||
void minimizePlayer(BuildContext context) {
|
||||
clearOverlaySettings();
|
||||
ref.read(mediaPlaybackProvider.notifier).update((state) => state.copyWith(state: VideoPlayerState.minimized));
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
Future<void> clearOverlaySettings() async {
|
||||
toggleOverlay(value: true);
|
||||
if (!AdaptiveLayout.of(context).isDesktop) {
|
||||
ScreenBrightness().resetScreenBrightness();
|
||||
} else {
|
||||
disableFullscreen();
|
||||
}
|
||||
|
||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: ref.read(clientSettingsProvider.select((value) => value.statusBarBrightness(context))),
|
||||
));
|
||||
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
void resetTimer() => timer.reset();
|
||||
|
||||
Future<void> closePlayer() async {
|
||||
clearOverlaySettings();
|
||||
ref.read(videoPlayerProvider).stop();
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
|
||||
Future<void> disableFullscreen() async {
|
||||
resetTimer();
|
||||
final isFullScreen = await windowManager.isFullScreen();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue