import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart';
import 'package:pdfrx/pdfrx.dart';

import 'login_page.dart';

Future<void> main() async {
  Logger.root.level = Level.ALL; // defaults to Level.INFO
  Logger.root.onRecord.listen((record) {
    debugPrint('${record.level.name}: ${record.time}: ${record.message}');
    if (record.error != null) {
      debugPrint('${record.error}');
    }
  });

  pdfrxFlutterInitialize(); // Needed especially for web

  if (!kIsWeb) {
    Directory dir = await getApplicationDocumentsDirectory();
    Hive.init(dir.path); // Needed only if not web
  }

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Sheetless',
      theme: ThemeData(useMaterial3: true, primarySwatch: Colors.blue),
      home: const LoginPage(),
    );
  }
}
