diff --git a/lib/components/animes/calendar/calendar_anime_component.dart b/lib/components/animes/calendar/calendar_anime_component.dart index 9f34492..b98786b 100644 --- a/lib/components/animes/calendar/calendar_anime_component.dart +++ b/lib/components/animes/calendar/calendar_anime_component.dart @@ -72,9 +72,15 @@ class CalendarAnimeComponent extends StatelessWidget { ), ); }, - onLongPress: (final TapDownDetails? details) { - AnimeController.instance.onLongPress(context, release.anime, details); - }, + onLongPress: !isReleased + ? (final TapDownDetails? details) { + AnimeController.instance.onLongPress( + context, + release.anime, + details, + ); + } + : null, child: Column( spacing: 8, children: [ diff --git a/lib/components/platforms/platform_preference_dialog.dart b/lib/components/platforms/platform_preference_dialog.dart index 723d8e0..5c5b340 100644 --- a/lib/components/platforms/platform_preference_dialog.dart +++ b/lib/components/platforms/platform_preference_dialog.dart @@ -34,7 +34,7 @@ class PlatformPreferenceDialog extends StatefulWidget { isScrollControlled: true, showDragHandle: true, builder: (final BuildContext context) => FractionallySizedBox( - heightFactor: 0.55, + heightFactor: 0.45, child: PlatformPreferenceDialog( platforms: platforms, initialRemember: initialRemember, @@ -93,7 +93,8 @@ class _PlatformPreferenceDialogState extends State { return Padding( key: ValueKey(platform.id), padding: const EdgeInsets.symmetric(vertical: 8), - child: Row( + child: Flex( + direction: Axis.horizontal, spacing: 8, children: [ PlatformComponent( @@ -106,7 +107,7 @@ class _PlatformPreferenceDialogState extends State { style: Theme.of(context).textTheme.bodyLarge, ), const Spacer(), - const Icon(Icons.drag_handle), + const Icon(Icons.drag_indicator), ], ), ); @@ -124,26 +125,27 @@ class _PlatformPreferenceDialogState extends State { ), ), ), - if (!widget.isForSettings) - Padding( - padding: const EdgeInsets.all(16), - child: Row( - children: [ - Checkbox( - value: _remember, - onChanged: (final bool? value) => - setState(() => _remember = value ?? false), - ), - const SizedBox(width: 8), - Expanded(child: Text(l10n.rememberMyChoice)), - ], - ), - ), Padding( padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16), child: Row( - mainAxisAlignment: MainAxisAlignment.end, children: [ + if (!widget.isForSettings) + GestureDetector( + onTap: () => setState(() => _remember = !_remember), + child: Flex( + direction: Axis.horizontal, + children: [ + Checkbox( + value: _remember, + onChanged: (final bool? value) => + setState(() => _remember = value ?? false), + ), + const SizedBox(width: 8), + Text(l10n.rememberMyChoice), + ], + ), + ), + const Spacer(), ElevatedButton( onPressed: () => Navigator.of(context).pop( diff --git a/lib/controllers/animes/anime_controller.dart b/lib/controllers/animes/anime_controller.dart index 770b502..098db95 100644 --- a/lib/controllers/animes/anime_controller.dart +++ b/lib/controllers/animes/anime_controller.dart @@ -74,7 +74,7 @@ class AnimeController extends GenericController { spacing: 8, direction: Axis.horizontal, children: [ - const Icon(Icons.checklist), + const Icon(Icons.bookmark_add_outlined), Text(AppLocalizations.of(context)!.markWatched), ], ), diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 6fbd47d..b740278 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -168,7 +168,8 @@ "rememberMyChoice": "Remember my choice", "dragToReorder": "Drag to reorder", "continueLabel": "Continue", - "platformPreferencesDescription": "Sort your streaming services (like Netflix, Disney+, etc.) by placing your favorite one first.\n\nThis way, when you play an episode, we'll always suggest that service first and can even open it for you automatically.", + "platformPreferencesDescription": "Place your favorite service at the top of the list. We will use it by default to launch your episodes.", "reorderPlatforms": "Service Priority", - "reorderPlatformsDescription": "Put your favorite service at the top of the list. We'll prioritize it when you go to watch an episode" + "reorderPlatformsDescription": "Put your favorite service at the top of the list. We'll prioritize it when you go to watch an episode", + "loggingIn": "Logging in..." } \ No newline at end of file diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index 0a4c30b..4748a55 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -111,7 +111,8 @@ "rememberMyChoice": "Se souvenir de mon choix", "dragToReorder": "Glissez pour réorganiser", "continueLabel": "Continuer", - "platformPreferencesDescription": "Classez vos services de streaming (Netflix, Disney+, etc.) en plaçant votre préféré en premier.\n\nAinsi, quand vous lancerez un épisode, nous vous proposerons toujours ce service en priorité et pourrons même l'ouvrir automatiquement pour vous.", + "platformPreferencesDescription": "Placez votre service préféré en haut de la liste. Nous l'utiliserons par défaut pour lancer vos épisodes", "reorderPlatforms": "Ordre des services", - "reorderPlatformsDescription": "Mettez votre service favori en haut de la liste. Nous le lancerons en priorité lorsque vous regarderez un épisode" + "reorderPlatformsDescription": "Mettez votre service favori en haut de la liste. Nous le lancerons en priorité lorsque vous regarderez un épisode", + "loggingIn": "Connexion en cours..." } \ No newline at end of file diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index 6a8a145..b698844 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -677,7 +677,7 @@ abstract class AppLocalizations { /// No description provided for @platformPreferencesDescription. /// /// In en, this message translates to: - /// **'Sort your streaming services (like Netflix, Disney+, etc.) by placing your favorite one first.\n\nThis way, when you play an episode, we\'ll always suggest that service first and can even open it for you automatically.'** + /// **'Place your favorite service at the top of the list. We will use it by default to launch your episodes.'** String get platformPreferencesDescription; /// No description provided for @reorderPlatforms. @@ -691,6 +691,12 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Put your favorite service at the top of the list. We\'ll prioritize it when you go to watch an episode'** String get reorderPlatformsDescription; + + /// No description provided for @loggingIn. + /// + /// In en, this message translates to: + /// **'Logging in...'** + String get loggingIn; } class _AppLocalizationsDelegate diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index a86ab9d..2b14bb2 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -375,7 +375,7 @@ class AppLocalizationsEn extends AppLocalizations { @override String get platformPreferencesDescription => - 'Sort your streaming services (like Netflix, Disney+, etc.) by placing your favorite one first.\n\nThis way, when you play an episode, we\'ll always suggest that service first and can even open it for you automatically.'; + 'Place your favorite service at the top of the list. We will use it by default to launch your episodes.'; @override String get reorderPlatforms => 'Service Priority'; @@ -383,4 +383,7 @@ class AppLocalizationsEn extends AppLocalizations { @override String get reorderPlatformsDescription => 'Put your favorite service at the top of the list. We\'ll prioritize it when you go to watch an episode'; + + @override + String get loggingIn => 'Logging in...'; } diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index a548541..fddb97a 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -380,7 +380,7 @@ class AppLocalizationsFr extends AppLocalizations { @override String get platformPreferencesDescription => - 'Classez vos services de streaming (Netflix, Disney+, etc.) en plaçant votre préféré en premier.\n\nAinsi, quand vous lancerez un épisode, nous vous proposerons toujours ce service en priorité et pourrons même l\'ouvrir automatiquement pour vous.'; + 'Placez votre service préféré en haut de la liste. Nous l\'utiliserons par défaut pour lancer vos épisodes'; @override String get reorderPlatforms => 'Ordre des services'; @@ -388,4 +388,7 @@ class AppLocalizationsFr extends AppLocalizations { @override String get reorderPlatformsDescription => 'Mettez votre service favori en haut de la liste. Nous le lancerons en priorité lorsque vous regarderez un épisode'; + + @override + String get loggingIn => 'Connexion en cours...'; } diff --git a/lib/main.dart b/lib/main.dart index 51c88fc..e9e1143 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,6 +18,7 @@ import 'package:application/utils/notification_throttler.dart'; import 'package:application/views/account_view.dart'; import 'package:application/views/calendar_view.dart'; import 'package:application/views/home_view.dart'; +import 'package:application/views/loading_view.dart'; import 'package:application/views/no_internet.dart'; import 'package:application/views/simulcast_view.dart'; import 'package:firebase_core/firebase_core.dart'; @@ -61,47 +62,69 @@ Future _firebaseMessagingBackgroundHandler( Future main() async { WidgetsFlutterBinding.ensureInitialized(); - bool hasInternet = false; if (kDebugMode && Constant.apiUrl == 'https://api.shikkanime.fr') { throw Exception('You must change the API URL in the Constant class'); } - try { - if (NotificationsController.isSupported) { - await Firebase.initializeApp( - options: DefaultFirebaseOptions.currentPlatform, - ); - - FirebaseMessaging.onBackgroundMessage( - _firebaseMessagingBackgroundHandler, - ); - FirebaseMessaging.onMessage.listen(_firebaseMessagingBackgroundHandler); - } + runApp(const MyApp()); +} - final int start = DateTime.now().millisecondsSinceEpoch; - debugPrint('Logging in...'); +class MyApp extends StatefulWidget { + const MyApp({super.key}); - await SharedPreferencesController.instance.init(); - await MemberController.instance.init(); - await SortController.instance.init(); + @override + State createState() => _MyAppState(); +} - debugPrint( - 'Logged in in ${DateTime.now().millisecondsSinceEpoch - start}ms', - ); +class _MyAppState extends State { + bool? _hasInternet; - hasInternet = true; - } on Exception catch (e) { - debugPrint(e.toString()); + @override + void initState() { + super.initState(); + _init(); } - runApp(MyApp(hasInternet: hasInternet)); -} + Future _init() async { + try { + if (NotificationsController.isSupported) { + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); + + FirebaseMessaging.onBackgroundMessage( + _firebaseMessagingBackgroundHandler, + ); + FirebaseMessaging.onMessage.listen(_firebaseMessagingBackgroundHandler); + } + + final int start = DateTime.now().millisecondsSinceEpoch; + debugPrint('Logging in...'); -class MyApp extends StatelessWidget { - const MyApp({required this.hasInternet, super.key}); + await SharedPreferencesController.instance.init(); + await MemberController.instance.init(); + await SortController.instance.init(); - final bool hasInternet; + debugPrint( + 'Logged in in ${DateTime.now().millisecondsSinceEpoch - start}ms', + ); + + if (mounted) { + setState(() { + _hasInternet = true; + }); + } + } on Exception catch (e) { + debugPrint(e.toString()); + + if (mounted) { + setState(() { + _hasInternet = false; + }); + } + } + } @override Widget build(final BuildContext context) => MaterialApp( @@ -133,7 +156,9 @@ class MyApp extends StatelessWidget { iconImage: const AssetImage('assets/light_icon.png'), oppositeTextColor: Colors.black, ), - home: hasInternet ? const MyHomePage() : const NoInternet(), + home: _hasInternet == null + ? const LoadingView() + : (_hasInternet! ? const MyHomePage() : const NoInternet()), debugShowCheckedModeBanner: false, ); diff --git a/lib/views/anime_details_view.dart b/lib/views/anime_details_view.dart index 4d037c3..093a653 100644 --- a/lib/views/anime_details_view.dart +++ b/lib/views/anime_details_view.dart @@ -74,7 +74,7 @@ class _AnimeDetailsViewState extends State { text: span, textDirection: TextDirection.ltr, maxLines: 4, - )..layout(maxWidth: MediaQuery.sizeOf(context).width - 16); + )..layout(maxWidth: MediaQuery.sizeOf(context).width); final List? seasons = SortController.instance.sortType == SortType.oldest diff --git a/lib/views/loading_view.dart b/lib/views/loading_view.dart new file mode 100644 index 0000000..964a7f0 --- /dev/null +++ b/lib/views/loading_view.dart @@ -0,0 +1,33 @@ +import 'package:application/l10n/app_localizations.dart'; +import 'package:application/utils/extensions.dart'; +import 'package:flutter/material.dart'; + +class LoadingView extends StatelessWidget { + const LoadingView({super.key}); + + @override + Widget build(final BuildContext context) => Scaffold( + body: Center( + child: Column( + spacing: 16, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + if (Theme.of(context).iconImage != null) + Padding( + padding: const EdgeInsets.only(bottom: 16), + child: Image( + image: Theme.of(context).iconImage!, + width: 100, + height: 100, + ), + ), + const CircularProgressIndicator(), + Text( + AppLocalizations.of(context)!.loggingIn, + style: Theme.of(context).textTheme.bodyLarge, + ), + ], + ), + ), + ); +}