mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 10:28:50 +01:00
Update naming of the protected push methods in context
This commit is contained in:
parent
dbfca98d6d
commit
340cce297e
2 changed files with 12 additions and 3 deletions
|
@ -28,7 +28,8 @@ class ProtectedPageAuthException implements Exception {
|
|||
}
|
||||
|
||||
extension ProtectedPageBuildContextExtension on NavigatorState {
|
||||
Future<T?> pushReplacementProtected<T extends Object?, U extends Object?>(
|
||||
Future<T?>
|
||||
pushReplacementNamedProtected<T extends Object?, U extends Object?>(
|
||||
String routeName, {
|
||||
U? result,
|
||||
Object? arguments,
|
||||
|
@ -41,7 +42,7 @@ extension ProtectedPageBuildContextExtension on NavigatorState {
|
|||
}
|
||||
}
|
||||
|
||||
Future<T?> pushProtected<T extends Object?>(
|
||||
Future<T?> pushNamedProtected<T extends Object?>(
|
||||
String routeName, {
|
||||
Object? arguments,
|
||||
}) async {
|
||||
|
@ -52,6 +53,14 @@ extension ProtectedPageBuildContextExtension on NavigatorState {
|
|||
}
|
||||
}
|
||||
|
||||
Future<T?> pushProtected<T extends Object?>(Route<T> route) async {
|
||||
if (await _auth()) {
|
||||
return push(route);
|
||||
} else {
|
||||
throw const ProtectedPageAuthException();
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> _auth() async {
|
||||
final securePrefController = context.read<SecurePrefController>();
|
||||
switch (securePrefController.protectedPageAuthTypeValue) {
|
||||
|
|
|
@ -145,7 +145,7 @@ class _SplashState extends State<Splash> {
|
|||
Navigator.pushReplacementNamed(context, SignIn.routeName);
|
||||
} else {
|
||||
Navigator.of(context)
|
||||
.pushReplacementProtected(Home.routeName,
|
||||
.pushReplacementNamedProtected(Home.routeName,
|
||||
arguments: HomeArguments(account))
|
||||
.then((value) async {
|
||||
if (getRawPlatform() == NpPlatform.android) {
|
||||
|
|
Loading…
Reference in a new issue