Skip to content

Commit 249d6e6

Browse files
committed
chore: Update default title in bindings.dart.md
1 parent 2ef5a07 commit 249d6e6

File tree

3 files changed

+38
-48
lines changed

3 files changed

+38
-48
lines changed

lib/src/generate_screen/_insight_mappers.dart

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import '_insight.dart';
1414

1515
final insightMappers = [
1616
_InsightMapper(
17-
placeholder: Placeholders.TITLE,
17+
placeholder: Placeholders.DEFAULT_TITLE,
1818
mapInsights: (insight) async {
1919
return insight.title;
2020
},
@@ -63,9 +63,8 @@ final insightMappers = [
6363
_InsightMapper(
6464
placeholder: Placeholders.I1,
6565
mapInsights: (insight) async {
66-
final q1 = insight.queryParameters
67-
.map((e) => 'late final $e = this.configuration.$e;')
68-
.join('\n');
66+
final q1 =
67+
insight.queryParameters.map((e) => 'late final $e = this.configuration.$e;').join('\n');
6968
return q1;
7069
},
7170
),
@@ -89,17 +88,13 @@ final insightMappers = [
8988
final generateScreenBindingsArgs = [
9089
if (insight.path.isNotEmpty) "path: '${insight.path}'",
9190
if (insight.title.isNotEmpty) "title: '${insight.title}'",
92-
if (insight.isAccessibleOnlyIfLoggedIn)
93-
'isAccessibleOnlyIfLoggedIn: true',
91+
if (insight.isAccessibleOnlyIfLoggedIn) 'isAccessibleOnlyIfLoggedIn: true',
9492
if (insight.isAccessibleOnlyIfLoggedInAndVerified)
9593
'isAccessibleOnlyIfLoggedInAndVerified: true',
96-
if (insight.isAccessibleOnlyIfLoggedOut)
97-
'isAccessibleOnlyIfLoggedOut: true',
94+
if (insight.isAccessibleOnlyIfLoggedOut) 'isAccessibleOnlyIfLoggedOut: true',
9895
if (insight.isRedirectable) 'isRedirectable: true',
99-
if (insight.internalParameters.isNotEmpty && a.isNotEmpty)
100-
'internalParameters: {$a,}',
101-
if (insight.queryParameters.isNotEmpty && b.isNotEmpty)
102-
'queryParameters: {$b,}',
96+
if (insight.internalParameters.isNotEmpty && a.isNotEmpty) 'internalParameters: {$a,}',
97+
if (insight.queryParameters.isNotEmpty && b.isNotEmpty) 'queryParameters: {$b,}',
10398
].join(',');
10499
return generateScreenBindingsArgs;
105100
},
@@ -117,7 +112,7 @@ final insightMappers = [
117112
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
118113

119114
enum Placeholders {
120-
TITLE,
115+
DEFAULT_TITLE,
121116
SCREEN_CLASS,
122117
BINDINGS_FILE,
123118
CONTROLLER_FILE,

lib/src/generate_screen_bindings/_insight_mappers.dart

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ final _screenSegmentMapper = _InsightMapper(
3131
final path = insight.annotation.path ?? '';
3232
final screenSegment = p.joinAll(
3333
[
34-
path.isNotEmpty && path.startsWith(RegExp(r'[\\/]'))
35-
? path.substring(1)
36-
: path,
34+
path.isNotEmpty && path.startsWith(RegExp(r'[\\/]')) ? path.substring(1) : path,
3735
screenKey,
3836
],
3937
);
@@ -48,6 +46,18 @@ final insightMappers = [
4846
return insight.className;
4947
},
5048
),
49+
_InsightMapper(
50+
placeholder: Placeholders.DEFAULT_TITLE,
51+
mapInsights: (insight) async {
52+
return insight.annotation.title ??
53+
insight.className
54+
.toCamelCase()
55+
.replaceAll('screen', '')
56+
.split('_')
57+
.map((e) => e.capitalize())
58+
.join(' ');
59+
},
60+
),
5161
_InsightMapper(
5262
placeholder: Placeholders.CONFIGURATION_CLASS,
5363
mapInsights: (insight) async {
@@ -79,8 +89,7 @@ final insightMappers = [
7989
_InsightMapper(
8090
placeholder: Placeholders.IS_ACCESSIBLE_ONLY_IF_LOGGED_IN_AND_VERIFIED,
8191
mapInsights: (insight) async {
82-
final b =
83-
insight.annotation.isAccessibleOnlyIfLoggedInAndVerified ?? false;
92+
final b = insight.annotation.isAccessibleOnlyIfLoggedInAndVerified ?? false;
8493
return b.toString();
8594
},
8695
),
@@ -101,8 +110,7 @@ final insightMappers = [
101110
_InsightMapper(
102111
placeholder: Placeholders.IS_ALWAYS_ACCESSIBLE,
103112
mapInsights: (insight) async {
104-
final a =
105-
insight.annotation.isAccessibleOnlyIfLoggedInAndVerified ?? false;
113+
final a = insight.annotation.isAccessibleOnlyIfLoggedInAndVerified ?? false;
106114
final b = insight.annotation.isAccessibleOnlyIfLoggedIn ?? false;
107115
final c = insight.annotation.isAccessibleOnlyIfLoggedOut ?? false;
108116
if (a && b) {
@@ -145,10 +153,8 @@ final insightMappers = [
145153
_InsightMapper(
146154
placeholder: Placeholders.IP0,
147155
mapInsights: (insight) async {
148-
final params = insight.annotation.internalParameters
149-
?.map((e) => FieldUtils.ofOrNull(e))
150-
.nonNulls ??
151-
{};
156+
final params =
157+
insight.annotation.internalParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
152158
if (params.isNotEmpty) {
153159
final a = params.map((e) {
154160
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -176,10 +182,8 @@ final insightMappers = [
176182
_InsightMapper(
177183
placeholder: Placeholders.IP1,
178184
mapInsights: (insight) async {
179-
final params = insight.annotation.internalParameters
180-
?.map((e) => FieldUtils.ofOrNull(e))
181-
.nonNulls ??
182-
{};
185+
final params =
186+
insight.annotation.internalParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
183187
if (params.isNotEmpty) {
184188
final a = params.map((e) {
185189
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -199,10 +203,8 @@ final insightMappers = [
199203
_InsightMapper(
200204
placeholder: Placeholders.IP2,
201205
mapInsights: (insight) async {
202-
final params = insight.annotation.internalParameters
203-
?.map((e) => FieldUtils.ofOrNull(e))
204-
.nonNulls ??
205-
{};
206+
final params =
207+
insight.annotation.internalParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
206208
if (params.isNotEmpty) {
207209
final a = params.map((e) {
208210
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -220,10 +222,8 @@ final insightMappers = [
220222
_InsightMapper(
221223
placeholder: Placeholders.QP0,
222224
mapInsights: (insight) async {
223-
final params = insight.annotation.queryParameters
224-
?.map((e) => FieldUtils.ofOrNull(e))
225-
.nonNulls ??
226-
{};
225+
final params =
226+
insight.annotation.queryParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
227227
if (params.isNotEmpty) {
228228
final a = params.map((e) {
229229
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -251,10 +251,8 @@ final insightMappers = [
251251
_InsightMapper(
252252
placeholder: Placeholders.QP1,
253253
mapInsights: (insight) async {
254-
final params = insight.annotation.queryParameters
255-
?.map((e) => FieldUtils.ofOrNull(e))
256-
.nonNulls ??
257-
{};
254+
final params =
255+
insight.annotation.queryParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
258256
if (params.isNotEmpty) {
259257
final a = params.map((e) {
260258
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -271,10 +269,8 @@ final insightMappers = [
271269
_InsightMapper(
272270
placeholder: Placeholders.QP2,
273271
mapInsights: (insight) async {
274-
final params = insight.annotation.queryParameters
275-
?.map((e) => FieldUtils.ofOrNull(e))
276-
.nonNulls ??
277-
{};
272+
final params =
273+
insight.annotation.queryParameters?.map((e) => FieldUtils.ofOrNull(e)).nonNulls ?? {};
278274
if (params.isNotEmpty) {
279275
final a = params.map((e) {
280276
final fieldName = e.fieldPath!.join('_').toCamelCase();
@@ -296,6 +292,7 @@ final insightMappers = [
296292

297293
enum Placeholders {
298294
CLASS,
295+
DEFAULT_TITLE,
299296
CONFIGURATION_CLASS,
300297
CLASS_FILE,
301298
SCREEN_KEY,
@@ -313,8 +310,6 @@ enum Placeholders {
313310
QP0,
314311
QP1,
315312
QP2,
316-
TITLE,
317313
}
318314

319-
typedef _InsightMapper
320-
= InsightMapper<ClassInsight<ModelGenerateScreenBindings>, Placeholders>;
315+
typedef _InsightMapper = InsightMapper<ClassInsight<ModelGenerateScreenBindings>, Placeholders>;

templates/msm1/bindings.dart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,5 @@ const _CLASS = '___CLASS___';
218218
const _SEGMENT = '___SCREEN_SEGMENT___';
219219
const _PATH = '/$_SEGMENT';
220220
const _TR_KEY = 'screens.___CLASS___';
221-
const _DEFAULT_TITLE = '___TITLE___';
221+
const _DEFAULT_TITLE = '___ DEFAULT_TITLE___';
222222
```

0 commit comments

Comments
 (0)