2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/domain/entities/setting.dart';
|
|
|
|
|
import 'package:fcs/domain/entities/user.dart';
|
|
|
|
|
import 'package:fcs/pages/main/model/main_model.dart';
|
|
|
|
|
import 'package:fcs/pages/signin/invitation_request_page.dart';
|
|
|
|
|
import 'package:fcs/pages/signin/signup_page.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/bottom_up_page_route.dart';
|
2020-10-14 13:54:42 +06:30
|
|
|
import 'package:flutter/cupertino.dart';
|
2020-09-13 21:49:39 +06:30
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
navigateAfterAuthVerified(BuildContext context) async {
|
|
|
|
|
User user = Provider.of<MainModel>(context, listen: false).user;
|
|
|
|
|
Setting setting = Provider.of<MainModel>(context, listen: false).setting;
|
|
|
|
|
|
2020-09-22 03:52:48 +06:30
|
|
|
if (setting == null) return;
|
2020-09-13 21:49:39 +06:30
|
|
|
|
2020-09-22 03:52:48 +06:30
|
|
|
if (user != null && (user.joined || user.requested)) {
|
2020-09-13 21:49:39 +06:30
|
|
|
Navigator.pushNamedAndRemoveUntil(context, "/home", (r) => false);
|
|
|
|
|
} else {
|
|
|
|
|
if (setting.inviteRequired) {
|
|
|
|
|
bool invited =
|
|
|
|
|
await Provider.of<MainModel>(context, listen: false).hasInvite();
|
|
|
|
|
if (!invited) {
|
|
|
|
|
await Navigator.of(context).pushAndRemoveUntil(
|
2020-10-14 13:54:42 +06:30
|
|
|
CupertinoPageRoute(builder: (context) => RequestInvitationPage()),
|
|
|
|
|
(r) => false);
|
2020-09-13 21:49:39 +06:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-14 13:54:42 +06:30
|
|
|
await Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
|
CupertinoPageRoute(builder: (context) => SignupPage()), (r) => false);
|
2020-09-13 21:49:39 +06:30
|
|
|
}
|
|
|
|
|
}
|