import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_map_tile_caching/flutter_map_tile_caching.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:rogapp/pages/index/index_binding.dart';
import 'package:rogapp/routes/app_pages.dart';
import 'package:rogapp/utils/string_values.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:path/path.dart' as p;

void main() async {
  
  WidgetsFlutterBinding.ensureInitialized();
  
  FlutterMapTileCaching.initialise(await RootDirectory.normalCache);
  final StoreDirectory instanceA = FMTC.instance('OpenStreetMap (A)');
    await instanceA.manage.createAsync();
    await instanceA.metadata.addAsync(
      key: 'sourceURL',
      value: 'https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png',
    );
    await instanceA.metadata.addAsync(
      key: 'validDuration',
      value: '14',
    );
    await instanceA.metadata.addAsync(
      key: 'behaviour',
      value: 'cacheFirst',
    );

  runApp(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) {
    return GetMaterialApp(
      translations: StringValues(),
      locale: const Locale('ja', 'JP'),
      //locale: const Locale('en', 'US'),
      fallbackLocale: const Locale('en', 'US'),
      title: 'ROGAINING',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
        textTheme: GoogleFonts.muliTextTheme(),
      ),
      debugShowCheckedModeBanner: false,
      defaultTransition: Transition.cupertino,
      opaqueRoute: Get.isOpaqueRouteDefault,
      popGesture: Get.isPopGestureEnable,
      transitionDuration: const Duration(milliseconds: 230),
      initialBinding: IndexBinding(), //HomeBinding(),
      initialRoute: AppPages.PERMISSION,
      getPages: AppPages.routes,
      enableLog: true,
    );
  }
}



// class MyApp extends StatelessWidget {
//   MyApp({Key? key}) : super(key: key);

//   // This widget is the root of your application.
//   @override
//   Widget build(BuildContext context) {
//     return MaterialApp(
//       title: 'Flutter Demo',
//       theme: ThemeData(
//         primaryColor: Color(0xfff00B074),
//         textTheme: const TextTheme(
//           bodyText1: TextStyle(
//               fontSize: 18.0,
//               fontFamily: 'Barlow-Medium',
//               color: Color(0xff464255)),
//         ),
//       ),
//       home: PermissionHandlerScreen(),
//     );
//   }
// }




// class SplashScreen extends StatelessWidget {
//   const SplashScreen({Key? key}) : super(key: key);

//   @override
//   Widget build(BuildContext context) {
//     return WillPopScope(
//       onWillPop: () async {
//         SystemNavigator.pop();
//         return true;
//       },
//       child: Scaffold(
//         body: Center(
//           child: Text(
//             "Splash Screen",
//           ),
//         ),
//       ),
//     );
//   }
// }
