|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:firebase_core/firebase_core.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
|
|
|
import 'package:localization/localization.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
import 'package:test_sa/new_views/app_style/app_themes.dart';
|
|
|
|
|
import 'package:test_sa/new_views/pages/land_page/land_page.dart';
|
|
|
|
|
import 'package:test_sa/new_views/pages/login_page.dart';
|
|
|
|
|
import 'package:test_sa/new_views/pages/new_service_request_page.dart';
|
|
|
|
|
import 'package:test_sa/new_views/pages/splash_page.dart';
|
|
|
|
|
|
|
|
|
|
import 'controllers/providers/api/user_provider.dart';
|
|
|
|
|
import 'controllers/providers/settings/setting_provider.dart';
|
|
|
|
|
|
|
|
|
|
void main() async {
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
if (Platform.isIOS) {
|
|
|
|
|
await Firebase.initializeApp(
|
|
|
|
|
options: const FirebaseOptions(
|
|
|
|
|
apiKey: "AIzaSyACQkSleNwU1jzEKR5ho1uSfZERokwwAbc",
|
|
|
|
|
appId: "1:973582662416:ios:bc4a8061444c6a08fbc395",
|
|
|
|
|
messagingSenderId: "973582662416",
|
|
|
|
|
projectId: "atoms-fb912",
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
await Firebase.initializeApp();
|
|
|
|
|
}
|
|
|
|
|
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(statusBarColor: Colors.transparent));
|
|
|
|
|
|
|
|
|
|
/// only portrait mode
|
|
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
|
|
DeviceOrientation.portraitUp,
|
|
|
|
|
DeviceOrientation.portraitDown,
|
|
|
|
|
]);
|
|
|
|
|
runApp(ChangeNotifierProvider(create: (_) => SettingProvider(), child: const MyApp()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
|
const MyApp({Key key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
// This widget is the root of your application.
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
LocalJsonLocalization.delegate.directories = ['assets/translations'];
|
|
|
|
|
final settingProvider = Provider.of<SettingProvider>(context);
|
|
|
|
|
return MultiProvider(
|
|
|
|
|
providers: [
|
|
|
|
|
ChangeNotifierProvider(create: (_) => UserProvider()),
|
|
|
|
|
],
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
onTap: () {
|
|
|
|
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
|
|
|
|
if (!currentFocus.hasPrimaryFocus) {
|
|
|
|
|
FocusManager.instance.primaryFocus.unfocus();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
child: MaterialApp(
|
|
|
|
|
title: 'ATOMS',
|
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
|
theme: settingProvider.theme == "dark" ? AppThemes.darkTheme : AppThemes.lightTheme,
|
|
|
|
|
localizationsDelegates: [
|
|
|
|
|
LocalJsonLocalization.delegate,
|
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
|
],
|
|
|
|
|
supportedLocales: const [Locale('en'), Locale('ar')],
|
|
|
|
|
locale: Locale(settingProvider.language ?? 'en'),
|
|
|
|
|
initialRoute: SplashPage.routeName,
|
|
|
|
|
routes: {
|
|
|
|
|
SplashPage.routeName: (_) => const SplashPage(),
|
|
|
|
|
LoginPage.routeName: (_) => const LoginPage(),
|
|
|
|
|
LandPage.routeName: (_) => const LandPage(),
|
|
|
|
|
NewServiceRequestPage.routeName: (_) => const NewServiceRequestPage(),
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|