Skip to content

Commit 5dcebfb

Browse files
author
Gabriel Peres Bernes
committed
feat: implements fake firebase data sources
1 parent 7eba5ed commit 5dcebfb

123 files changed

Lines changed: 795 additions & 306 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

env.example.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"API_BASE_URL": "",
3-
"CRM_BASE_URL": ""
2+
"API_BASE_URL": "https://dummyjson.com/products",
3+
"CRM_BASE_URL": "https://veushuon.api.sanity.io/v2025-12-27/data/query/production",
4+
"USE_FIREBASE": false
45
}

ios/Podfile.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,8 @@ PODS:
14911491
- GTMSessionFetcher/Core (3.5.0)
14921492
- GTMSessionFetcher/Full (3.5.0):
14931493
- GTMSessionFetcher/Core
1494+
- integration_test (0.0.1):
1495+
- Flutter
14941496
- leveldb-library (1.22.6)
14951497
- nanopb (3.30910.0):
14961498
- nanopb/decode (= 3.30910.0)
@@ -1528,6 +1530,7 @@ DEPENDENCIES:
15281530
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
15291531
- flutter_secure_storage_darwin (from `.symlinks/plugins/flutter_secure_storage_darwin/darwin`)
15301532
- google_sign_in_ios (from `.symlinks/plugins/google_sign_in_ios/darwin`)
1533+
- integration_test (from `.symlinks/plugins/integration_test/ios`)
15311534
- package_info_plus (from `.symlinks/plugins/package_info_plus/ios`)
15321535
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
15331536
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
@@ -1592,6 +1595,8 @@ EXTERNAL SOURCES:
15921595
:path: ".symlinks/plugins/flutter_secure_storage_darwin/darwin"
15931596
google_sign_in_ios:
15941597
:path: ".symlinks/plugins/google_sign_in_ios/darwin"
1598+
integration_test:
1599+
:path: ".symlinks/plugins/integration_test/ios"
15951600
package_info_plus:
15961601
:path: ".symlinks/plugins/package_info_plus/ios"
15971602
path_provider_foundation:
@@ -1644,6 +1649,7 @@ SPEC CHECKSUMS:
16441649
gRPC-Core: 860978b7db482de8b4f5e10677216309b5ff6330
16451650
GTMAppAuth: 217a876b249c3c585a54fd6f73e6b58c4f5c4238
16461651
GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6
1652+
integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
16471653
leveldb-library: cc8b8f8e013647a295ad3f8cd2ddf49a6f19be19
16481654
nanopb: fad817b59e0457d11a5dfbde799381cd727c1275
16491655
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
9740EEB61CF901F6004384FC /* Run Script */,
200200
97C146EA1CF9000F007C117D /* Sources */,
201201
97C146EB1CF9000F007C117D /* Frameworks */,
202+
C032AB572F269F1300A6E1E6 /* Check Firebase Plist */,
202203
97C146EC1CF9000F007C117D /* Resources */,
203204
9705A1C41CF9048500538489 /* Embed Frameworks */,
204205
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
@@ -404,6 +405,26 @@
404405
shellPath = /bin/sh;
405406
shellScript = "\n#!/bin/bash\nPATH=\"${PATH}:$FLUTTER_ROOT/bin:${PUB_CACHE}/bin:$HOME/.pub-cache/bin\"\n\nif [ -z \"$PODS_ROOT\" ] || [ ! -d \"$PODS_ROOT/FirebaseCrashlytics\" ]; then\n # Cannot use \"BUILD_DIR%/Build/*\" as per Firebase documentation, it points to \"flutter-project/build/ios/*\" path which doesn't have run script\n DERIVED_DATA_PATH=$(echo \"$BUILD_ROOT\" | sed -E 's|(.*DerivedData/[^/]+).*|\\1|')\n PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT=\"${DERIVED_DATA_PATH}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run\"\nelse\n PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT=\"$PODS_ROOT/FirebaseCrashlytics/run\"\nfi\n\n# Command to upload symbols script used to upload symbols to Firebase server\nflutterfire upload-crashlytics-symbols --upload-symbols-script-path=\"$PATH_TO_CRASHLYTICS_UPLOAD_SCRIPT\" --platform=ios --apple-project-path=\"${SRCROOT}\" --env-platform-name=\"${PLATFORM_NAME}\" --env-configuration=\"${CONFIGURATION}\" --env-project-dir=\"${PROJECT_DIR}\" --env-built-products-dir=\"${BUILT_PRODUCTS_DIR}\" --env-dwarf-dsym-folder-path=\"${DWARF_DSYM_FOLDER_PATH}\" --env-dwarf-dsym-file-name=\"${DWARF_DSYM_FILE_NAME}\" --env-infoplist-path=\"${INFOPLIST_PATH}\" --default-config=default\n";
406407
};
408+
C032AB572F269F1300A6E1E6 /* Check Firebase Plist */ = {
409+
isa = PBXShellScriptBuildPhase;
410+
buildActionMask = 2147483647;
411+
files = (
412+
);
413+
inputFileListPaths = (
414+
);
415+
inputPaths = (
416+
"$(PROJECT_DIR)/Runner/GoogleService-Info-Placeholder.plist",
417+
);
418+
name = "Check Firebase Plist";
419+
outputFileListPaths = (
420+
);
421+
outputPaths = (
422+
"$(PROJECT_DIR)/Runner/GoogleService-Info.plist",
423+
);
424+
runOnlyForDeploymentPostprocessing = 0;
425+
shellPath = /bin/sh;
426+
shellScript = "set -euo pipefail\n\n# Paths\nRUNNER_DIR=\"${PROJECT_DIR}/Runner\"\nTARGET_PLIST=\"${RUNNER_DIR}/GoogleService-Info.plist\"\nPLACEHOLDER_PLIST=\"${RUNNER_DIR}/GoogleService-Info-Placeholder.plist\"\n\nif [ -f \"$TARGET_PLIST\" ]; then\n echo \"[Firebase] GoogleService-Info.plist already exists ✅\"\n exit 0\nfi\n\nif [ ! -f \"$PLACEHOLDER_PLIST\" ]; then\n echo \"[Firebase] Placeholder not found at: $PLACEHOLDER_PLIST ❌\"\n exit 1\nfi\n\necho \"[Firebase] GoogleService-Info.plist not found. Creating from placeholder…\"\ncp \"$PLACEHOLDER_PLIST\" \"$TARGET_PLIST\"\necho \"[Firebase] Created GoogleService-Info.plist ✅\"\n";
427+
};
407428
/* End PBXShellScriptBuildPhase section */
408429

409430
/* Begin PBXSourcesBuildPhase section */
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CLIENT_ID</key>
6+
<string>111111111111-aaa1aaaaaaaaa1a111aa1a1a1aaaaaa.apps.googleusercontent.com</string>
7+
<key>REVERSED_CLIENT_ID</key>
8+
<string>com.googleusercontent.apps.111111111111-aaa1aaaaaaaaa1a111aa1a1a1aaaaaa</string>
9+
<key>ANDROID_CLIENT_ID</key>
10+
<string>111111111111-1aa111aaaaaaa11aaaaaaaaaaa1aa1aa.apps.googleusercontent.com</string>
11+
<key>API_KEY</key>
12+
<string>AAaaAaAaAA1a1AAaA1AaAaA1a11aAAA1aAaAAAA</string>
13+
<key>GCM_SENDER_ID</key>
14+
<string>111111111111</string>
15+
<key>PLIST_VERSION</key>
16+
<string>1</string>
17+
<key>BUNDLE_ID</key>
18+
<string>dev.bernes.flutlystore</string>
19+
<key>PROJECT_ID</key>
20+
<string>flutly-store</string>
21+
<key>STORAGE_BUCKET</key>
22+
<string>flutly-store.firebasestorage.app</string>
23+
<key>IS_ADS_ENABLED</key>
24+
<false></false>
25+
<key>IS_ANALYTICS_ENABLED</key>
26+
<false></false>
27+
<key>IS_APPINVITE_ENABLED</key>
28+
<true></true>
29+
<key>IS_GCM_ENABLED</key>
30+
<true></true>
31+
<key>IS_SIGNIN_ENABLED</key>
32+
<true></true>
33+
<key>GOOGLE_APP_ID</key>
34+
<string>1:111111111111:ios:1a1aaa11a1aaa111a11a11</string>
35+
</dict>
36+
</plist>

lib/app/app.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class _AppState extends State<App> {
2727
void initState() {
2828
super.initState();
2929

30-
_injectionFuture = AppModule().register(CoreInjector.instance);
30+
_injectionFuture = const AppModule().register(CoreInjector.instance);
3131
}
3232

3333
@override

lib/app/features/auth/auth.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export 'data/data_sources/auth_local_data_source.dart';
2-
export 'data/data_sources/auth_local_data_source_impl.dart';
3-
export 'data/data_sources/auth_remote_data_source.dart';
4-
export 'data/data_sources/auth_remote_data_source_impl.dart';
1+
export 'data/data_sources/local/auth_local_data_source.dart';
2+
export 'data/data_sources/local/auth_local_data_source_impl.dart';
3+
export 'data/data_sources/remote/auth_remote_data_source.dart';
4+
export 'data/data_sources/remote/auth_remote_data_source_impl.dart';
55
export 'data/models/credentials_model.dart';
66
export 'data/repositories/auth_repository_impl.dart';
77
export 'domain/entities/credentials.dart';

lib/app/features/auth/data/data_sources/auth_local_data_source.dart renamed to lib/app/features/auth/data/data_sources/local/auth_local_data_source.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:fpdart/fpdart.dart';
22

3-
import '../../../../shared/types/response_type.dart';
4-
import '../models/credentials_model.dart';
3+
import '../../../../../shared/types/response_type.dart';
4+
import '../../models/credentials_model.dart';
55

66
abstract interface class AuthLocalDataSource {
77
TaskResponse<void> saveCredentials(CredentialsModel credentials);

lib/app/features/auth/data/data_sources/auth_local_data_source_impl.dart renamed to lib/app/features/auth/data/data_sources/local/auth_local_data_source_impl.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'package:easy_localization/easy_localization.dart';
22
import 'package:fpdart/fpdart.dart';
33

4-
import '../../../../core/local_storage/local_storage.dart';
5-
import '../../../../shared/types/response_type.dart';
6-
import '../../../../shared/utils/task_utils.dart';
7-
import '../../constants/auth_constants.dart';
8-
import '../models/credentials_model.dart';
4+
import '../../../../../core/local_storage/local_storage.dart';
5+
import '../../../../../shared/types/response_type.dart';
6+
import '../../../../../shared/utils/task_utils.dart';
7+
import '../../../constants/auth_constants.dart';
8+
import '../../models/credentials_model.dart';
99
import 'auth_local_data_source.dart';
1010

1111
class AuthLocalDataSourceImpl implements AuthLocalDataSource {

lib/app/features/auth/data/data_sources/auth_remote_data_source.dart renamed to lib/app/features/auth/data/data_sources/remote/auth_remote_data_source.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import '../../../../shared/types/response_type.dart';
2-
import '../../domain/entities/credentials.dart';
3-
import '../models/credentials_model.dart';
1+
import '../../../../../shared/types/response_type.dart';
2+
import '../../../domain/entities/credentials.dart';
3+
import '../../models/credentials_model.dart';
44

55
abstract interface class AuthRemoteDataSource {
66
TaskResponse<CredentialsModel> signIn({
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import 'package:easy_localization/easy_localization.dart';
2+
3+
import '../../../../../core/local_storage/local_storage.dart';
4+
import '../../../../../shared/types/response_type.dart';
5+
import '../../../../../shared/utils/task_utils.dart';
6+
import '../../../constants/auth_constants.dart';
7+
import '../../../domain/entities/credentials.dart';
8+
import '../../models/credentials_model.dart';
9+
import 'auth_remote_data_source.dart';
10+
11+
/// A fake implementation of [AuthRemoteDataSource] for demonstration purposes.
12+
/// This class is used when Firebase is not enabled in the application.
13+
class AuthRemoteDataSourceDemoImpl implements AuthRemoteDataSource {
14+
AuthRemoteDataSourceDemoImpl(this._localStorage);
15+
16+
final CoreLocalStorage _localStorage;
17+
18+
final userId = 'demo_user_id';
19+
String userName = 'Demo User';
20+
String userEmail = 'demo@example.com';
21+
22+
@override
23+
TaskResponse<CredentialsModel> signIn({
24+
required String email,
25+
required String password,
26+
}) {
27+
userEmail = email;
28+
29+
return TaskResponse.right(
30+
CredentialsModel(
31+
userId: userId,
32+
name: userName,
33+
email: userEmail,
34+
provider: AuthProvider.email.name,
35+
),
36+
);
37+
}
38+
39+
@override
40+
TaskResponse<void> signOut() =>
41+
task(() async {}, (_) => tr('auth.errors.sign_out_failed'));
42+
43+
@override
44+
TaskResponse<CredentialsModel> signUp({
45+
required String name,
46+
required String email,
47+
required String password,
48+
}) {
49+
userName = name;
50+
userEmail = email;
51+
52+
return TaskResponse.right(
53+
CredentialsModel(
54+
userId: userId,
55+
name: userName,
56+
email: userEmail,
57+
provider: AuthProvider.email.name,
58+
),
59+
);
60+
}
61+
62+
@override
63+
TaskResponse<CredentialsModel> signWithApple() => TaskResponse.right(
64+
CredentialsModel(
65+
userId: userId,
66+
name: userName,
67+
email: 'apple@example.com',
68+
provider: AuthProvider.apple.name,
69+
),
70+
);
71+
72+
@override
73+
TaskResponse<CredentialsModel> signWithGoogle() => TaskResponse.right(
74+
CredentialsModel(
75+
userId: userId,
76+
name: userName,
77+
email: 'google@example.com',
78+
provider: AuthProvider.google.name,
79+
),
80+
);
81+
82+
@override
83+
TaskResponse<CredentialsModel> updateUser({
84+
required AuthProvider provider,
85+
String? name,
86+
String? currentPassword,
87+
String? newPassword,
88+
}) => task(
89+
() async {
90+
if (name != null) {
91+
userName = name;
92+
}
93+
94+
final data = await _localStorage.secureStorage.get<CredentialsModel>(
95+
AuthConstants.userKey,
96+
CredentialsModel.fromJson,
97+
);
98+
99+
if (data != null && data.email.isNotEmpty) {
100+
userEmail = data.email;
101+
}
102+
103+
return CredentialsModel(
104+
userId: userId,
105+
name: userName,
106+
email: userEmail,
107+
provider: provider.name,
108+
);
109+
},
110+
(_) => tr('auth.errors.update_failed'),
111+
);
112+
}

0 commit comments

Comments
 (0)