Merge pull request #469 from NBA2K1/main

Fix inspector/crash issues & improve UX in extension, player, and UI
This commit is contained in:
Moustapha Kodjo Amadou 2025-06-01 20:25:50 +01:00 committed by GitHub
commit 714ee50b1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 37 additions and 15 deletions

View file

@ -176,8 +176,8 @@ class DartExtensionService implements ExtensionService {
@override
List<SourcePreference> getSourcePreferences() {
final interpreter = _executeLib();
try {
final interpreter = _executeLib();
final result = interpreter.invoke('getSourcePreferences', []);
return (result as List).cast();
} catch (_) {

View file

@ -266,13 +266,19 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
_currentTotalDuration.value = duration;
});
bool get hasNextEpisode => _streamController.getEpisodeIndex().$1 != 0;
late final StreamSubscription<bool> _completed = _player.stream.completed
.listen((val) {
if (_streamController.getEpisodeIndex().$1 != 0 && val == true) {
if (hasNextEpisode && val) {
if (mounted) {
pushToNewEpisode(context, _streamController.getNextEpisode());
}
}
// If the last episode of an Anime has ended, exit fullscreen mode
if (!hasNextEpisode && val && _isDesktop && !_enterFullScreen.value) {
setFullScreen(value: false);
}
});
void pushToNewEpisode(BuildContext context, Chapter episode) {
@ -839,7 +845,6 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
_streamController.getEpisodesLength(
_streamController.getEpisodeIndex().$2,
);
bool hasNextEpisode = _streamController.getEpisodeIndex().$1 != 0;
final skipDuration = ref.watch(defaultDoubleTapToSkipLengthStateProvider);
return Column(
mainAxisAlignment: MainAxisAlignment.end,

View file

@ -545,7 +545,7 @@ Widget _textEditing(
return Padding(
padding: const EdgeInsets.all(4),
child: TextFormField(
keyboardType: TextInputType.number,
keyboardType: label == "Page" ? TextInputType.number : TextInputType.text,
onChanged: onChanged,
decoration: InputDecoration(
hintText: hintText,

View file

@ -77,7 +77,10 @@ class AboutScreen extends ConsumerWidget {
),
);
},
icon: const Icon(FontAwesomeIcons.github),
icon: const Padding(
padding: EdgeInsets.only(left: 2.5, right: 2.5),
child: Icon(FontAwesomeIcons.github),
),
),
IconButton(
onPressed: () {
@ -87,7 +90,10 @@ class AboutScreen extends ConsumerWidget {
),
);
},
icon: const Icon(FontAwesomeIcons.discord),
icon: const Padding(
padding: EdgeInsets.only(right: 5),
child: Icon(FontAwesomeIcons.discord),
),
),
],
),

View file

@ -68,21 +68,32 @@ GoRouter router(Ref ref) {
@riverpod
class RouterCurrentLocationState extends _$RouterCurrentLocationState {
bool _didSubscribe = false;
@override
String? build(BuildContext context) {
_listener();
// Delay listenerregistration until after the first frame.
if (!_didSubscribe) {
_didSubscribe = true;
// Schedule the registration to run after the first build/frame:
WidgetsBinding.instance.addPostFrameCallback((_) {
_listener();
});
}
return null;
}
_listener() {
final router = GoRouter.of(context);
void _listener() {
final router = ref.read(routerProvider);
router.routerDelegate.addListener(() {
final RouteMatch lastMatch =
router.routerDelegate.currentConfiguration.last;
final RouteMatchList matchList = lastMatch is ImperativeRouteMatch
? lastMatch.matches
: router.routerDelegate.currentConfiguration;
state = matchList.uri.toString();
WidgetsBinding.instance.addPostFrameCallback((_) {
final RouteMatchList matches =
router.routerDelegate.currentConfiguration;
final RouteMatch lastMatch = matches.last;
final RouteMatchList matchList = lastMatch is ImperativeRouteMatch
? lastMatch.matches
: matches;
state = matchList.uri.toString();
});
});
}
}