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 @override
List<SourcePreference> getSourcePreferences() { List<SourcePreference> getSourcePreferences() {
final interpreter = _executeLib();
try { try {
final interpreter = _executeLib();
final result = interpreter.invoke('getSourcePreferences', []); final result = interpreter.invoke('getSourcePreferences', []);
return (result as List).cast(); return (result as List).cast();
} catch (_) { } catch (_) {

View file

@ -266,13 +266,19 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
_currentTotalDuration.value = duration; _currentTotalDuration.value = duration;
}); });
bool get hasNextEpisode => _streamController.getEpisodeIndex().$1 != 0;
late final StreamSubscription<bool> _completed = _player.stream.completed late final StreamSubscription<bool> _completed = _player.stream.completed
.listen((val) { .listen((val) {
if (_streamController.getEpisodeIndex().$1 != 0 && val == true) { if (hasNextEpisode && val) {
if (mounted) { if (mounted) {
pushToNewEpisode(context, _streamController.getNextEpisode()); 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) { void pushToNewEpisode(BuildContext context, Chapter episode) {
@ -839,7 +845,6 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
_streamController.getEpisodesLength( _streamController.getEpisodesLength(
_streamController.getEpisodeIndex().$2, _streamController.getEpisodeIndex().$2,
); );
bool hasNextEpisode = _streamController.getEpisodeIndex().$1 != 0;
final skipDuration = ref.watch(defaultDoubleTapToSkipLengthStateProvider); final skipDuration = ref.watch(defaultDoubleTapToSkipLengthStateProvider);
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,

View file

@ -545,7 +545,7 @@ Widget _textEditing(
return Padding( return Padding(
padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(4),
child: TextFormField( child: TextFormField(
keyboardType: TextInputType.number, keyboardType: label == "Page" ? TextInputType.number : TextInputType.text,
onChanged: onChanged, onChanged: onChanged,
decoration: InputDecoration( decoration: InputDecoration(
hintText: hintText, 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( IconButton(
onPressed: () { 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 @riverpod
class RouterCurrentLocationState extends _$RouterCurrentLocationState { class RouterCurrentLocationState extends _$RouterCurrentLocationState {
bool _didSubscribe = false;
@override @override
String? build(BuildContext context) { 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; return null;
} }
_listener() { void _listener() {
final router = GoRouter.of(context); final router = ref.read(routerProvider);
router.routerDelegate.addListener(() { router.routerDelegate.addListener(() {
final RouteMatch lastMatch = WidgetsBinding.instance.addPostFrameCallback((_) {
router.routerDelegate.currentConfiguration.last; final RouteMatchList matches =
final RouteMatchList matchList = lastMatch is ImperativeRouteMatch router.routerDelegate.currentConfiguration;
? lastMatch.matches final RouteMatch lastMatch = matches.last;
: router.routerDelegate.currentConfiguration; final RouteMatchList matchList = lastMatch is ImperativeRouteMatch
state = matchList.uri.toString(); ? lastMatch.matches
: matches;
state = matchList.uri.toString();
});
}); });
} }
} }