Skip to content

Commit f69db3c

Browse files
committed
feat: some stuff
1 parent 1541202 commit f69db3c

File tree

8 files changed

+208
-137
lines changed

8 files changed

+208
-137
lines changed

lib/Functions/Function.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Future<void> snackString(
7979
BuildContext? c,
8080
}) async {
8181
var context = c ?? navigatorKey.currentContext ?? Get.context;
82-
82+
Logger.log(s ?? '');
8383
if (context != null && s != null && s.isNotEmpty) {
8484
var theme = Theme.of(context).colorScheme;
8585
Logger.log(s);

lib/Screens/Anime/AnimeScreen.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import 'package:dantotsu/Functions/Extensions.dart';
2-
import 'package:dantotsu/Screens/Calendar/CalendarScreen.dart';
32
import 'package:dantotsu/Theme/LanguageSwitcher.dart';
43
import 'package:flutter/material.dart';
54
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
65
import 'package:provider/provider.dart';
76

87
import '../../Adaptor/Media/MediaAdaptor.dart';
98
import '../../Adaptor/Media/Widgets/Chips.dart';
10-
import '../../Adaptor/Media/Widgets/MediaCard.dart';
119
import '../../Animation/SlideInAnimation.dart';
1210
import '../../Functions/Function.dart';
1311
import '../../Services/Screens/BaseAnimeScreen.dart';

lib/Screens/Player/Player.dart

Lines changed: 113 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ class MediaPlayerState extends State<MediaPlayer>
104104
void _initializePlayer() {
105105
currentQuality = widget.videos[widget.index];
106106
videoPlayerController = WindowsPlayer(resizeMode, settings);
107-
var sourceName = context.currentService(listen: false).getName;
107+
var sourceName = context
108+
.currentService(listen: false)
109+
.getName;
108110
var currentProgress = loadCustomData<int>(
109111
"${widget.media.id}-${widget.currentEpisode.number}-$sourceName-current",
110112
);
@@ -114,7 +116,9 @@ class MediaPlayerState extends State<MediaPlayer>
114116
}
115117

116118
void _loadPlayerSettings() {
117-
settings = loadCustomData('${widget.media.id}-${context.currentService(listen: false).getName}-PlayerSettings') ?? loadData(PrefName.playerSettings);
119+
settings = loadCustomData('${widget.media.id}-${context
120+
.currentService(listen: false)
121+
.getName}-PlayerSettings') ?? loadData(PrefName.playerSettings);
118122
widget.media.anime?.playerSettings = settings;
119123
resizeMode = (resizeMap[settings.resizeMode] ?? BoxFit.contain).obs;
120124
viewType = loadSelected(widget.media).recyclerStyle.obs;
@@ -170,7 +174,7 @@ class MediaPlayerState extends State<MediaPlayer>
170174
crossAxisAlignment: CrossAxisAlignment.start,
171175
children: [
172176
Obx(
173-
() {
177+
() {
174178
return MouseRegion(
175179
onHover: (_) => _onMouseMoved(),
176180
cursor: showControls.value
@@ -182,14 +186,15 @@ class MediaPlayerState extends State<MediaPlayer>
182186
},
183187
),
184188
Obx(
185-
() {
189+
() {
186190
if (!showEpisodes.value) {
187191
return const SizedBox();
188192
}
189193
return GestureDetector(
190194
onHorizontalDragUpdate: (details) {
191195
setState(
192-
() => episodePanelWidth =
196+
() =>
197+
episodePanelWidth =
193198
(episodePanelWidth! - details.delta.dx)
194199
.clamp(minWidth, availableWidth),
195200
);
@@ -225,34 +230,31 @@ class MediaPlayerState extends State<MediaPlayer>
225230
children: [
226231
videoPlayerController.playerWidget(),
227232
_buildSubtitle(),
228-
AnimatedAlign(
229-
alignment: Alignment.topCenter,
230-
duration: const Duration(milliseconds: 300),
231-
child: Card(
232-
color: Colors.black.withOpacity(0.5),
233-
shape: RoundedRectangleBorder(
234-
borderRadius: BorderRadius.circular(16),
235-
),
236-
child: Padding(
237-
padding: const EdgeInsets.symmetric(
238-
horizontal: 8.0,
239-
vertical: 4.0,
233+
if (isLongPress.value)
234+
AnimatedAlign(
235+
alignment: Alignment.topCenter,
236+
duration: const Duration(milliseconds: 300),
237+
child: Card(
238+
color: Colors.black.withOpacity(0.5),
239+
shape: RoundedRectangleBorder(
240+
borderRadius: BorderRadius.circular(16),
240241
),
241-
child: Obx(
242-
() {
243-
return isLongPress.value ? Text(
244-
'${videoPlayerController.currentSpeed.value}x ',
245-
style: const TextStyle(
246-
color: Colors.white,
247-
fontSize: 16,
248-
fontWeight: FontWeight.bold,
249-
),
250-
) : SizedBox();
251-
},
242+
child: Padding(
243+
padding: const EdgeInsets.symmetric(
244+
horizontal: 8.0,
245+
vertical: 4.0,
246+
),
247+
child: Text(
248+
'${videoPlayerController.currentSpeed.value}x ',
249+
style: const TextStyle(
250+
color: Colors.white,
251+
fontSize: 16,
252+
fontWeight: FontWeight.bold,
253+
),
254+
),
252255
),
253256
),
254257
),
255-
),
256258
KeyboardListener(
257259
focusNode: focusNode,
258260
onKeyEvent: _handleKeyPress,
@@ -267,7 +269,10 @@ class MediaPlayerState extends State<MediaPlayer>
267269
onVerticalDragUpdate: (e) async {
268270
final delta = e.delta.dy;
269271
final Offset position = e.localPosition;
270-
if (position.dx <= MediaQuery.of(context).size.width / 2) {
272+
if (position.dx <= MediaQuery
273+
.of(context)
274+
.size
275+
.width / 2) {
271276
final brightness = _brightnessValue.value - delta / 500;
272277
final result = brightness.clamp(0.0, 1.0);
273278
setBrightness(result);
@@ -315,59 +320,62 @@ class MediaPlayerState extends State<MediaPlayer>
315320
return const SizedBox();
316321
}
317322
return Obx(
318-
() => AnimatedPositioned(
319-
right: 0,
320-
left: 0,
321-
top: 0,
322-
duration: const Duration(milliseconds: 100),
323-
bottom: showControls.value
324-
? 100
325-
: (24 + settings.subtitleBottomPadding.toDouble()),
326-
child: AnimatedContainer(
327-
alignment: Alignment.bottomCenter,
328-
duration: const Duration(milliseconds: 300),
329-
child: Column(
330-
mainAxisSize: MainAxisSize.min,
331-
crossAxisAlignment: CrossAxisAlignment.center,
332-
mainAxisAlignment: MainAxisAlignment.center,
333-
children: [
334-
Container(
335-
padding:
323+
() =>
324+
AnimatedPositioned(
325+
right: 0,
326+
left: 0,
327+
top: 0,
328+
duration: const Duration(milliseconds: 100),
329+
bottom: showControls.value
330+
? 100
331+
: (24 + settings.subtitleBottomPadding.toDouble()),
332+
child: AnimatedContainer(
333+
alignment: Alignment.bottomCenter,
334+
duration: const Duration(milliseconds: 300),
335+
child: Column(
336+
mainAxisSize: MainAxisSize.min,
337+
crossAxisAlignment: CrossAxisAlignment.center,
338+
mainAxisAlignment: MainAxisAlignment.center,
339+
children: [
340+
Container(
341+
padding:
336342
const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
337-
decoration: BoxDecoration(
338-
color: videoPlayerController.subtitle[0].isEmpty
339-
? Colors.transparent
340-
: Color(
341-
settings.subtitleBackgroundColor,
342-
),
343-
borderRadius: BorderRadius.circular(12),
344-
),
345-
child: Text(
346-
[
347-
for (final line in videoPlayerController.subtitle)
348-
if (line.trim().isNotEmpty) line.trim(),
349-
].join('\n'),
350-
textAlign: TextAlign.center,
351-
style: TextStyle(
352-
fontSize: settings.subtitleSize.toDouble(),
353-
fontWeight:
343+
decoration: BoxDecoration(
344+
color: videoPlayerController.subtitle[0].isEmpty
345+
? Colors.transparent
346+
: Color(
347+
settings.subtitleBackgroundColor,
348+
),
349+
borderRadius: BorderRadius.circular(12),
350+
),
351+
child: Text(
352+
[
353+
for (final line in videoPlayerController.subtitle)
354+
if (line
355+
.trim()
356+
.isNotEmpty) line.trim(),
357+
].join('\n'),
358+
textAlign: TextAlign.center,
359+
style: TextStyle(
360+
fontSize: settings.subtitleSize.toDouble(),
361+
fontWeight:
354362
FontWeight.values[settings.subtitleWeight.toInt()],
355-
fontFamily: settings.subtitleFont,
356-
color: Color(settings.subtitleColor),
357-
shadows: [
358-
Shadow(
359-
offset: const Offset(1.0, 1.0),
360-
blurRadius: 10.0,
361-
color: Color(settings.subtitleOutlineColor),
363+
fontFamily: settings.subtitleFont,
364+
color: Color(settings.subtitleColor),
365+
shadows: [
366+
Shadow(
367+
offset: const Offset(1.0, 1.0),
368+
blurRadius: 10.0,
369+
color: Color(settings.subtitleOutlineColor),
370+
),
371+
],
362372
),
363-
],
373+
),
364374
),
365-
),
375+
],
366376
),
367-
],
377+
),
368378
),
369-
),
370-
),
371379
);
372380
}
373381

@@ -450,7 +458,10 @@ class MediaPlayerState extends State<MediaPlayer>
450458
final skipDuration = 0.obs;
451459

452460
void _handleDoubleTap(TapDownDetails details) {
453-
final screenWidth = MediaQuery.of(context).size.width;
461+
final screenWidth = MediaQuery
462+
.of(context)
463+
.size
464+
.width;
454465
final tapPosition = details.globalPosition;
455466
final isLeft = tapPosition.dx < screenWidth / 2;
456467
_skipSegments(isLeft);
@@ -460,6 +471,7 @@ class MediaPlayerState extends State<MediaPlayer>
460471
double currentSpeed = 2.0;
461472
Offset? longPressStartPosition;
462473
RxBool isLongPress = false.obs;
474+
463475
void _handleLongPressStart(LongPressStartDetails details) {
464476
isLongPress.value = true;
465477
initialSpeed = videoPlayerController.currentSpeed.value;
@@ -525,8 +537,14 @@ class MediaPlayerState extends State<MediaPlayer>
525537
return const SizedBox();
526538
}
527539
return AnimatedPositioned(
528-
left: isLeftSide.value ? 0 : MediaQuery.of(context).size.width / 1.5,
529-
width: MediaQuery.of(context).size.width / 2.5,
540+
left: isLeftSide.value ? 0 : MediaQuery
541+
.of(context)
542+
.size
543+
.width / 1.5,
544+
width: MediaQuery
545+
.of(context)
546+
.size
547+
.width / 2.5,
530548
top: 0,
531549
bottom: 0,
532550
duration: const Duration(milliseconds: 1000),
@@ -603,11 +621,11 @@ class MediaPlayerState extends State<MediaPlayer>
603621
Widget _buildEpisodeList() {
604622
var episodeList = widget.media.anime?.episodes ?? {};
605623
var (chunk, initChunkIndex) =
606-
buildChunks(context, episodeList, widget.media.userProgress.toString());
624+
buildChunks(context, episodeList, widget.media.userProgress.toString());
607625

608626
RxInt selectedChunkIndex = (-1).obs;
609627
selectedChunkIndex =
610-
selectedChunkIndex.value == -1 ? initChunkIndex : selectedChunkIndex;
628+
selectedChunkIndex.value == -1 ? initChunkIndex : selectedChunkIndex;
611629

612630
return ScrollConfig(
613631
context,
@@ -624,7 +642,7 @@ class MediaPlayerState extends State<MediaPlayer>
624642
reverse,
625643
),
626644
Obx(
627-
() {
645+
() {
628646
var reversed = reverse.value
629647
? chunk.map((element) => element.reversed.toList()).toList()
630648
: chunk;
@@ -662,19 +680,23 @@ class MediaPlayerState extends State<MediaPlayer>
662680
onPressed: () => settingsDialog(),
663681
icon: Icon(
664682
Icons.menu_rounded,
665-
color: Theme.of(context).colorScheme.onSurface,
683+
color: Theme
684+
.of(context)
685+
.colorScheme
686+
.onSurface,
666687
),
667688
),
668689
],
669690
),
670691
);
671692
}
672693

673-
void settingsDialog() => AnimeCompactSettings(
694+
void settingsDialog() =>
695+
AnimeCompactSettings(
674696
context,
675697
widget.media,
676698
widget.source,
677-
(i) {
699+
(i) {
678700
viewType.value = i.recyclerStyle;
679701
reverse.value = i.recyclerReversed;
680702
},
@@ -694,7 +716,7 @@ class MediaPlayerState extends State<MediaPlayer>
694716
var keyNumber = int.parse(event.logicalKey.keyLabel);
695717

696718
var videoDurationSeconds =
697-
_timeStringToSeconds(videoPlayerController.maxTime.value);
719+
_timeStringToSeconds(videoPlayerController.maxTime.value);
698720
var targetSeconds = (keyNumber / 10) * videoDurationSeconds;
699721

700722
if (keyNumber == 1) {
@@ -728,15 +750,17 @@ class MediaPlayerState extends State<MediaPlayer>
728750

729751
void saveSelected(int id, Selected data) {
730752
var sourceName =
731-
Provider.of<MediaServiceProvider>(Get.context!, listen: false)
753+
Provider
754+
.of<MediaServiceProvider>(Get.context!, listen: false)
732755
.currentService
733756
.getName;
734757
saveCustomData("Selected-$id-$sourceName", data);
735758
}
736759

737760
Selected loadSelected(m.Media mediaData) {
738761
var sourceName =
739-
Provider.of<MediaServiceProvider>(Get.context!, listen: false)
762+
Provider
763+
.of<MediaServiceProvider>(Get.context!, listen: false)
740764
.currentService
741765
.getName;
742766
return loadCustomData("Selected-${mediaData.id}-$sourceName") ?? Selected();

0 commit comments

Comments
 (0)