Skip to content

Commit 6fb2845

Browse files
committed
+chore: Removed ScreenTr from bindings
1 parent e4f6b52 commit 6fb2845

File tree

7 files changed

+443
-9
lines changed

7 files changed

+443
-9
lines changed

bin/genscr-bindings-v3.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//.title
2+
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
3+
//
4+
// Dart/Flutter (DF) Packages by DevCetra.com & contributors. SSee LICENSE file
5+
// in root directory.
6+
//
7+
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
8+
//.title~
9+
10+
import 'package:df_generate_screen/df_generate_screen.dart';
11+
import 'package:df_log/df_log.dart';
12+
13+
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
14+
15+
const VERSION = 'v3';
16+
17+
void main(List<String> args) async {
18+
DebugLog.debugOnly = false;
19+
await runGenerateScreenBindingsApp([
20+
...args,
21+
'--template',
22+
'https://raw.githubusercontent.com/robmllze/df_generate_screen/main/templates/$VERSION/bindings.dart.md',
23+
]);
24+
}

pubspec.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@
1111
##.title~
1212

1313
name: df_generate_screen
14-
description: "A tool to generate ready-made screen templates for your Flutter app (uses df_sceen)"
15-
version: 0.1.1
14+
description: A tool to generate ready-made screen templates for your Flutter app (uses df_sceen)
15+
version: 0.1.2
1616
repository: https://github.com/robmllze/df_generate_screen
1717
funding:
1818
- https://www.buymeacoffee.com/robmllze
19-
# topics:
20-
# - flutter
21-
# - code-generation
22-
# - screens
23-
# - templates
19+
topics:
20+
- source-gen
21+
- build-runner
22+
- code-generation
23+
- screen
24+
- pages
2425

2526
## -----------------------------------------------------------------------------
2627

@@ -34,7 +35,7 @@ dependencies:
3435
df_config: ^0.4.0
3536
df_gen_core: ^0.2.8
3637
df_generate_dart_indexes: ^0.2.2
37-
df_generate_dart_models_core: ^0.4.1
38+
df_generate_dart_models_core: ^0.4.2
3839
df_log: ^0.2.1
3940
df_screen_core: ^0.1.1
4041
df_string: ^0.2.1
@@ -55,7 +56,7 @@ dev_dependencies:
5556
executables:
5657
genscr: genscr-v2
5758
genscr-access: genscr-access-v2
58-
genscr-bindings: genscr-bindings-v2
59+
genscr-bindings: genscr-bindings-v3 # v3
5960

6061
genscr-v1: genscr-v1
6162
genscr-access-v1: genscr-access-v1

templates/v3/access.dart.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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

Comments
 (0)