2019-04-23 16:11:19 +00:00
|
|
|
import 'package:comunic/helpers/account_helper.dart';
|
2019-04-24 09:24:05 +00:00
|
|
|
import 'package:comunic/helpers/database/database_helper.dart';
|
2019-04-22 17:16:26 +00:00
|
|
|
import 'package:comunic/ui/routes/home_route.dart';
|
|
|
|
import 'package:comunic/ui/routes/login_route.dart';
|
|
|
|
import 'package:comunic/utils/ui_utils.dart';
|
2019-04-21 08:34:27 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
/// Main file of the application
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
2019-06-24 16:05:30 +00:00
|
|
|
void subMain() {
|
2019-04-24 09:24:05 +00:00
|
|
|
// Connect to database
|
|
|
|
DatabaseHelper.open();
|
|
|
|
|
2019-04-21 08:34:27 +00:00
|
|
|
runApp(ComunicApplication());
|
|
|
|
}
|
|
|
|
|
|
|
|
class ComunicApplication extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
2019-04-21 09:44:07 +00:00
|
|
|
debugShowCheckedModeBanner: false,
|
2019-04-22 17:16:26 +00:00
|
|
|
home: ComunicApplicationHome(),
|
2019-04-21 08:34:27 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-04-22 17:16:26 +00:00
|
|
|
|
|
|
|
class ComunicApplicationHome extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() => _ComunicApplicationHomeState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ComunicApplicationHomeState extends State<ComunicApplicationHome> {
|
|
|
|
bool _signedIn;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
2019-04-23 16:11:19 +00:00
|
|
|
AccountHelper().signedIn().then((v) {
|
2019-04-22 17:16:26 +00:00
|
|
|
setState(() {
|
|
|
|
_signedIn = v;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
if (_signedIn == null) return buildLoadingPage();
|
|
|
|
|
|
|
|
if (_signedIn)
|
|
|
|
return HomeRoute();
|
|
|
|
else
|
|
|
|
return LoginRoute();
|
|
|
|
}
|
|
|
|
}
|