Skip to content

Commit 469dc19

Browse files
committed
feat(): fix stuff for timestamps
1 parent 3cc2b29 commit 469dc19

File tree

7 files changed

+114
-90
lines changed

7 files changed

+114
-90
lines changed

lib/Adaptor/Episode/EpisodeCompactViewHolder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class EpisodeCompactView extends StatelessWidget {
4848
context: context,
4949
mediaId: mediaData.id,
5050
ep: episode.number,
51-
width: 162,
51+
width: double.infinity,
5252
),
5353
),
5454

lib/Adaptor/Episode/EpisodeGridViewHolder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class EpisodeCardView extends StatelessWidget {
5252
context: context,
5353
mediaId: mediaData.id,
5454
ep: episode.number,
55-
width: 162,
55+
width: double.infinity,
5656
)
5757
],
5858
),

lib/Screens/Info/Tabs/Watch/Anime/Player/Platform/WindowsPlayer.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class WindowsPlayer extends BasePlayer {
8989
visible: settings.showSubtitle,
9090
style: TextStyle(
9191
fontSize: settings.subtitleSize.toDouble(),
92+
fontWeight: FontWeight.values[settings.subtitleWeight.toInt()],
9293
fontFamily: settings.subtitleFont,
9394
backgroundColor: Color(settings.subtitleBackgroundColor),
9495
color: Color(settings.subtitleColor),

lib/Screens/Info/Tabs/Watch/Anime/Player/PlayerController.dart

Lines changed: 57 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,24 @@ class _PlayerControllerState extends State<PlayerController> {
8888
setDiscordRpc();
8989

9090
timeStamps.value = await AniSkip.getResult(
91-
malId: media.idMAL,
92-
episodeNumber: currentEpisode.number.toInt(),
93-
episodeLength: _timeStringToSeconds(_controller.maxTime.value).toInt(),
94-
useProxyForTimeStamps: false,
95-
) ?? [];
91+
malId: media.idMAL,
92+
episodeNumber: currentEpisode.number.toInt(),
93+
episodeLength:
94+
_timeStringToSeconds(_controller.maxTime.value).toInt(),
95+
useProxyForTimeStamps: false,
96+
) ??
97+
[];
9698

9799
_controller.seek(Duration(seconds: currentProgress ?? 0));
98100
_controller.currentPosition.listen((v) {
99101
if (v.inSeconds > 0) {
100102
_saveProgress(v.inSeconds);
101103
timeStampsText.value = timeStamps
102-
.firstWhereOrNull((e) => e.interval.startTime <= v.inSeconds && e.interval.endTime >= v.inSeconds)
103-
?.getType() ?? '';
104+
.firstWhereOrNull((e) =>
105+
e.interval.startTime <= v.inSeconds &&
106+
e.interval.endTime >= v.inSeconds)
107+
?.getType() ??
108+
'';
104109
}
105110
});
106111

@@ -213,12 +218,14 @@ class _PlayerControllerState extends State<PlayerController> {
213218
),
214219
),
215220
Obx(
216-
() => Text(
217-
" $timeStampsText",
221+
() => timeStampsText.value != '' ? Text(
222+
" $timeStampsText",
218223
style: TextStyle(
219224
color: Colors.white,
225+
fontWeight: FontWeight.w300,
226+
fontFamily: 'Poppins-SemiBold',
220227
),
221-
),
228+
) : const SizedBox(),
222229
),
223230
],
224231
),
@@ -264,20 +271,18 @@ class _PlayerControllerState extends State<PlayerController> {
264271
secondaryTrackValue:
265272
bufferingValue.clamp(0.0, maxValue),
266273
secondaryActiveColor: Colors.white,
267-
onChangeStart: (_) => _controller.pause(),
268274
onChangeEnd: (val) async {
269275
_controller.seek(Duration(seconds: val.toInt()));
270-
_controller.play();
271276
},
272277
onChanged: (double value) => _controller
273278
.currentTime.value = _formatTime(value.toInt()),
274279
),
275280
Positioned.fill(
276281
child: Padding(
277282
padding: const EdgeInsets.only(
278-
left: 7.0,
279-
right: 8.0,
280-
top: 4.5,
283+
left: 3.0,
284+
right: 5.0,
285+
top: 4.4,
281286
),
282287
child: LayoutBuilder(
283288
builder: (context, constraints) {
@@ -286,10 +291,13 @@ class _PlayerControllerState extends State<PlayerController> {
286291
children: timeStamps.map(
287292
(timestamp) {
288293
var startPosition =
289-
(timestamp.interval.startTime / maxValue) *
294+
(timestamp.interval.startTime /
295+
maxValue) *
290296
trackWidth;
291297
var endPosition =
292-
(timestamp.interval.endTime / maxValue) * trackWidth;
298+
(timestamp.interval.endTime /
299+
maxValue) *
300+
trackWidth;
293301

294302
return Positioned(
295303
left:
@@ -298,7 +306,7 @@ class _PlayerControllerState extends State<PlayerController> {
298306
children: [
299307
SizedBox(
300308
width: endPosition - startPosition,
301-
child: _buildDot(),
309+
child: _buildLine(),
302310
),
303311
],
304312
),
@@ -321,9 +329,9 @@ class _PlayerControllerState extends State<PlayerController> {
321329
);
322330
}
323331

324-
Widget _buildDot() {
332+
Widget _buildLine() {
325333
return Container(
326-
height: 3,
334+
height: 3.4,
327335
decoration: BoxDecoration(
328336
color: Color.fromARGB(255, 56, 192, 41),
329337
shape: BoxShape.rectangle,
@@ -588,52 +596,33 @@ class _PlayerControllerState extends State<PlayerController> {
588596
title: "Subtitles",
589597
viewList: [_buildSubtitleList(sub)],
590598
negativeText: "Add Subtitle",
591-
negativeCallback: () {
592-
FilePicker.platform.pickFiles(
599+
negativeCallback: () async {
600+
var file = await FilePicker.platform.pickFiles(
593601
type: FileType.custom,
594-
allowedExtensions: [
595-
'srt',
596-
'ass',
597-
'ssa',
598-
'vtt',
599-
'sub',
600-
'txt',
601-
'dfxp',
602-
'smi',
603-
'stl',
604-
'idx',
605-
'ttml',
606-
'sbv',
607-
'lrc',
608-
'xml'
609-
],
610-
).then(
611-
(value) {
612-
if (value != null) {
613-
if (sub) {
614-
currentQuality.subtitles = [
615-
v.Track(
616-
file: value.files.single.path ?? "",
617-
label: value.files.single.name,
618-
),
619-
];
620-
} else {
621-
currentQuality.subtitles?.add(
622-
v.Track(
623-
file: value.files.single.path ?? "",
624-
label: value.files.single.name,
625-
),
626-
);
627-
}
628-
_controller.setSubtitle(
629-
value.files.single.path ?? "",
630-
value.files.single.name,
631-
);
632-
Get.back();
633-
_controller.play();
634-
}
635-
},
602+
allowedExtensions: subMap,
636603
);
604+
if (file == null) return;
605+
if (sub) {
606+
currentQuality.subtitles = [
607+
v.Track(
608+
file: file.files.single.path ?? "",
609+
label: file.files.single.name,
610+
),
611+
];
612+
} else {
613+
currentQuality.subtitles?.add(
614+
v.Track(
615+
file: file.files.single.path ?? "",
616+
label: file.files.single.name,
617+
),
618+
);
619+
}
620+
_controller.setSubtitle(
621+
file.files.single.path ?? "",
622+
file.files.single.name,
623+
);
624+
Get.back();
625+
_controller.play();
637626
},
638627
);
639628
showCustomBottomDialog(context, subtitlesDialog);
@@ -693,7 +682,8 @@ class _PlayerControllerState extends State<PlayerController> {
693682
return Text(
694683
timeStampsText.value != ''
695684
? timeStamps
696-
.firstWhere((e) => e.getType() == timeStampsText.value)
685+
.firstWhere(
686+
(e) => e.getType() == timeStampsText.value)
697687
.getType()
698688
: "+${settings.skipDuration}s",
699689
style: const TextStyle(
@@ -719,9 +709,8 @@ class _PlayerControllerState extends State<PlayerController> {
719709

720710
void _fastForward(int seconds) {
721711
if (timeStampsText.value != '') {
722-
var current = timeStamps.firstWhere(
723-
(element) => element.getType() == timeStampsText.value
724-
);
712+
var current = timeStamps
713+
.firstWhere((element) => element.getType() == timeStampsText.value);
725714
_controller.seek(Duration(seconds: current.interval.endTime.toInt()));
726715
return;
727716
}

lib/Screens/Info/Tabs/Watch/Widgets/WrongTitle.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class WrongTitleDialog extends StatefulWidget {
3030
class WrongTitleDialogState extends State<WrongTitleDialog> {
3131
final TextEditingController textEditingController = TextEditingController();
3232
late Future<MPages?> searchFuture;
33-
33+
late FocusNode focusNode;
3434
@override
3535
void initState() {
3636
super.initState();
@@ -40,6 +40,18 @@ class WrongTitleDialogState extends State<WrongTitleDialog> {
4040
'';
4141
textEditingController.text = initialSearchText;
4242
searchFuture = _performSearch(initialSearchText);
43+
44+
45+
WidgetsBinding.instance.addPostFrameCallback((_) {
46+
focusNode.requestFocus();
47+
});
48+
}
49+
50+
@override
51+
void dispose() {
52+
super.dispose;
53+
textEditingController.dispose();
54+
focusNode.dispose();
4355
}
4456

4557
Future<MPages?> _performSearch(String query) {
@@ -66,7 +78,7 @@ class WrongTitleDialogState extends State<WrongTitleDialog> {
6678
viewList: [
6779
_buildSearchInput(theme),
6880
const SizedBox(height: 16.0),
69-
FutureBuilder<MPages?>(
81+
FutureBuilder(
7082
future: searchFuture,
7183
builder: (context, snapshot) {
7284
return _buildResultList(snapshot, theme);
@@ -78,6 +90,7 @@ class WrongTitleDialogState extends State<WrongTitleDialog> {
7890

7991
Widget _buildSearchInput(ColorScheme theme) {
8092
return TextField(
93+
focusNode: focusNode,
8194
controller: textEditingController,
8295
onSubmitted: _onSubmitted,
8396
style: TextStyle(

lib/Screens/Settings/SettingsPlayerScreen.dart

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -297,26 +297,10 @@ List<Widget> playerSettings(
297297
}
298298

299299
Future<void> openPlayer(BuildContext context) async {
300-
const allowedExtensions = [
301-
'mp4',
302-
'mkv',
303-
'webm',
304-
'avi',
305-
'mov',
306-
'wmv',
307-
'flv',
308-
'm4v',
309-
'3gp',
310-
'mpg',
311-
'mpeg',
312-
'ogv',
313-
'ts',
314-
'm3u8',
315-
];
316-
300+
if (!await StorageProvider().videoPermission()) return;
317301
final result = await FilePicker.platform.pickFiles(
318302
type: FileType.custom,
319-
allowedExtensions: allowedExtensions,
303+
allowedExtensions: vidMap,
320304
);
321305

322306
if (result == null) return;
@@ -350,6 +334,40 @@ Future<void> openPlayer(BuildContext context) async {
350334
);
351335
}
352336

337+
List<String> vidMap = [
338+
'mp4',
339+
'mkv',
340+
'webm',
341+
'avi',
342+
'mov',
343+
'wmv',
344+
'flv',
345+
'm4v',
346+
'3gp',
347+
'mpg',
348+
'mpeg',
349+
'ogv',
350+
'ts',
351+
'm3u8',
352+
];
353+
354+
List<String> subMap = [
355+
'srt',
356+
'ass',
357+
'ssa',
358+
'vtt',
359+
'sub',
360+
'txt',
361+
'dfxp',
362+
'smi',
363+
'stl',
364+
'idx',
365+
'ttml',
366+
'sbv',
367+
'lrc',
368+
'xml'
369+
];
370+
353371
List<String> speedMap(bool cursed) => cursed
354372
? [
355373
"0.25x",

pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ flutter:
134134
weight: 600
135135
- asset: assets/fonts/poppins_thin.ttf
136136
weight: 100
137+
- family: Poppins-SemiBold
138+
fonts:
139+
- asset: assets/fonts/poppins_semi_bold.ttf
137140

138141
# Assets
139142
assets:

0 commit comments

Comments
 (0)