@@ -5,6 +5,7 @@ import 'dart:math';
5
5
import 'package:dantotsu/Preferences/HiveDataClasses/DefaultPlayerSettings/DefaultPlayerSettings.dart' ;
6
6
import 'package:dantotsu/Preferences/PrefManager.dart' ;
7
7
import 'package:dantotsu/Preferences/Preferences.dart' ;
8
+ import 'package:flutter/foundation.dart' ;
8
9
import 'package:flutter/material.dart' ;
9
10
import 'package:flutter/services.dart' ;
10
11
import 'package:get/get.dart' ;
@@ -93,16 +94,14 @@ class MediaPlayerState extends State<MediaPlayer>
93
94
94
95
final _isCursorVisible = true .obs;
95
96
Timer ? _hideCursorTimer;
96
-
97
- void _onMouseMoved (PointerEvent event) {
97
+ void _onMouseMoved () {
98
98
if (! _isCursorVisible.value) {
99
99
_isCursorVisible.value = true ;
100
100
showControls.value = true ;
101
101
}
102
102
_hideCursorTimer? .cancel ();
103
103
_hideCursorTimer = Timer (const Duration (seconds: 3 ), () {
104
104
_isCursorVisible.value = false ;
105
-
106
105
showControls.value = false ;
107
106
});
108
107
}
@@ -146,7 +145,7 @@ class MediaPlayerState extends State<MediaPlayer>
146
145
if (state) {
147
146
SystemChrome .setPreferredOrientations (
148
147
[DeviceOrientation .landscapeLeft, DeviceOrientation .landscapeRight]);
149
- SystemChrome .setEnabledSystemUIMode (SystemUiMode .immersive );
148
+ SystemChrome .setEnabledSystemUIMode (SystemUiMode .immersiveSticky );
150
149
} else {
151
150
SystemChrome .setPreferredOrientations ([
152
151
DeviceOrientation .portraitUp,
@@ -161,53 +160,59 @@ class MediaPlayerState extends State<MediaPlayer>
161
160
@override
162
161
Widget build (BuildContext context) {
163
162
return Obx (
164
- () {
165
- return MouseRegion (
166
- onHover: _onMouseMoved,
167
- cursor: _isCursorVisible.value
168
- ? SystemMouseCursors .basic
169
- : SystemMouseCursors .none,
170
- child: Scaffold (
171
- body: LayoutBuilder (
172
- builder: (context, constraints) {
173
- const double minWidth = 250 ;
174
- final double availableWidth = constraints.maxWidth;
175
-
176
- double episodePanelWidth =
177
- (availableWidth / 3 ).clamp (minWidth, availableWidth);
178
-
179
- return StatefulBuilder (
180
- builder: (context, setState) {
181
- return Row (
182
- crossAxisAlignment: CrossAxisAlignment .start,
183
- children: [
184
- _buildVideoPlayer (availableWidth, episodePanelWidth),
185
- Obx (() {
186
- if (! showEpisodes.value) {
187
- return const SizedBox ();
188
- }
189
- return GestureDetector (
190
- onHorizontalDragUpdate: (details) {
191
- setState (
192
- () => episodePanelWidth =
193
- (episodePanelWidth - details.delta.dx)
194
- .clamp (minWidth, availableWidth),
195
- );
196
- },
197
- child: SizedBox (
198
- width: episodePanelWidth,
199
- child: SingleChildScrollView (
200
- padding: const EdgeInsets .all (8.0 ),
201
- child: _buildEpisodeList (),
163
+ () {
164
+ return GestureDetector (
165
+ onTap: _onMouseMoved,
166
+ onPanUpdate: (_) => _onMouseMoved (),
167
+ child: MouseRegion (
168
+ onHover: (_) => _onMouseMoved (),
169
+ cursor: defaultTargetPlatform == TargetPlatform .macOS || defaultTargetPlatform == TargetPlatform .windows
170
+ ? (_isCursorVisible.value
171
+ ? SystemMouseCursors .basic
172
+ : SystemMouseCursors .none)
173
+ : SystemMouseCursors .basic,
174
+ child: Scaffold (
175
+ body: LayoutBuilder (
176
+ builder: (context, constraints) {
177
+ const double minWidth = 250 ;
178
+ final double availableWidth = constraints.maxWidth;
179
+
180
+ double episodePanelWidth =
181
+ (availableWidth / 3 ).clamp (minWidth, availableWidth);
182
+
183
+ return StatefulBuilder (
184
+ builder: (context, setState) {
185
+ return Row (
186
+ crossAxisAlignment: CrossAxisAlignment .start,
187
+ children: [
188
+ _buildVideoPlayer (availableWidth, episodePanelWidth),
189
+ Obx (() {
190
+ if (! showEpisodes.value) {
191
+ return const SizedBox ();
192
+ }
193
+ return GestureDetector (
194
+ onHorizontalDragUpdate: (details) {
195
+ setState (
196
+ () => episodePanelWidth =
197
+ (episodePanelWidth - details.delta.dx)
198
+ .clamp (minWidth, availableWidth),
199
+ );
200
+ },
201
+ child: SizedBox (
202
+ width: episodePanelWidth,
203
+ child: SingleChildScrollView (
204
+ padding: const EdgeInsets .all (8.0 ),
205
+ child: _buildEpisodeList (),
206
+ ),
202
207
),
203
- ),
204
- );
205
- }) ,
206
- ],
207
- );
208
- },
209
- );
210
- } ,
208
+ );
209
+ }),
210
+ ] ,
211
+ );
212
+ },
213
+ );
214
+ },
215
+ ) ,
211
216
),
212
217
),
213
218
);
@@ -483,9 +488,10 @@ class MediaPlayerState extends State<MediaPlayer>
483
488
}
484
489
485
490
Widget _buildEpisodeList () {
486
- Map < String , Episode > episodeList = widget.media.anime? .episodes ?? {};
491
+ var episodeList = widget.media.anime? .episodes ?? {};
487
492
var (chunk, initChunkIndex) =
488
493
buildChunks (context, episodeList, widget.media.userProgress.toString ());
494
+
489
495
RxInt selectedChunkIndex = (- 1 ).obs;
490
496
selectedChunkIndex =
491
497
selectedChunkIndex.value == - 1 ? initChunkIndex : selectedChunkIndex;
@@ -506,7 +512,7 @@ class MediaPlayerState extends State<MediaPlayer>
506
512
),
507
513
Obx (
508
514
() {
509
- List < List < Episode >> reversed = reverse.value
515
+ var reversed = reverse.value
510
516
? chunk.map ((element) => element.reversed.toList ()).toList ()
511
517
: chunk;
512
518
return EpisodeAdaptor (
@@ -540,7 +546,7 @@ class MediaPlayerState extends State<MediaPlayer>
540
546
maxLines: 1 ,
541
547
),
542
548
IconButton (
543
- onPressed: () => settingsDialog (context, widget.media ),
549
+ onPressed: () => settingsDialog (),
544
550
icon: Icon (
545
551
Icons .menu_rounded,
546
552
color: Theme .of (context).colorScheme.onSurface,
@@ -551,10 +557,10 @@ class MediaPlayerState extends State<MediaPlayer>
551
557
);
552
558
}
553
559
554
- void settingsDialog (BuildContext context, m. Media media ) =>
560
+ void settingsDialog () =>
555
561
AnimeCompactSettings (
556
562
context,
557
- media,
563
+ widget. media,
558
564
(i) {
559
565
viewType.value = i.recyclerStyle! ;
560
566
reverse.value = i.recyclerReversed;
0 commit comments