Updated launch screen
This commit is contained in:
parent
f9e124764f
commit
03d9005c1b
@ -14,7 +14,6 @@ class LaunchScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _LaunchScreenState extends State<LaunchScreen> {
|
class _LaunchScreenState extends State<LaunchScreen> {
|
||||||
late Timer _timer;
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@ -50,7 +49,7 @@ class _LaunchScreenState extends State<LaunchScreen> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
'TeleMedNet',
|
'TelemedNet',
|
||||||
style: Theme.of(context).textTheme.titleLarge,
|
style: Theme.of(context).textTheme.titleLarge,
|
||||||
),
|
),
|
||||||
StreamBuilder(
|
StreamBuilder(
|
||||||
@ -61,26 +60,7 @@ class _LaunchScreenState extends State<LaunchScreen> {
|
|||||||
ConnectionState.waiting) {
|
ConnectionState.waiting) {
|
||||||
return const CircularProgressIndicator();
|
return const CircularProgressIndicator();
|
||||||
} else if (snapshot.hasData) {
|
} else if (snapshot.hasData) {
|
||||||
_timer =
|
_fetchProfileAndNavigate(context);
|
||||||
Timer(const Duration(seconds: 3), () {
|
|
||||||
try {
|
|
||||||
DataService.getProfile()
|
|
||||||
.then((profile) {
|
|
||||||
if (profile == null) {
|
|
||||||
// ignore: use_build_context_synchronously
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushReplacementNamed(
|
|
||||||
RouteNames.userProfile);
|
|
||||||
} else {
|
|
||||||
// ignore: use_build_context_synchronously
|
|
||||||
Navigator.of(context)
|
|
||||||
.pushReplacementNamed(
|
|
||||||
RouteNames.userHome);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} finally {}
|
|
||||||
_timer.cancel();
|
|
||||||
});
|
|
||||||
return _buildProceedingWidget(context);
|
return _buildProceedingWidget(context);
|
||||||
} else {
|
} else {
|
||||||
return _buildSignInSignUpRow(context);
|
return _buildSignInSignUpRow(context);
|
||||||
@ -94,6 +74,19 @@ class _LaunchScreenState extends State<LaunchScreen> {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _fetchProfileAndNavigate(BuildContext context) async {
|
||||||
|
var profile = await DataService.getProfile();
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
if (profile == null) {
|
||||||
|
Navigator.of(context).pushReplacementNamed(RouteNames.userProfile);
|
||||||
|
} else {
|
||||||
|
Navigator.of(context).pushReplacementNamed(RouteNames.userHome);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Widget _buildProceedingWidget(BuildContext context) {
|
Widget _buildProceedingWidget(BuildContext context) {
|
||||||
return const Column(
|
return const Column(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user