import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:siro_service/controller/firbase_messge.dart';
import 'package:siro_service/firebase_options.dart';

import 'controller/functions/encrypt_decrypt.dart';
import 'controller/local/local_controller.dart';
import 'controller/local/translations.dart';
import 'login_page.dart';

final box = GetStorage();
const storage = FlutterSecureStorage();

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await GetStorage.init();

  await EncryptionHelper.initialize();

  if (Firebase.apps.isEmpty) {
    await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform);
  } else {
    Firebase.app();
  }
  Get.put(FirebaseMessagesController()).getToken();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  MyApp({super.key});
  LocaleController localController = Get.put(LocaleController());

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      title: 'Inatleq Service'.tr,
      debugShowCheckedModeBanner: false,
      translations: MyTranslation(),
      locale: localController.language,
      theme: localController.appTheme,
      key: UniqueKey(),
      home: LoginPage(),
    );
  }
}
