mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-29 16:26:27 +00:00
69 lines
1.6 KiB
Dart
69 lines
1.6 KiB
Dart
import 'package:comunic/helpers/account_helper.dart';
|
|
import 'package:comunic/helpers/database/database_helper.dart';
|
|
import 'package:comunic/models/config.dart';
|
|
import 'package:comunic/ui/routes/home_route.dart';
|
|
import 'package:comunic/ui/routes/login_route.dart';
|
|
import 'package:comunic/utils/ui_utils.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// Main file of the application
|
|
///
|
|
/// @author Pierre HUBERT
|
|
|
|
void main() {
|
|
/// Initialize application configuration
|
|
///
|
|
// TODO : Adapt to production
|
|
Config.set(Config(
|
|
apiServerName: "devweb.local",
|
|
apiServerUri: "/comunic/api/",
|
|
apiServerSecure: false,
|
|
serviceName: "ComunicFlutter",
|
|
serviceToken: "G9sZCBmb3IgVWJ1bnR1CkNvbW1lbnRbbmVdPeCkieCkrOCkq"));
|
|
|
|
// Connect to database
|
|
DatabaseHelper.open();
|
|
|
|
runApp(ComunicApplication());
|
|
}
|
|
|
|
class ComunicApplication extends StatelessWidget {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
home: ComunicApplicationHome(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ComunicApplicationHome extends StatefulWidget {
|
|
@override
|
|
State<StatefulWidget> createState() => _ComunicApplicationHomeState();
|
|
}
|
|
|
|
class _ComunicApplicationHomeState extends State<ComunicApplicationHome> {
|
|
bool _signedIn;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
|
|
AccountHelper().signedIn().then((v) {
|
|
setState(() {
|
|
_signedIn = v;
|
|
});
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (_signedIn == null) return buildLoadingPage();
|
|
|
|
if (_signedIn)
|
|
return HomeRoute();
|
|
else
|
|
return LoginRoute();
|
|
}
|
|
}
|