This commit is contained in:
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:encrypt_shared_preferences/provider.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:f0ckapp/services/api.dart';
|
||||
import 'package:f0ckapp/controller/authcontroller.dart';
|
||||
import 'package:f0ckapp/controller/localizationcontroller.dart';
|
||||
import 'package:f0ckapp/controller/themecontroller.dart';
|
||||
@ -14,11 +15,17 @@ import 'package:f0ckapp/screens/login.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await EncryptedSharedPreferencesAsync.initialize('VokTnbAbemBUa2j9');
|
||||
await MyTranslations.loadTranslations();
|
||||
await AppVersion.init();
|
||||
|
||||
await Future.wait([
|
||||
EncryptedSharedPreferencesAsync.initialize('VokTnbAbemBUa2j9'),
|
||||
MyTranslations.loadTranslations(),
|
||||
AppVersion.init(),
|
||||
]);
|
||||
|
||||
Get.put(AuthController());
|
||||
final MediaController mediaController = Get.put(MediaController());
|
||||
Get.put(ApiService());
|
||||
Get.put(MediaController());
|
||||
|
||||
final ThemeController themeController = Get.put(ThemeController());
|
||||
final LocalizationController localizationController = Get.put(
|
||||
LocalizationController(),
|
||||
@ -41,7 +48,7 @@ void main() async {
|
||||
final Uri uri = Uri.parse(settings.name ?? '/');
|
||||
|
||||
if (uri.path == '/' || uri.pathSegments.isEmpty) {
|
||||
return MaterialPageRoute(builder: (_) => MediaGrid());
|
||||
return MaterialPageRoute(builder: (_) => const MediaGrid());
|
||||
}
|
||||
|
||||
if (uri.path == '/login') {
|
||||
@ -49,26 +56,17 @@ void main() async {
|
||||
}
|
||||
|
||||
if (uri.pathSegments.length == 1) {
|
||||
final int id = int.parse(uri.pathSegments.first);
|
||||
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => FutureBuilder(
|
||||
future: mediaController.items.isEmpty
|
||||
? mediaController.fetchInitial(id: id)
|
||||
: Future.value(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.connectionState == ConnectionState.done) {
|
||||
return MediaDetailScreen(initialId: id);
|
||||
}
|
||||
return const Scaffold(
|
||||
body: Center(child: CircularProgressIndicator()),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
try {
|
||||
final int id = int.parse(uri.pathSegments.first);
|
||||
return MaterialPageRoute(
|
||||
builder: (_) => MediaDetailScreen(initialId: id),
|
||||
);
|
||||
} catch (e) {
|
||||
return MaterialPageRoute(builder: (_) => const MediaGrid());
|
||||
}
|
||||
}
|
||||
|
||||
return MaterialPageRoute(builder: (_) => MediaGrid());
|
||||
return MaterialPageRoute(builder: (_) => const MediaGrid());
|
||||
},
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user