You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
107 lines
4.0 KiB
107 lines
4.0 KiB
import 'package:camera/camera.dart';
|
|
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
|
|
import 'package:flutter_libphonenumber/flutter_libphonenumber.dart';
|
|
import 'package:no_context_navigation/no_context_navigation.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:teso/Pages/Sub_Pages/LandingPage/Login.dart';
|
|
import 'package:teso/Services/locator.dart';
|
|
import 'package:teso/main_screen.dart';
|
|
import 'package:teso/providers/app_provider.dart';
|
|
import 'package:teso/providers/referral_provider.dart';
|
|
import 'package:teso/providers/user_provider.dart';
|
|
import 'package:teso/providers/device_provider.dart';
|
|
import 'package:teso/resetpassword.dart';
|
|
import 'package:teso/util/consts.dart';
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'Pages/splash.dart';
|
|
import 'Services/uservideo_controller_service.dart';
|
|
import 'Services/video_controller_service.dart' as ma;
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await Firebase.initializeApp();
|
|
await FlutterLibphonenumber().init();
|
|
// Initialize Firebase.
|
|
setupLocator();
|
|
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
|
|
runApp(
|
|
MultiProvider(
|
|
providers: [
|
|
ChangeNotifierProvider(create: (_) => AppProvider()),
|
|
ChangeNotifierProvider(create: (_) => UserProvider()),
|
|
ChangeNotifierProvider(create: (_) => DeviceProvider()),
|
|
ChangeNotifierProvider(create: (_) => ReferralProvider()),
|
|
RepositoryProvider<VideoControllerService>(
|
|
create: (context) =>
|
|
CachedVideoControllerService(DefaultCacheManager()),
|
|
),
|
|
RepositoryProvider<ma.VideoControllerService>(
|
|
create: (context) =>
|
|
ma.CachedVideoControllerService(DefaultCacheManager()),
|
|
),
|
|
],
|
|
child: MyApp(),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
|
// If you're going to use other Firebase services in the background, such as Firestore,
|
|
// make sure you call `initializeApp` before using other Firebase services.
|
|
await Firebase.initializeApp();
|
|
}
|
|
|
|
class MyApp extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
|
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
|
statusBarColor: Theme.of(context).primaryColor.withOpacity(0.7),
|
|
// systemNavigationBarColor: Colors.black,
|
|
));
|
|
return Consumer<AppProvider>(
|
|
builder: (_, AppProvider appProvider, __) {
|
|
return MaterialApp(
|
|
key: appProvider.key,
|
|
debugShowCheckedModeBanner: false,
|
|
navigatorKey: NavigationService.navigationKey,
|
|
title: Constants.appName,
|
|
theme: appProvider.theme,
|
|
home: Splash(),
|
|
onGenerateRoute: (RouteSettings settings) {
|
|
switch (settings.name) {
|
|
case '/':
|
|
return MaterialPageRoute(builder: (_) => MainScreens());
|
|
case '/resetpassword':
|
|
return MaterialPageRoute(
|
|
builder: (_) => ResetPassword(resetID: settings.arguments));
|
|
case "/login":
|
|
List<CameraDescription> cameras;
|
|
availableCameras().then((value) {
|
|
cameras = value;
|
|
});
|
|
return MaterialPageRoute(
|
|
builder: (_) => LoginPage(
|
|
referrer: settings.arguments,
|
|
connectedCameras: cameras,
|
|
),
|
|
);
|
|
default:
|
|
return null;
|
|
}
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|
|
|
|
// Future<void> _firebaseMessagingBackgroundHandler(
|
|
// RemoteMessage message, data) async {
|
|
// // print('Handling a background message ${message.messageId}');
|
|
// data = message.data["senderID"];
|
|
// }
|
|
|