mirror of
https://github.com/ErfanRht/MovieLab.git
synced 2026-03-13 10:23:24 +08:00
(add) deeplink to OMDb
This commit is contained in:
@@ -36,6 +36,23 @@
|
||||
android:name="io.flutter.embedding.android.NormalTheme"
|
||||
android:resource="@style/NormalTheme"
|
||||
/>
|
||||
<!-- Deep linking -->
|
||||
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="http" android:host="www.imdb.com" />
|
||||
<data android:scheme="https" android:host="www.imdb.com" />
|
||||
</intent-filter>
|
||||
<!-- App Links -->
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="http" android:host="www.m.imdb.com" />
|
||||
<data android:scheme="https" android:host="www.m.imdb.com" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:get/get.dart';
|
||||
import 'package:hive_flutter/adapters.dart';
|
||||
import 'package:movielab/constants/themes.dart';
|
||||
import 'package:movielab/pages/main/profile/profile_controller.dart';
|
||||
import 'package:movielab/pages/show/show_page/show_page.dart';
|
||||
import 'constants/routes.dart';
|
||||
import 'models/hive/hive_helper/register_adapters.dart';
|
||||
import 'models/hive/models/show_preview.dart';
|
||||
@@ -22,9 +23,16 @@ void main() async {
|
||||
runApp(const App());
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
class App extends StatefulWidget {
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<App> createState() => _AppState();
|
||||
}
|
||||
|
||||
class _AppState extends State<App> {
|
||||
final String initRoute = splashScreenRoute;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
@@ -32,6 +40,21 @@ class App extends StatelessWidget {
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: AppThemes.darkTheme,
|
||||
initialRoute: initRoute,
|
||||
onUnknownRoute: (settings) {
|
||||
// ToDo: Setup deep link for iOS.
|
||||
// ToDo: Improve router for Android(not launched).
|
||||
final matches =
|
||||
RegExp(r'(^\/title\/)(tt\d*)').firstMatch(settings.name.toString());
|
||||
if (matches?.group(1).toString() == "/title/" &&
|
||||
matches?.group(2).toString() != null) {
|
||||
return MaterialPageRoute(
|
||||
builder: (BuildContext context) =>
|
||||
ShowPage(id: matches!.group(2).toString()),
|
||||
);
|
||||
}
|
||||
return MaterialPageRoute(
|
||||
builder: (BuildContext context) => const SplashScreen());
|
||||
},
|
||||
routes: {
|
||||
splashScreenRoute: (context) => const SplashScreen(),
|
||||
homeScreenRoute: (context) => const MainPage(),
|
||||
@@ -51,12 +74,11 @@ Future? initializeHive() async {
|
||||
Hive.openBox<HiveShowPreview>('artists');
|
||||
}
|
||||
|
||||
Future? initializeGetX() {
|
||||
Future? initializeGetX() async {
|
||||
// Initialize the controllers
|
||||
Get.put(MainController());
|
||||
Get.put(HomeDataController());
|
||||
Get.put(SearchBarController());
|
||||
Get.put(ProfileController());
|
||||
Get.put(CacheData());
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import 'get_initial_data.dart';
|
||||
import 'get_user_data.dart';
|
||||
|
||||
class SplashScreen extends StatefulWidget {
|
||||
const SplashScreen({Key? key}) : super(key: key);
|
||||
const SplashScreen({Key? key, this.then}) : super(key: key);
|
||||
final VoidCallback? then;
|
||||
|
||||
@override
|
||||
State<SplashScreen> createState() => _SplashScreenState();
|
||||
|
||||
Reference in New Issue
Block a user