Skip to content

Commit 9b5135f

Browse files
authored
Merge pull request #24 from headlines-toolkit/refatrcor_auth_hints_for_demo_envirement
Refatrcor auth hints for demo envirement
2 parents d221b6c + ec8d5a7 commit 9b5135f

File tree

8 files changed

+97
-4
lines changed

8 files changed

+97
-4
lines changed

lib/app/bloc/app_bloc.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ class AppBloc extends Bloc<AppEvent, AppState> {
2121
}) : _authenticationRepository = authenticationRepository,
2222
_userAppSettingsRepository = userAppSettingsRepository,
2323
_appConfigRepository = appConfigRepository,
24-
_environment = environment,
2524
super(
26-
const AppState(),
25+
AppState(environment: environment),
2726
) {
2827
on<AppUserChanged>(_onAppUserChanged);
2928
on<AppLogoutRequested>(_onLogoutRequested);
@@ -37,7 +36,6 @@ class AppBloc extends Bloc<AppEvent, AppState> {
3736
final HtAuthRepository _authenticationRepository;
3837
final HtDataRepository<UserAppSettings> _userAppSettingsRepository;
3938
final HtDataRepository<AppConfig> _appConfigRepository;
40-
final local_config.AppEnvironment _environment;
4139
late final StreamSubscription<User?> _userSubscription;
4240

4341
/// Handles user changes and loads initial settings once user is available.

lib/authentication/view/email_code_verification_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class EmailCodeVerificationPage extends StatelessWidget {
8282
children: [
8383
const SizedBox(height: AppSpacing.md),
8484
Text(
85-
l10n.demoVerificationCodeMessage('123456'),
85+
l10n.demoCodeHint('123456'),
8686
style: textTheme.bodyMedium?.copyWith(
8787
color: colorScheme.secondary,
8888
fontWeight: FontWeight.bold,

lib/authentication/view/request_code_page.dart

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import 'package:flutter/material.dart';
55
import 'package:flutter_bloc/flutter_bloc.dart';
6+
import 'package:ht_dashboard/app/bloc/app_bloc.dart';
7+
import 'package:ht_dashboard/app/config/config.dart';
68
import 'package:go_router/go_router.dart';
79
import 'package:ht_dashboard/authentication/bloc/authentication_bloc.dart';
810
import 'package:ht_dashboard/l10n/l10n.dart';
@@ -129,6 +131,26 @@ class _RequestCodeView extends StatelessWidget {
129131
),
130132
textAlign: TextAlign.center,
131133
),
134+
// Display demo email if in demo environment
135+
BlocSelector<AppBloc, AppState, AppEnvironment?>(
136+
selector: (state) => state.environment,
137+
builder: (context, environment) {
138+
if (environment == AppEnvironment.demo) {
139+
return Padding(
140+
padding: const EdgeInsets.only(top: AppSpacing.lg),
141+
child: Text(
142+
l10n.demoEmailHint('[email protected]'),
143+
style: textTheme.bodyMedium?.copyWith(
144+
color: colorScheme.secondary,
145+
fontWeight: FontWeight.bold,
146+
),
147+
textAlign: TextAlign.center,
148+
),
149+
);
150+
}
151+
return const SizedBox.shrink();
152+
},
153+
),
132154
const SizedBox(height: AppSpacing.xxl),
133155
_EmailLinkForm(isLoading: isLoading),
134156
],

lib/l10n/app_localizations.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,18 @@ abstract class AppLocalizations {
14171417
/// In en, this message translates to:
14181418
/// **'Disabled'**
14191419
String get appStatusDisabled;
1420+
1421+
/// Hint text shown in demo environment for the login email.
1422+
///
1423+
/// In en, this message translates to:
1424+
/// **'For demo, use email: {email}'**
1425+
String demoEmailHint(String email);
1426+
1427+
/// Hint text shown in demo environment for the verification code.
1428+
///
1429+
/// In en, this message translates to:
1430+
/// **'For demo, use code: {code}'**
1431+
String demoCodeHint(String code);
14201432
}
14211433

14221434
class _AppLocalizationsDelegate

lib/l10n/app_localizations_ar.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,4 +737,14 @@ class AppLocalizationsAr extends AppLocalizations {
737737

738738
@override
739739
String get appStatusDisabled => 'معطل';
740+
741+
@override
742+
String demoEmailHint(String email) {
743+
return 'للعرض التجريبي، استخدم البريد الإلكتروني: $email';
744+
}
745+
746+
@override
747+
String demoCodeHint(String code) {
748+
return 'للعرض التجريبي، استخدم الرمز: $code';
749+
}
740750
}

lib/l10n/app_localizations_en.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,4 +735,14 @@ class AppLocalizationsEn extends AppLocalizations {
735735

736736
@override
737737
String get appStatusDisabled => 'Disabled';
738+
739+
@override
740+
String demoEmailHint(String email) {
741+
return 'For demo, use email: $email';
742+
}
743+
744+
@override
745+
String demoCodeHint(String code) {
746+
return 'For demo, use code: $code';
747+
}
738748
}

lib/l10n/arb/app_ar.arb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,5 +893,25 @@
893893
"appStatusDisabled": "معطل",
894894
"@appStatusDisabled": {
895895
"description": "نص حالة التطبيق 'معطل'"
896+
},
897+
"demoEmailHint": "للعرض التجريبي، استخدم البريد الإلكتروني: {email}",
898+
"@demoEmailHint": {
899+
"description": "Hint text shown in demo environment for the login email.",
900+
"placeholders": {
901+
"email": {
902+
"type": "String",
903+
"example": "[email protected]"
904+
}
905+
}
906+
},
907+
"demoCodeHint": "للعرض التجريبي، استخدم الرمز: {code}",
908+
"@demoCodeHint": {
909+
"description": "Hint text shown in demo environment for the verification code.",
910+
"placeholders": {
911+
"code": {
912+
"type": "String",
913+
"example": "123456"
914+
}
915+
}
896916
}
897917
}

lib/l10n/arb/app_en.arb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,5 +893,26 @@
893893
"appStatusDisabled": "Disabled",
894894
"@appStatusDisabled": {
895895
"description": "Text for the 'Disabled' app status"
896+
},
897+
"demoEmailHint": "For demo, use email: {email}",
898+
"@demoEmailHint": {
899+
"description": "Hint text shown in demo environment for the login email.",
900+
"placeholders": {
901+
"email": {
902+
"type": "String",
903+
"example": "[email protected]"
904+
}
905+
}
906+
},
907+
"demoCodeHint": "For demo, use code: {code}",
908+
"@demoCodeHint": {
909+
"description": "Hint text shown in demo environment for the verification code.",
910+
"placeholders": {
911+
"code": {
912+
"type": "String",
913+
"example": "123456"
914+
}
915+
}
896916
}
917+
897918
}

0 commit comments

Comments
 (0)