// import 'package:barcode_scan/barcode_scan.dart';
import 'dart:io';

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:hive/hive.dart';
import 'package:path_provider/path_provider.dart';
import 'app.dart';
import 'data/repository/auth_repository.dart';
import 'environment/app_config.dart';

final GlobalKey<NavigatorState> globalNavigator = GlobalKey<NavigatorState>();
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  Firebase.initializeApp();
  // if (Platform.isAndroid) {
  //   await Firebase.initializeApp(
  //     options: DefaultFirebaseOptions.currentPlatform,
  //   );
  // } else {
  //   await Firebase.initializeApp();
  // }
  // await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(alert: true, badge: true, sound: true);
  // FirebaseMessaging.onBackgroundMessage(FirebaseMessages.firebaseMessagingBackgroundHandler);
  // FirebaseMessaging.onMessageOpenedApp.listen(FirebaseMessages.firebaseMessagingBackgroundHandler);

  await SystemChrome.setPreferredOrientations([
    DeviceOrientation.portraitDown,
    DeviceOrientation.portraitUp,
  ]);
  setFlavorDevelopment();
  final appDocumentDirectory = await getApplicationDocumentsDirectory();
  Hive..init(appDocumentDirectory.path);
  await Hive.openBox('LocalDBName');
  runApp(App(
    authenticationRepository: AuthenticationRepository(),
  ));
}
