|
| 1 | +//.title |
| 2 | +// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ |
| 3 | +// |
| 4 | +// GENERATED - DO NOT MODIFY BY HAND |
| 5 | +// See: https://github.com/DevCetra/df_generate_screen |
| 6 | +// |
| 7 | +// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ |
| 8 | +//.title~ |
| 9 | + |
| 10 | +// ignore_for_file: unused_element |
| 11 | + |
| 12 | +part of 'widget.dart'; |
| 13 | + |
| 14 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 15 | + |
| 16 | +final _globalKey = GlobalKey<_State>(); |
| 17 | + |
| 18 | +/// Serves as the blueprint for the [___WIDGET_NAME___] screen. |
| 19 | +/// It outlines the screen's properties and behaviors prior to routing. |
| 20 | +class ___WIDGET_NAME___Configuration extends ModelScreenConfiguration { |
| 21 | + // |
| 22 | + // |
| 23 | + // |
| 24 | + |
| 25 | + factory ___WIDGET_NAME___Configuration({ |
| 26 | + Map<dynamic, dynamic>? $args, |
| 27 | + }) { |
| 28 | + return ___WIDGET_NAME___Configuration.optional( |
| 29 | + args: { |
| 30 | + ...?$args, |
| 31 | + }.nonNulls, |
| 32 | + ); |
| 33 | + } |
| 34 | + |
| 35 | + // |
| 36 | + // |
| 37 | + // |
| 38 | + |
| 39 | + ___WIDGET_NAME___Configuration.optional({ |
| 40 | + Map<dynamic, dynamic>? args, |
| 41 | + }) : super.optional( |
| 42 | + title: null, |
| 43 | + path: _PATH, |
| 44 | + args: args ?? {}, |
| 45 | + isAccessibleOnlyIfLoggedInAndVerified: |
| 46 | + _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED, |
| 47 | + isAccessibleOnlyIfLoggedIn: _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN, |
| 48 | + isAccessibleOnlyIfLoggedOut: _IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT, |
| 49 | + isRedirectable: _IS_REDIRECTABLE, |
| 50 | + ); |
| 51 | + |
| 52 | + // |
| 53 | + // |
| 54 | + // |
| 55 | + |
| 56 | + /// The name of the corresponding [Screen] class. |
| 57 | + static const WIDGET = _CLASS; |
| 58 | + |
| 59 | + /// The path of the corresponding [Screen]. |
| 60 | + static const PATH = _PATH; |
| 61 | + |
| 62 | + /// The segment of the corresponding [Screen] path. |
| 63 | + static const SEGMENT = _SEGMENT; |
| 64 | + |
| 65 | + /// The translation key for the corresponding [Screen]. |
| 66 | + static const TR_KEY = _TR_KEY; |
| 67 | + |
| 68 | + /// Whether the corresponding [Screen] is only accessible if the user is logged in and verified. |
| 69 | + static const IS_ACCESSIBLE_ONLY_IF_LOGGED_IN = |
| 70 | + _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN; |
| 71 | + |
| 72 | + /// Whether the corresponding [Screen] is only accessible if the user is logged in. |
| 73 | + static const IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED = |
| 74 | + _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED; |
| 75 | + |
| 76 | + /// Whether the corresponding [Screen] is only accessible if the user is logged out. |
| 77 | + static const IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT = |
| 78 | + _IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT; |
| 79 | + |
| 80 | + /// Whether the corresponding [Screen] is redirectable, i.e., if it can be requested from the browser URL. |
| 81 | + static const IS_REDIRECTABLE = _IS_REDIRECTABLE; |
| 82 | +} |
| 83 | + |
| 84 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 85 | + |
| 86 | +/// Extend this class to create a controller for the [___WIDGET_NAME___] screen. |
| 87 | +abstract base class _ControllerBroker<T1 extends ___WIDGET_NAME___, |
| 88 | + T2 extends _State> |
| 89 | + extends ScreenController<___WIDGET_NAME___Configuration> { |
| 90 | + /// The [Screen] that corresponds to `this` controller. |
| 91 | + late final screen = super.superScreen as T1; |
| 92 | + |
| 93 | + /// The [State] that corresponds to `this` controller. |
| 94 | + late final state = super.superState as T2; |
| 95 | + |
| 96 | + /// The [ModelScreenConfiguration] that corresponds to `this` controller. |
| 97 | + late final configuration = screen.extra is ___WIDGET_NAME___Configuration |
| 98 | + ? screen.extra as ___WIDGET_NAME___Configuration |
| 99 | + : ___WIDGET_NAME___Configuration.optional( |
| 100 | + args: screen.extra is ModelScreenConfiguration |
| 101 | + ? (screen.extra as ModelScreenConfiguration).args |
| 102 | + : {}, |
| 103 | + ); |
| 104 | + |
| 105 | + _ControllerBroker( |
| 106 | + super.superScreen, |
| 107 | + super.superState, [ |
| 108 | + super.extra, |
| 109 | + ]); |
| 110 | +} |
| 111 | + |
| 112 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 113 | + |
| 114 | +/// The generated [GoRoute] that corresponds to [___WIDGET_NAME___]. |
| 115 | +final generated___WIDGET_NAME___Route = GoRoute( |
| 116 | + path: _SEGMENT, |
| 117 | + pageBuilder: (context, state) { |
| 118 | + final extra = letAsOrNull<ModelScreenConfiguration>(state.extra); |
| 119 | + return NoTransitionPage( |
| 120 | + key: state.pageKey, |
| 121 | + child: ___WIDGET_NAME___( |
| 122 | + key: _globalKey, |
| 123 | + extra: extra ?? |
| 124 | + urlToScreenConfiguration( |
| 125 | + url: state.uri, |
| 126 | + isAccessibleOnlyIfLoggedIn: ___WIDGET_NAME___Configuration |
| 127 | + .IS_ACCESSIBLE_ONLY_IF_LOGGED_IN, |
| 128 | + isAccessibleOnlyIfLoggedInAndVerified: |
| 129 | + ___WIDGET_NAME___Configuration |
| 130 | + .IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED, |
| 131 | + isAccessibleOnlyIfLoggedOut: ___WIDGET_NAME___Configuration |
| 132 | + .IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT, |
| 133 | + isRedirectable: ___WIDGET_NAME___Configuration.IS_REDIRECTABLE, |
| 134 | + title: null, |
| 135 | + ), |
| 136 | + ), |
| 137 | + ); |
| 138 | + }, |
| 139 | +); |
| 140 | + |
| 141 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 142 | + |
| 143 | +/// Returns a [___WIDGET_NAME___] instance if the [configuration] is of type |
| 144 | +/// [___WIDGET_NAME___Configuration] and if the current authentication status matches |
| 145 | +/// [isLoggedInAndVerified], [isLoggedIn], and [isLoggedOut]. |
| 146 | +Screen? maker___WIDGET_NAME___( |
| 147 | + ModelScreenConfiguration extra, |
| 148 | + bool isLoggedInAndVerified, |
| 149 | + bool isLoggedIn, |
| 150 | + bool isLoggedOut, |
| 151 | +) { |
| 152 | + if ((_IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED && |
| 153 | + !isLoggedInAndVerified) || |
| 154 | + (_IS_ACCESSIBLE_ONLY_IF_LOGGED_IN && !isLoggedIn) || |
| 155 | + (_IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT && !isLoggedOut)) { |
| 156 | + return null; |
| 157 | + } |
| 158 | + if (extra is ___WIDGET_NAME___Configuration) { |
| 159 | + return ___WIDGET_NAME___( |
| 160 | + key: _globalKey, |
| 161 | + extra: extra, |
| 162 | + ); |
| 163 | + } |
| 164 | + if (RegExp(r'^(' + _PATH + r')([?/].*)?$') |
| 165 | + .hasMatch(Uri.decodeComponent(extra.path ?? ''))) { |
| 166 | + final temp = ___WIDGET_NAME___Configuration.optional( |
| 167 | + args: extra.args, |
| 168 | + ); |
| 169 | + return ___WIDGET_NAME___( |
| 170 | + key: _globalKey, |
| 171 | + extra: temp, |
| 172 | + ); |
| 173 | + } |
| 174 | + return null; |
| 175 | +} |
| 176 | + |
| 177 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 178 | + |
| 179 | +/// A controller type corresponding to [___WIDGET_NAME___]. |
| 180 | +typedef T___WIDGET_NAME___Controller |
| 181 | + = _ControllerBroker<___WIDGET_NAME___, _State>; |
| 182 | + |
| 183 | +/// A [AdaptiveScreenState] type corresponding to [___WIDGET_NAME___]. |
| 184 | +typedef TAdaptive___WIDGET_NAME___State = AdaptiveScreenState<___WIDGET_NAME___, |
| 185 | + ___WIDGET_NAME___Configuration, ___WIDGET_NAME___Controller>; |
| 186 | + |
| 187 | +/// A [ScreenState] type corresponding to [___WIDGET_NAME___]. |
| 188 | +typedef T___WIDGET_NAME___State = ScreenState<___WIDGET_NAME___, |
| 189 | + ___WIDGET_NAME___Configuration, ___WIDGET_NAME___Controller>; |
| 190 | + |
| 191 | +/// A [ScreenPageState] type corresponding to [___WIDGET_NAME___]. |
| 192 | +typedef T___WIDGET_NAME___PageState<T extends ScreenPage> = ScreenPageState<T, |
| 193 | + ___WIDGET_NAME___Configuration, ___WIDGET_NAME___Controller>; |
| 194 | + |
| 195 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 196 | + |
| 197 | +base class ____WIDGET_NAME___ extends Screen { |
| 198 | + const ____WIDGET_NAME___({ |
| 199 | + required super.key, |
| 200 | + required super.extra, |
| 201 | + super.controllerTimeout = Duration.zero, |
| 202 | + }); |
| 203 | + |
| 204 | + @override |
| 205 | + createState() => _State(); |
| 206 | + |
| 207 | + @override |
| 208 | + createController( |
| 209 | + Screen screen, |
| 210 | + ScreenState state, |
| 211 | + ) { |
| 212 | + return ___WIDGET_NAME___Controller(screen, state); |
| 213 | + } |
| 214 | +} |
| 215 | + |
| 216 | +// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ |
| 217 | + |
| 218 | +// The following constants are set by the generator based on the provided |
| 219 | +// options. Together they form the behavior of the generated screen. |
| 220 | + |
| 221 | +const _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED = false; |
| 222 | +const _IS_ACCESSIBLE_ONLY_IF_LOGGED_IN = false; |
| 223 | +const _IS_ACCESSIBLE_ONLY_IF_LOGGED_OUT = false; |
| 224 | +const _IS_REDIRECTABLE = false; |
| 225 | +const _CLASS = '___WIDGET_NAME___'; |
| 226 | +const _SEGMENT = '_example'; |
| 227 | +const _PATH = '/$_SEGMENT'; |
| 228 | +const _TR_KEY = 'screens.___WIDGET_NAME___'; |
| 229 | +const _DEFAULT_TITLE = 'ExampleScreen'; |
0 commit comments