mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 12:59:21 +00:00
Remove a useless widget
This commit is contained in:
parent
db52c495ec
commit
6d95d5f7a2
@ -4,7 +4,6 @@ import 'package:comunic/helpers/preferences_helper.dart';
|
||||
import 'package:comunic/ui/routes/login_route.dart';
|
||||
import 'package:comunic/ui/widgets/init_widget.dart';
|
||||
import 'package:comunic/utils/intl_utils.dart';
|
||||
import 'package:comunic/utils/ui_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Main file of the application
|
||||
@ -21,55 +20,34 @@ void subMain() async {
|
||||
// Get current system language
|
||||
await initTranslations();
|
||||
|
||||
// Check if the user is currently signed in
|
||||
final signedIn = await AccountHelper().signedIn();
|
||||
|
||||
runApp(ComunicApplication(
|
||||
darkMode: (await PreferencesHelper.getInstance())
|
||||
.getBool(PreferencesKeyList.ENABLE_DARK_THEME),
|
||||
signedIn: signedIn,
|
||||
));
|
||||
}
|
||||
|
||||
class ComunicApplication extends StatelessWidget {
|
||||
final bool darkMode;
|
||||
final bool signedIn;
|
||||
|
||||
const ComunicApplication({Key key, @required this.darkMode})
|
||||
: assert(darkMode != null),
|
||||
const ComunicApplication({
|
||||
Key key,
|
||||
@required this.darkMode,
|
||||
@required this.signedIn,
|
||||
}) : assert(darkMode != null),
|
||||
assert(signedIn != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: ComunicApplicationHome(),
|
||||
home: signedIn ? InitializeWidget() : LoginRoute(),
|
||||
theme: darkMode ? ThemeData.dark() : ThemeData.light(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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 InitializeWidget();
|
||||
else
|
||||
return LoginRoute();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user