2023-06-21 17:44:28 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2024-03-16 16:46:53 +08:00
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
2024-04-11 17:27:45 +08:00
|
|
|
import 'package:together_mobile/utils/env.dart';
|
2024-03-16 16:46:53 +08:00
|
|
|
|
2024-04-09 17:23:28 +08:00
|
|
|
import '/common/theme.dart';
|
|
|
|
import '/database/hive_database.dart';
|
|
|
|
import '/router/router.dart';
|
|
|
|
import '/models/init_get_it.dart';
|
2023-09-09 16:48:47 +08:00
|
|
|
import 'notification_api.dart';
|
2023-06-21 17:44:28 +08:00
|
|
|
|
2024-03-16 16:46:53 +08:00
|
|
|
final easyLoading = EasyLoading.init();
|
|
|
|
|
2023-09-09 16:48:47 +08:00
|
|
|
void main() async {
|
2024-04-11 17:27:45 +08:00
|
|
|
await EnvConfig.loadEnv(Env.product);
|
2023-07-11 23:39:36 +08:00
|
|
|
initGetIt();
|
2023-09-10 11:30:20 +08:00
|
|
|
await NotificationAPI.init();
|
|
|
|
HiveDatabase.registerAdapter();
|
2023-06-21 17:44:28 +08:00
|
|
|
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) {
|
2024-03-16 16:46:53 +08:00
|
|
|
child = easyLoading(context, child);
|
|
|
|
child = GestureDetector(
|
2023-09-10 11:30:20 +08:00
|
|
|
onTap: () {
|
|
|
|
if (FocusManager.instance.primaryFocus != null) {
|
|
|
|
FocusManager.instance.primaryFocus!.unfocus();
|
|
|
|
}
|
|
|
|
},
|
2023-06-21 17:44:28 +08:00
|
|
|
child: child,
|
|
|
|
);
|
2024-03-16 16:46:53 +08:00
|
|
|
return child;
|
2023-06-21 17:44:28 +08:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|