|
| 1 | +```dart |
| 2 | +//.title |
| 3 | +// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ |
| 4 | +// |
| 5 | +// GENERATED - DO NOT MODIFY BY HAND |
| 6 | +// See: https://github.com/robmllze/df_generate_screen |
| 7 | +// |
| 8 | +// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ |
| 9 | +//.title~ |
| 10 | +
|
| 11 | +// ignore: depend_on_referenced_packages |
| 12 | +import 'package:df_screen/df_screen.dart'; |
| 13 | +
|
| 14 | +import '../v2 copy/_index.g.dart'; |
| 15 | +
|
| 16 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 17 | +
|
| 18 | +/// A list of all screen routes in the app. |
| 19 | +final generatedScreenRoutes = [ |
| 20 | + ___GENERATED_SCREEN_ROUTES___, |
| 21 | +]; |
| 22 | +
|
| 23 | +/// A list of function references. Each function returns a corresponding [Screen] |
| 24 | +/// for a given [ModelScreenConfiguration] or `null` if the given configuration |
| 25 | +/// does not match or access is denied to the screen. |
| 26 | +const SCREEN_MAKERS = [ |
| 27 | + ___SCREEN_MAKERS___, |
| 28 | +]; |
| 29 | +
|
| 30 | +/// Finds the screen that corresponds to [configuration]. It iterates through |
| 31 | +/// the list of screen makers and calls each one with the provided [configuration] |
| 32 | +/// and authentication states ([isLoggedInAndVerified], [isLoggedIn], [isLoggedOut]). |
| 33 | +/// If a screen is found that matches the configuration and is accessible, it is |
| 34 | +/// returned. Otherwise, `null` is returned. |
| 35 | +Screen? findScreenFromConfiguration({ |
| 36 | + required ModelScreenConfiguration configuration, |
| 37 | + required bool? isLoggedInAndVerified, |
| 38 | + required bool? isLoggedIn, |
| 39 | + required bool? isLoggedOut, |
| 40 | +}) { |
| 41 | + for (final screenMaker in SCREEN_MAKERS) { |
| 42 | + final screen = screenMaker.call( |
| 43 | + configuration, |
| 44 | + isLoggedInAndVerified ?? false, |
| 45 | + isLoggedIn ?? false, |
| 46 | + isLoggedOut ?? true, |
| 47 | + ); |
| 48 | + if (screen != null) { |
| 49 | + return screen; |
| 50 | + } |
| 51 | + } |
| 52 | + return null; |
| 53 | +} |
| 54 | +
|
| 55 | +/// Finds the screen that corresponds to [configuration], considering |
| 56 | +/// the user's authentication state ([loggedIn], [verified]). It determines |
| 57 | +/// whether the user is logged in, verified, or logged out, and then calls |
| 58 | +/// `findScreenFromConfiguration` with these states. If a matching screen is |
| 59 | +/// found and accessible, it is returned; otherwise, `null` is returned. |
| 60 | +Screen? findScreenFromConfigurationAndAuthService({ |
| 61 | + required ModelScreenConfiguration configuration, |
| 62 | + required bool loggedIn, |
| 63 | + required bool verified, |
| 64 | +}) { |
| 65 | + final loggedOut = !loggedIn; |
| 66 | + final loggedInAndVerified = loggedIn && verified; |
| 67 | + return findScreenFromConfiguration( |
| 68 | + configuration: configuration, |
| 69 | + isLoggedInAndVerified: loggedInAndVerified, |
| 70 | + isLoggedIn: loggedIn, |
| 71 | + isLoggedOut: loggedOut, |
| 72 | + ); |
| 73 | +} |
| 74 | +
|
| 75 | +/// Translates the current URL into a [ModelScreenConfiguration], considering |
| 76 | +/// the user's authentication state ([loggedIn], [verified]). It calls |
| 77 | +/// `findScreenFromConfigurationAndAuthService` with the current URL's query |
| 78 | +/// parameters and path, along with the user's authentication states. If a |
| 79 | +/// matching screen configuration is found and accessible, it is returned; |
| 80 | +/// otherwise, `null` is returned. |
| 81 | +ModelScreenConfiguration? currentUrlToConfiguration({ |
| 82 | + required bool loggedIn, |
| 83 | + required bool verified, |
| 84 | +}) { |
| 85 | + return findScreenFromConfigurationAndAuthService( |
| 86 | + configuration: ModelScreenConfiguration( |
| 87 | + args: Uri.base.queryParameters, |
| 88 | + path: Uri.base.path, |
| 89 | + ), |
| 90 | + loggedIn: loggedIn, |
| 91 | + verified: verified, |
| 92 | + )?.configuration; |
| 93 | +} |
| 94 | +
|
| 95 | +/// Translates the current URL into a [ModelScreenConfiguration] under the |
| 96 | +/// assumption that the user is logged in and verified. It calls |
| 97 | +/// `findScreenFromConfiguration` with the current URL's query parameters and |
| 98 | +/// path, assuming the user is logged in and verified. If a corresponding |
| 99 | +/// screen is accessible, its configuration is returned; otherwise, `null` is |
| 100 | +/// returned. |
| 101 | +ModelScreenConfiguration? currentUrlToLoginConfiguration() { |
| 102 | + return findScreenFromConfiguration( |
| 103 | + configuration: ModelScreenConfiguration( |
| 104 | + args: Uri.base.queryParameters, |
| 105 | + path: Uri.base.path, |
| 106 | + ), |
| 107 | + isLoggedInAndVerified: true, |
| 108 | + isLoggedIn: true, |
| 109 | + isLoggedOut: false, |
| 110 | + )?.configuration; |
| 111 | +} |
| 112 | +
|
| 113 | +/// Translates the current URL into a [ModelScreenConfiguration] under the |
| 114 | +/// assumption that the user is logged out. It calls `findScreenFromConfiguration` |
| 115 | +/// with the current URL's query parameters and path, assuming the user is |
| 116 | +/// logged out. If a corresponding screen is accessible, its configuration is |
| 117 | +/// returned; otherwise, `null` is returned. |
| 118 | +ModelScreenConfiguration? currentUrlToLogoutConfiguration() { |
| 119 | + return findScreenFromConfiguration( |
| 120 | + configuration: ModelScreenConfiguration( |
| 121 | + args: Uri.base.queryParameters, |
| 122 | + path: Uri.base.path, |
| 123 | + ), |
| 124 | + isLoggedInAndVerified: false, |
| 125 | + isLoggedIn: false, |
| 126 | + isLoggedOut: true, |
| 127 | + )?.configuration; |
| 128 | +} |
| 129 | +``` |
0 commit comments