|
| 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 | +part of '___CLASS_FILE___'; |
| 12 | +
|
| 13 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 14 | +
|
| 15 | +final _globalKey = GlobalKey<_View>(); |
| 16 | +
|
| 17 | +/// Serves as the blueprint for the [___CLASS___] screen. |
| 18 | +/// It outlines the screen's properties and behaviors prior to routing. |
| 19 | +class ___CONFIGURATION_CLASS___ extends ModelScreenConfiguration { |
| 20 | + // |
| 21 | + // |
| 22 | + // |
| 23 | +
|
| 24 | + ___IP0___ |
| 25 | + ___QP0___ |
| 26 | +
|
| 27 | + factory ___CONFIGURATION_CLASS___({ |
| 28 | + ___IP1___ |
| 29 | + ___QP1___ |
| 30 | + Map<dynamic, dynamic>? $args, |
| 31 | + }) { |
| 32 | + return ___CONFIGURATION_CLASS___.c2( |
| 33 | + args: { |
| 34 | + ___IP2___ |
| 35 | + ___QP2___ |
| 36 | + ...?$args, |
| 37 | + }.nonNulls, |
| 38 | + ); |
| 39 | + } |
| 40 | +
|
| 41 | + // |
| 42 | + // |
| 43 | + // |
| 44 | +
|
| 45 | + ___CONFIGURATION_CLASS___.c2({ |
| 46 | + Map<dynamic, dynamic>? args, |
| 47 | + }): super.c2( |
| 48 | + title: translatedTitle, |
| 49 | + path: _PATH, |
| 50 | + args: args ?? {}, |
| 51 | + isAccessibleOnlyIfLoggedInAndVerified: _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED, |
| 52 | + isAccessibleOnlyIfLoggedIn: _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN, |
| 53 | + isAccessibleOnlyIfLoggedOut: _IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT, |
| 54 | + isRedirectable: _IS_REDIRECTABLE, |
| 55 | + ); |
| 56 | +
|
| 57 | + // |
| 58 | + // |
| 59 | + // |
| 60 | +
|
| 61 | + @override |
| 62 | + String get title => translatedTitle; |
| 63 | +
|
| 64 | + // |
| 65 | + // |
| 66 | + // |
| 67 | +
|
| 68 | + /// The name of the corresponding [Screen] class. |
| 69 | + static const CLASS = _CLASS; |
| 70 | +
|
| 71 | + /// The path of the corresponding [Screen]. |
| 72 | + static const PATH = _PATH; |
| 73 | +
|
| 74 | + /// The segment of the corresponding [Screen] path. |
| 75 | + static const SEGMENT = _SEGMENT; |
| 76 | +
|
| 77 | + /// The translation key for the corresponding [Screen]. |
| 78 | + static const TR_KEY = _TR_KEY; |
| 79 | +
|
| 80 | + /// Whether the corresponding [Screen] is only accessible if the user is logged in and verified. |
| 81 | + static const IS_ACCESSIBLE_ONLY_IF_LOGGED_IN = _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN; |
| 82 | +
|
| 83 | + /// Whether the corresponding [Screen] is only accessible if the user is logged in. |
| 84 | + static const IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED = _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED; |
| 85 | +
|
| 86 | + /// Whether the corresponding [Screen] is only accessible if the user is logged out. |
| 87 | + static const IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT = _IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT; |
| 88 | +
|
| 89 | + /// Whether the corresponding [Screen] is redirectable, i.e., if it can be requested from the browser URL. |
| 90 | + static const IS_REDIRECTABLE = _IS_REDIRECTABLE; |
| 91 | +
|
| 92 | + /// The title of the corresponding [Screen]. |
| 93 | + static String get translatedTitle => screenTr('$_DEFAULT_TITLE||title'); |
| 94 | +
|
| 95 | + /// Translates the provided [key] using the screen's translation key. |
| 96 | + static String screenTr(String key, {Map<dynamic, dynamic> args = const {}}) { |
| 97 | + return key.splitByLastOccurrenceOf('||').join('||$_TR_KEY.').tr(args: args); |
| 98 | + } |
| 99 | +} |
| 100 | +
|
| 101 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 102 | +
|
| 103 | +/// Extend this class to create a controller for the [___CLASS___] screen. |
| 104 | +abstract base class _ControllerBroker<T1 extends ___CLASS___, T2 extends _View> |
| 105 | + extends ScreenController<___CONFIGURATION_CLASS___> { |
| 106 | +
|
| 107 | + /// The [Screen] that corresponds to `this` controller. |
| 108 | + late final screen = super.superScreen as T1; |
| 109 | +
|
| 110 | + /// The [State] that corresponds to `this` controller. |
| 111 | + late final state = super.superState as T2; |
| 112 | +
|
| 113 | + /// The [ModelScreenConfiguration] that corresponds to `this` controller. |
| 114 | + late final configuration = super.internalConfiguration ?? ___CONFIGURATION_CLASS___.c2( |
| 115 | + args: screen.configuration?.args, |
| 116 | + ); |
| 117 | +
|
| 118 | + _ControllerBroker( |
| 119 | + super.superScreen, |
| 120 | + super.superState, [ |
| 121 | + super.internalConfiguration, |
| 122 | + ]); |
| 123 | +} |
| 124 | +
|
| 125 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 126 | +
|
| 127 | +/// The generated [GoRoute] that corresponds to [___CLASS___]. |
| 128 | +final generated___CLASS___Route = GoRoute( |
| 129 | + path: _SEGMENT, |
| 130 | + pageBuilder: (context, state) { |
| 131 | + final extraConfiguration = letAs<ModelScreenConfiguration>(state.extra); |
| 132 | + final urlConfiguration = urlToScreenConfiguration( |
| 133 | + url: state.uri, |
| 134 | + isAccessibleOnlyIfLoggedIn: ___CONFIGURATION_CLASS___.IS_ACCESSIBLE_ONLY_IF_LOGGED_IN, |
| 135 | + isAccessibleOnlyIfLoggedInAndVerified: ___CONFIGURATION_CLASS___.IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED, |
| 136 | + isAccessibleOnlyIfLoggedOut: ___CONFIGURATION_CLASS___.IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT, |
| 137 | + isRedirectable: ___CONFIGURATION_CLASS___.IS_REDIRECTABLE, |
| 138 | + title: ___CONFIGURATION_CLASS___.translatedTitle, |
| 139 | + ); |
| 140 | + final configuration = extraConfiguration ?? urlConfiguration; |
| 141 | + return NoTransitionPage( |
| 142 | + key: state.pageKey, |
| 143 | + child: ___CLASS___( |
| 144 | + key: _globalKey, |
| 145 | + configuration: configuration, |
| 146 | + ), |
| 147 | + ); |
| 148 | + }, |
| 149 | +); |
| 150 | +
|
| 151 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 152 | +
|
| 153 | +extension _ScreenTr on String { |
| 154 | + /// Translates this [String] using the translation key '_TR_KEY'. Optionally, |
| 155 | + /// pass [args] to replace placeholders in this String denoted by `{key}` in |
| 156 | + /// the translation. |
| 157 | + // ignore: unused_element |
| 158 | + String screenTr({Map<dynamic, dynamic> args = const {}}) { |
| 159 | + return ___CONFIGURATION_CLASS___.screenTr(this, args: args); |
| 160 | + } |
| 161 | +} |
| 162 | +
|
| 163 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 164 | +
|
| 165 | +/// Returns a [___CLASS___] instance if the [configuration] is of type |
| 166 | +/// [___CONFIGURATION_CLASS___] and if the current authentication status matches |
| 167 | +/// [isLoggedInAndVerified], [isLoggedIn], and [isLoggedOut]. |
| 168 | +Screen? maker___CLASS___( |
| 169 | + ModelScreenConfiguration configuration, |
| 170 | + bool isLoggedInAndVerified, |
| 171 | + bool isLoggedIn, |
| 172 | + bool isLoggedOut, |
| 173 | +) { |
| 174 | + if ((_IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED && !isLoggedInAndVerified) || (_IS_ACCESSIBLE_ONLY_IF_LOGGED_IN && !isLoggedIn) || (_IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT && !isLoggedOut)) { |
| 175 | + return null; |
| 176 | + } |
| 177 | + if (configuration is ___CONFIGURATION_CLASS___) { |
| 178 | + return ___CLASS___( |
| 179 | + key: _globalKey, |
| 180 | + configuration: configuration, |
| 181 | + ); |
| 182 | + } |
| 183 | + if (RegExp(r'^(' + _PATH + r')([?/].*)?$') |
| 184 | + .hasMatch(Uri.decodeComponent(configuration.path ?? ''))) { |
| 185 | + final temp = ___CONFIGURATION_CLASS___.c2( |
| 186 | + args: configuration.args, |
| 187 | + ); |
| 188 | + return ___CLASS___( |
| 189 | + key: _globalKey, |
| 190 | + configuration: temp, |
| 191 | + ); |
| 192 | + } |
| 193 | + return null; |
| 194 | +} |
| 195 | +
|
| 196 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 197 | +
|
| 198 | +/// The controller [Type] corresponding to [___CLASS___]. |
| 199 | +typedef T___CLASS___Controller = _ControllerBroker<___CLASS___, _View>; |
| 200 | +
|
| 201 | +/// The [ScreenView] [Type] corresponding to [___CLASS___]. |
| 202 | +typedef T___CLASS___View = ScreenView<___CLASS___, ___CONFIGURATION_CLASS___, ___CLASS___Controller>; |
| 203 | +
|
| 204 | +/// The [ScreenPageView] [Type] corresponding to [___CLASS___]. |
| 205 | +typedef T___CLASS___PageView<T extends ScreenPage> = ScreenPageView<T, ___CONFIGURATION_CLASS___, ___CLASS___Controller>; |
| 206 | +
|
| 207 | +
|
| 208 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 209 | +
|
| 210 | +// The following constants are set by the generator based on the provided |
| 211 | +// options. Together they form the behavior of the generated screen. |
| 212 | +
|
| 213 | +const _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED = ___IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED___; |
| 214 | +const _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN = ___IS_ACCESSIBLE_ONLY_IF_LOGGED_IN___; |
| 215 | +const _IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT = ___IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT___; |
| 216 | +const _IS_REDIRECTABLE = ___IS_REDIRECTABLE___; |
| 217 | +const _CLASS = '___CLASS___'; |
| 218 | +const _SEGMENT = '___SCREEN_SEGMENT___'; |
| 219 | +const _PATH = '/$_SEGMENT'; |
| 220 | +const _TR_KEY = 'screens.___CLASS___'; |
| 221 | +const _DEFAULT_TITLE = '___DEFAULT_TITLE___'; |
| 222 | +``` |
0 commit comments