Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/components/animes/calendar/calendar_anime_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Widget>[
Expand Down
40 changes: 21 additions & 19 deletions lib/components/platforms/platform_preference_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -93,7 +93,8 @@ class _PlatformPreferenceDialogState extends State<PlatformPreferenceDialog> {
return Padding(
key: ValueKey<String>(platform.id),
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
child: Flex(
direction: Axis.horizontal,
spacing: 8,
children: <Widget>[
PlatformComponent(
Expand All @@ -106,7 +107,7 @@ class _PlatformPreferenceDialogState extends State<PlatformPreferenceDialog> {
style: Theme.of(context).textTheme.bodyLarge,
),
const Spacer(),
const Icon(Icons.drag_handle),
const Icon(Icons.drag_indicator),
],
),
);
Expand All @@ -124,26 +125,27 @@ class _PlatformPreferenceDialogState extends State<PlatformPreferenceDialog> {
),
),
),
if (!widget.isForSettings)
Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: <Widget>[
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: <Widget>[
if (!widget.isForSettings)
GestureDetector(
onTap: () => setState(() => _remember = !_remember),
child: Flex(
direction: Axis.horizontal,
children: <Widget>[
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<PlatformPreferenceResult>(
Expand Down
2 changes: 1 addition & 1 deletion lib/controllers/animes/anime_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AnimeController extends GenericController<AnimeDto> {
spacing: 8,
direction: Axis.horizontal,
children: <Widget>[
const Icon(Icons.checklist),
const Icon(Icons.bookmark_add_outlined),
Text(AppLocalizations.of(context)!.markWatched),
],
),
Expand Down
5 changes: 3 additions & 2 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
}
5 changes: 3 additions & 2 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
}
8 changes: 7 additions & 1 deletion lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,15 @@ 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';

@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...';
}
5 changes: 4 additions & 1 deletion lib/l10n/app_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,15 @@ 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';

@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...';
}
83 changes: 54 additions & 29 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -61,47 +62,69 @@ Future<void> _firebaseMessagingBackgroundHandler(

Future<void> 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<MyApp> createState() => _MyAppState();
}

debugPrint(
'Logged in in ${DateTime.now().millisecondsSinceEpoch - start}ms',
);
class _MyAppState extends State<MyApp> {
bool? _hasInternet;

hasInternet = true;
} on Exception catch (e) {
debugPrint(e.toString());
@override
void initState() {
super.initState();
_init();
}

runApp(MyApp(hasInternet: hasInternet));
}
Future<void> _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(
Expand Down Expand Up @@ -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,
);

Expand Down
2 changes: 1 addition & 1 deletion lib/views/anime_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class _AnimeDetailsViewState extends State<AnimeDetailsView> {
text: span,
textDirection: TextDirection.ltr,
maxLines: 4,
)..layout(maxWidth: MediaQuery.sizeOf(context).width - 16);
)..layout(maxWidth: MediaQuery.sizeOf(context).width);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The maxWidth for the TextPainter should account for the horizontal padding of the parent container. The text is rendered within a Padding with symmetric(horizontal: 8), so the available width is MediaQuery.sizeOf(context).width - 16. Using the full screen width might lead to an incorrect calculation of didExceedMaxLines, potentially hiding the '...more' button when the text actually overflows.

Suggested change
)..layout(maxWidth: MediaQuery.sizeOf(context).width);
)..layout(maxWidth: MediaQuery.sizeOf(context).width - 16);


final List<SeasonDto>? seasons =
SortController.instance.sortType == SortType.oldest
Expand Down
33 changes: 33 additions & 0 deletions lib/views/loading_view.dart
Original file line number Diff line number Diff line change
@@ -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: <Widget>[
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,
),
],
),
),
);
}