import 'package:flutter/material.dart';

import 'package:together_mobile/common/theme.dart';
import 'package:together_mobile/database/hive_database.dart';
import 'package:together_mobile/router/router.dart';
import 'package:together_mobile/models/init_get_it.dart';
import 'notification_api.dart';

void main() async {
  initGetIt();
  await NotificationAPI.init();
  HiveDatabase.registerAdapter();
  runApp(const Together());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      debugShowCheckedModeBanner: false,
      title: "Together",
      theme: lightThemeData(context),
      darkTheme: darkThemeData(context),
      routerConfig: router,
      // This builder is used to dismiss keyboard while tap anywhere of the
      // screen excluding the input widgets.
      builder: (context, child) {
        return GestureDetector(
          onTap: () {
            if (FocusManager.instance.primaryFocus != null) {
              FocusManager.instance.primaryFocus!.unfocus();
            }
          },
          child: child,
        );
      },
    );
  }
}