2021-10-26 18:50:34 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2021-06-18 10:29:48 +02:00
|
|
|
import 'package:matrix/matrix.dart';
|
2021-05-23 13:11:55 +02:00
|
|
|
import 'package:vrouter/vrouter.dart';
|
2021-10-26 18:50:34 +02:00
|
|
|
|
|
|
|
import 'package:fluffychat/pages/views/empty_page_view.dart';
|
2021-05-22 08:53:52 +02:00
|
|
|
import 'package:fluffychat/widgets/matrix.dart';
|
2021-01-16 12:46:38 +01:00
|
|
|
|
|
|
|
class LoadingView extends StatelessWidget {
|
2021-10-14 18:09:30 +02:00
|
|
|
const LoadingView({Key key}) : super(key: key);
|
|
|
|
|
2021-01-16 12:46:38 +01:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-09-19 13:48:23 +02:00
|
|
|
if (Matrix.of(context)
|
|
|
|
.widget
|
|
|
|
.clients
|
|
|
|
.every((client) => client.loginState != null)) {
|
2021-06-18 16:15:11 +02:00
|
|
|
WidgetsBinding.instance.addPostFrameCallback(
|
2021-07-08 17:10:20 +02:00
|
|
|
(_) => VRouter.of(context).to(
|
2021-09-19 13:48:23 +02:00
|
|
|
Matrix.of(context)
|
|
|
|
.widget
|
|
|
|
.clients
|
|
|
|
.any((client) => client.loginState == LoginState.loggedIn)
|
2021-05-23 13:11:55 +02:00
|
|
|
? '/rooms'
|
2021-06-18 16:15:11 +02:00
|
|
|
: '/home',
|
|
|
|
queryParameters: VRouter.of(context).queryParameters,
|
|
|
|
),
|
|
|
|
);
|
2021-01-17 08:05:34 +01:00
|
|
|
}
|
2021-10-14 18:09:30 +02:00
|
|
|
return const EmptyPage(loading: true);
|
2021-01-16 12:46:38 +01:00
|
|
|
}
|
|
|
|
}
|