diff --git a/__mocks__/@react-native-firebase/remote-config.js b/__mocks__/@react-native-firebase/remote-config.js new file mode 100644 index 0000000..3a3d777 --- /dev/null +++ b/__mocks__/@react-native-firebase/remote-config.js @@ -0,0 +1,11 @@ +const remoteConfig = () => ({ + fetchAndActivate: jest.fn(() => Promise.resolve(true)), + setConfigSettings: jest.fn(), + setDefaults: jest.fn(), + getValue: jest.fn(), + getAll: jest.fn(), + getString: jest.fn(), + getNumber: jest.fn(), +}); + +export default remoteConfig; diff --git a/android/app/build.gradle b/android/app/build.gradle index 7a318fa..13703d6 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,6 +1,8 @@ apply plugin: "com.android.application" apply plugin: "com.facebook.react" +apply plugin: 'com.google.gms.google-services' + project.ext.vectoricons = [ iconFontNames: ['MaterialCommunityIcons.ttf'] ] diff --git a/android/app/google-services.json b/android/app/google-services.json new file mode 100644 index 0000000..b29eab8 --- /dev/null +++ b/android/app/google-services.json @@ -0,0 +1,29 @@ +{ + "project_info": { + "project_number": "473250290916", + "project_id": "smartstop-7a69d", + "storage_bucket": "smartstop-7a69d.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:473250290916:android:6153a7d8264a90b963e0f1", + "android_client_info": { + "package_name": "com.smartstop" + } + }, + "oauth_client": [], + "api_key": [ + { + "current_key": "AIzaSyAI7Q2y3XOAO8qQfnOZAOfFGqzS4pjbD7k" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index 34ea718..204a3d8 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -17,5 +17,7 @@ buildscript { dependencies { classpath("com.android.tools.build:gradle") classpath("com.facebook.react:react-native-gradle-plugin") + + classpath 'com.google.gms:google-services:4.4.0' } } diff --git a/ios/Podfile b/ios/Podfile index a7e494a..c4eb638 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -23,6 +23,7 @@ linkage = ENV['USE_FRAMEWORKS'] if linkage != nil Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green use_frameworks! :linkage => linkage.to_sym + $RNFirebaseAsStaticFramework = true end target 'SmartStop' do diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 142ab22..751cb14 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -9,12 +9,46 @@ PODS: - React-Core (= 0.72.6) - React-jsi (= 0.72.6) - ReactCommon/turbomodule/core (= 0.72.6) + - Firebase/CoreOnly (10.19.0): + - FirebaseCore (= 10.19.0) + - Firebase/RemoteConfig (10.19.0): + - Firebase/CoreOnly + - FirebaseRemoteConfig (~> 10.19.0) + - FirebaseABTesting (10.19.0): + - FirebaseCore (~> 10.0) + - FirebaseCore (10.19.0): + - FirebaseCoreInternal (~> 10.0) + - GoogleUtilities/Environment (~> 7.12) + - GoogleUtilities/Logger (~> 7.12) + - FirebaseCoreInternal (10.19.0): + - "GoogleUtilities/NSData+zlib (~> 7.8)" + - FirebaseInstallations (10.19.0): + - FirebaseCore (~> 10.0) + - GoogleUtilities/Environment (~> 7.8) + - GoogleUtilities/UserDefaults (~> 7.8) + - PromisesObjC (~> 2.1) + - FirebaseRemoteConfig (10.19.0): + - FirebaseABTesting (~> 10.0) + - FirebaseCore (~> 10.0) + - FirebaseInstallations (~> 10.0) + - FirebaseSharedSwift (~> 10.0) + - GoogleUtilities/Environment (~> 7.8) + - "GoogleUtilities/NSData+zlib (~> 7.8)" + - FirebaseSharedSwift (10.19.0) - fmt (6.2.1) - glog (0.3.5) + - GoogleUtilities/Environment (7.12.0): + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/Logger (7.12.0): + - GoogleUtilities/Environment + - "GoogleUtilities/NSData+zlib (7.12.0)" + - GoogleUtilities/UserDefaults (7.12.0): + - GoogleUtilities/Logger - hermes-engine (0.72.6): - hermes-engine/Pre-built (= 0.72.6) - hermes-engine/Pre-built (0.72.6) - libevent (2.1.12) + - PromisesObjC (2.3.1) - RCT-Folly (2021.07.22.00): - boost - DoubleConversion @@ -425,6 +459,15 @@ PODS: - React-jsi (= 0.72.6) - React-logger (= 0.72.6) - React-perflogger (= 0.72.6) + - RNDeviceInfo (10.11.0): + - React-Core + - RNFBApp (18.7.3): + - Firebase/CoreOnly (= 10.19.0) + - React-Core + - RNFBRemoteConfig (18.7.3): + - Firebase/RemoteConfig (= 10.19.0) + - React-Core + - RNFBApp - SocketRocket (0.6.1) - Yoga (1.14.0) @@ -469,12 +512,24 @@ DEPENDENCIES: - React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`) - React-utils (from `../node_modules/react-native/ReactCommon/react/utils`) - ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`) + - RNDeviceInfo (from `../node_modules/react-native-device-info`) + - "RNFBApp (from `../node_modules/@react-native-firebase/app`)" + - "RNFBRemoteConfig (from `../node_modules/@react-native-firebase/remote-config`)" - Yoga (from `../node_modules/react-native/ReactCommon/yoga`) SPEC REPOS: trunk: + - Firebase + - FirebaseABTesting + - FirebaseCore + - FirebaseCoreInternal + - FirebaseInstallations + - FirebaseRemoteConfig + - FirebaseSharedSwift - fmt + - GoogleUtilities - libevent + - PromisesObjC - SocketRocket EXTERNAL SOURCES: @@ -555,6 +610,12 @@ EXTERNAL SOURCES: :path: "../node_modules/react-native/ReactCommon/react/utils" ReactCommon: :path: "../node_modules/react-native/ReactCommon" + RNDeviceInfo: + :path: "../node_modules/react-native-device-info" + RNFBApp: + :path: "../node_modules/@react-native-firebase/app" + RNFBRemoteConfig: + :path: "../node_modules/@react-native-firebase/remote-config" Yoga: :path: "../node_modules/react-native/ReactCommon/yoga" @@ -563,45 +624,57 @@ SPEC CHECKSUMS: DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54 FBLazyVector: 748c0ef74f2bf4b36cfcccf37916806940a64c32 FBReactNativeSpec: 966f29e4e697de53a3b366355e8f57375c856ad9 + Firebase: 63ce8ece0d43743dc28eacac0c6867a2d7fd5a9d + FirebaseABTesting: bfa3b384b68cee10a89183649c64cd7998a37a12 + FirebaseCore: dc5c7badf99d47613c52b2e3a57a64cd187f8554 + FirebaseCoreInternal: b444828ea7cfd594fca83046b95db98a2be4f290 + FirebaseInstallations: 033d199474164db20c8350736842a94fe717b960 + FirebaseRemoteConfig: a7fcc7a5941faa7e09248e91c8797340aa4c85f6 + FirebaseSharedSwift: f34eeb7d3ea87a34497629b6ca41657beadef76a fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b + GoogleUtilities: 0759d1a57ebb953965c2dfe0ba4c82e95ccc2e34 hermes-engine: 8057e75cfc1437b178ac86c8654b24e7fead7f60 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 + PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4 RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1 RCTRequired: 28469809442eb4eb5528462705f7d852948c8a74 RCTTypeSafety: e9c6c409fca2cc584e5b086862d562540cb38d29 React: 769f469909b18edfe934f0539fffb319c4c61043 React-callinvoker: e48ce12c83706401251921896576710d81e54763 - React-Codegen: a136b8094d39fd071994eaa935366e6be2239cb1 - React-Core: e548a186fb01c3a78a9aeeffa212d625ca9511bf - React-CoreModules: d226b22d06ea1bc4e49d3c073b2c6cbb42265405 + React-Codegen: 8cb364505beec45713ac224bcbb6bb41c3fc1a85 + React-Core: 56221b0ea21a0934aa1fbc4aef924e9007d60f26 + React-CoreModules: 9748a6fe4404323a3280ad3c5311d28d6f4f813b React-cxxreact: 44a3560510ead6633b6e02f9fbbdd1772fb40f92 - React-debug: 238501490155574ae9f3f8dd1c74330eba30133e + React-debug: 0a068b2ff5e6d2575d64303b37b554573d758e76 React-hermes: 46e66dc854124d7645c20bfec0a6be9542826ecd React-jsi: fbdaf4166bae60524b591b18c851b530c8cdb90c React-jsiexecutor: 3bf18ff7cb03cd8dfdce08fbbc0d15058c1d71ae React-jsinspector: 194e32c6aab382d88713ad3dd0025c5f5c4ee072 React-logger: cebf22b6cf43434e471dc561e5911b40ac01d289 - React-NativeModulesApple: 02e35e9a51e10c6422f04f5e4076a7c02243fff2 + React-NativeModulesApple: 1802a680a4cd891d2ab97780771bcb2ff11fdc0b React-perflogger: e3596db7e753f51766bceadc061936ef1472edc3 React-RCTActionSheet: 17ab132c748b4471012abbcdcf5befe860660485 - React-RCTAnimation: c8bbaab62be5817d2a31c36d5f2571e3f7dcf099 - React-RCTAppDelegate: af1c7dace233deba4b933cd1d6491fe4e3584ad1 - React-RCTBlob: 1bcf3a0341eb8d6950009b1ddb8aefaf46996b8c - React-RCTImage: 670a3486b532292649b1aef3ffddd0b495a5cee4 - React-RCTLinking: bd7ab853144aed463903237e615fd91d11b4f659 - React-RCTNetwork: be86a621f3e4724758f23ad1fdce32474ab3d829 - React-RCTSettings: 4f3a29a6d23ffa639db9701bc29af43f30781058 + React-RCTAnimation: 3fe720d2c172de51de8dc19ba091c559d22ebd9b + React-RCTAppDelegate: c64ab148e0c8139be28c76d4f159acd87560359d + React-RCTBlob: fd752f54ae335c93a36650be8129b352b852185f + React-RCTImage: a99cc31f93f72fe17d0448fd45d7a812fd50388e + React-RCTLinking: c56c6c36b85cebf1f4fa61a3493c9f01551afaab + React-RCTNetwork: 01167794715ec8ae4854caca36d4009b5e257257 + React-RCTSettings: 52790fef45f5a0655cad22ab9b9a87e675d84d8c React-RCTText: adde32164a243103aaba0b1dc7b0a2599733873e - React-RCTVibration: 6bd85328388ac2e82ae0ca11afe48ad5555b483a - React-rncore: fda7b1ae5918fa7baa259105298a5487875a57c8 + React-RCTVibration: 1c047e1d9b21992f91c21f221f360640a4a288ec + React-rncore: 87d117a5b3854f0c9c3b08d46fa83fa98a7b9f1c React-runtimeexecutor: 57d85d942862b08f6d15441a0badff2542fd233c - React-runtimescheduler: f23e337008403341177fc52ee4ca94e442c17ede - React-utils: fa59c9a3375fb6f4aeb66714fd3f7f76b43a9f16 - ReactCommon: dd03c17275c200496f346af93a7b94c53f3093a4 + React-runtimescheduler: 76eb364c37e6c20845cfe0cb049f883021bdfccf + React-utils: 1dc03e6e55f56388b6fdde3768a66c885bacb627 + ReactCommon: cfe086d2e2ec9f2907c66666c856082608fba822 + RNDeviceInfo: bf8a32acbcb875f568217285d1793b0e8588c974 + RNFBApp: 5ee688b07ed0fa692a3a8fd07df6d6ae41e4c3a0 + RNFBRemoteConfig: dc5418251c49d2f40edfd76cc935d2c36b8331b0 SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 Yoga: b76f1acfda8212aa16b7e26bcce3983230c82603 -PODFILE CHECKSUM: d5944da49023f46d0bbf077ec79388922a256f45 +PODFILE CHECKSUM: b7b1817d2fd83e1705fac92a367587ac3c36a745 COCOAPODS: 1.12.1 diff --git a/ios/SmartStop.xcodeproj/project.pbxproj b/ios/SmartStop.xcodeproj/project.pbxproj index 43cab1b..266d3b4 100644 --- a/ios/SmartStop.xcodeproj/project.pbxproj +++ b/ios/SmartStop.xcodeproj/project.pbxproj @@ -8,13 +8,14 @@ /* Begin PBXBuildFile section */ 00E356F31AD99517003FC87E /* SmartStopTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* SmartStopTests.m */; }; - 0C80B921A6F3F58F76C31292 /* libPods-SmartStop.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5DCACB8F33CDC322A6C60F78 /* libPods-SmartStop.a */; }; 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; - 7699B88040F8A987B510C191 /* libPods-SmartStop-SmartStopTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-SmartStop-SmartStopTests.a */; }; + 2CFD6FF67A2AFBB7E0E0B3CA /* Pods_SmartStop.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 591339F73B403D78EB8BCB60 /* Pods_SmartStop.framework */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; 904C36942B12DB0600B0C7C3 /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 90BEE4642AFC5DCD0014196C /* MaterialCommunityIcons.ttf */; }; + 90BF95BA2B361DF800182B5A /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 90BF95B92B361DF800182B5A /* GoogleService-Info.plist */; }; + DD77F3C499C8D3941589212A /* Pods_SmartStop_SmartStopTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8259ABFC09C9E604639AC83F /* Pods_SmartStop_SmartStopTests.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -37,14 +38,15 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = SmartStop/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = SmartStop/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = SmartStop/main.m; sourceTree = ""; }; - 19F6CBCC0A4E27FBF8BF4A61 /* libPods-SmartStop-SmartStopTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SmartStop-SmartStopTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3B4392A12AC88292D35C810B /* Pods-SmartStop.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SmartStop.debug.xcconfig"; path = "Target Support Files/Pods-SmartStop/Pods-SmartStop.debug.xcconfig"; sourceTree = ""; }; 5709B34CF0A7D63546082F79 /* Pods-SmartStop.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SmartStop.release.xcconfig"; path = "Target Support Files/Pods-SmartStop/Pods-SmartStop.release.xcconfig"; sourceTree = ""; }; + 591339F73B403D78EB8BCB60 /* Pods_SmartStop.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SmartStop.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 5B7EB9410499542E8C5724F5 /* Pods-SmartStop-SmartStopTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SmartStop-SmartStopTests.debug.xcconfig"; path = "Target Support Files/Pods-SmartStop-SmartStopTests/Pods-SmartStop-SmartStopTests.debug.xcconfig"; sourceTree = ""; }; - 5DCACB8F33CDC322A6C60F78 /* libPods-SmartStop.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SmartStop.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = SmartStop/LaunchScreen.storyboard; sourceTree = ""; }; + 8259ABFC09C9E604639AC83F /* Pods_SmartStop_SmartStopTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SmartStop_SmartStopTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 89C6BE57DB24E9ADA2F236DE /* Pods-SmartStop-SmartStopTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SmartStop-SmartStopTests.release.xcconfig"; path = "Target Support Files/Pods-SmartStop-SmartStopTests/Pods-SmartStop-SmartStopTests.release.xcconfig"; sourceTree = ""; }; 90BEE4642AFC5DCD0014196C /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = MaterialCommunityIcons.ttf; sourceTree = ""; }; + 90BF95B92B361DF800182B5A /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "SmartStop/GoogleService-Info.plist"; sourceTree = ""; }; ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; }; /* End PBXFileReference section */ @@ -53,7 +55,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 7699B88040F8A987B510C191 /* libPods-SmartStop-SmartStopTests.a in Frameworks */, + DD77F3C499C8D3941589212A /* Pods_SmartStop_SmartStopTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -61,7 +63,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 0C80B921A6F3F58F76C31292 /* libPods-SmartStop.a in Frameworks */, + 2CFD6FF67A2AFBB7E0E0B3CA /* Pods_SmartStop.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -102,8 +104,8 @@ isa = PBXGroup; children = ( ED297162215061F000B7C4FE /* JavaScriptCore.framework */, - 5DCACB8F33CDC322A6C60F78 /* libPods-SmartStop.a */, - 19F6CBCC0A4E27FBF8BF4A61 /* libPods-SmartStop-SmartStopTests.a */, + 591339F73B403D78EB8BCB60 /* Pods_SmartStop.framework */, + 8259ABFC09C9E604639AC83F /* Pods_SmartStop_SmartStopTests.framework */, ); name = Frameworks; sourceTree = ""; @@ -118,6 +120,7 @@ 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( + 90BF95B92B361DF800182B5A /* GoogleService-Info.plist */, 90BEE45D2AFC5DCD0014196C /* Fonts */, 13B07FAE1A68108700A75B9A /* SmartStop */, 832341AE1AAA6A7D00B99B32 /* Libraries */, @@ -196,6 +199,7 @@ 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */, 00EEFC60759A1932668264C0 /* [CP] Embed Pods Frameworks */, E235C05ADACE081382539298 /* [CP] Copy Pods Resources */, + 98C271DDEE989C57E9B4F19A /* [CP-User] [RNFB] Core Configuration */, ); buildRules = ( ); @@ -255,6 +259,7 @@ buildActionMask = 2147483647; files = ( 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, + 90BF95BA2B361DF800182B5A /* GoogleService-Info.plist in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, 904C36942B12DB0600B0C7C3 /* MaterialCommunityIcons.ttf in Resources */, ); @@ -296,6 +301,19 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SmartStop/Pods-SmartStop-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; + 98C271DDEE989C57E9B4F19A /* [CP-User] [RNFB] Core Configuration */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)", + ); + name = "[CP-User] [RNFB] Core Configuration"; + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#!/usr/bin/env bash\n#\n# Copyright (c) 2016-present Invertase Limited & Contributors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this library except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\nset -e\n\n_MAX_LOOKUPS=2;\n_SEARCH_RESULT=''\n_RN_ROOT_EXISTS=''\n_CURRENT_LOOKUPS=1\n_JSON_ROOT=\"'react-native'\"\n_JSON_FILE_NAME='firebase.json'\n_JSON_OUTPUT_BASE64='e30=' # { }\n_CURRENT_SEARCH_DIR=${PROJECT_DIR}\n_PLIST_BUDDY=/usr/libexec/PlistBuddy\n_TARGET_PLIST=\"${BUILT_PRODUCTS_DIR}/${INFOPLIST_PATH}\"\n_DSYM_PLIST=\"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Info.plist\"\n\n# plist arrays\n_PLIST_ENTRY_KEYS=()\n_PLIST_ENTRY_TYPES=()\n_PLIST_ENTRY_VALUES=()\n\nfunction setPlistValue {\n echo \"info: setting plist entry '$1' of type '$2' in file '$4'\"\n ${_PLIST_BUDDY} -c \"Add :$1 $2 '$3'\" $4 || echo \"info: '$1' already exists\"\n}\n\nfunction getFirebaseJsonKeyValue () {\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n ruby -Ku -e \"require 'rubygems';require 'json'; output=JSON.parse('$1'); puts output[$_JSON_ROOT]['$2']\"\n else\n echo \"\"\n fi;\n}\n\nfunction jsonBoolToYesNo () {\n if [[ $1 == \"false\" ]]; then\n echo \"NO\"\n elif [[ $1 == \"true\" ]]; then\n echo \"YES\"\n else echo \"NO\"\n fi\n}\n\necho \"info: -> RNFB build script started\"\necho \"info: 1) Locating ${_JSON_FILE_NAME} file:\"\n\nif [[ -z ${_CURRENT_SEARCH_DIR} ]]; then\n _CURRENT_SEARCH_DIR=$(pwd)\nfi;\n\nwhile true; do\n _CURRENT_SEARCH_DIR=$(dirname \"$_CURRENT_SEARCH_DIR\")\n if [[ \"$_CURRENT_SEARCH_DIR\" == \"/\" ]] || [[ ${_CURRENT_LOOKUPS} -gt ${_MAX_LOOKUPS} ]]; then break; fi;\n echo \"info: ($_CURRENT_LOOKUPS of $_MAX_LOOKUPS) Searching in '$_CURRENT_SEARCH_DIR' for a ${_JSON_FILE_NAME} file.\"\n _SEARCH_RESULT=$(find \"$_CURRENT_SEARCH_DIR\" -maxdepth 2 -name ${_JSON_FILE_NAME} -print | /usr/bin/head -n 1)\n if [[ ${_SEARCH_RESULT} ]]; then\n echo \"info: ${_JSON_FILE_NAME} found at $_SEARCH_RESULT\"\n break;\n fi;\n _CURRENT_LOOKUPS=$((_CURRENT_LOOKUPS+1))\ndone\n\nif [[ ${_SEARCH_RESULT} ]]; then\n _JSON_OUTPUT_RAW=$(cat \"${_SEARCH_RESULT}\")\n _RN_ROOT_EXISTS=$(ruby -Ku -e \"require 'rubygems';require 'json'; output=JSON.parse('$_JSON_OUTPUT_RAW'); puts output[$_JSON_ROOT]\" || echo '')\n\n if [[ ${_RN_ROOT_EXISTS} ]]; then\n if ! python3 --version >/dev/null 2>&1; then echo \"python3 not found, firebase.json file processing error.\" && exit 1; fi\n _JSON_OUTPUT_BASE64=$(python3 -c 'import json,sys,base64;print(base64.b64encode(bytes(json.dumps(json.loads(open('\"'${_SEARCH_RESULT}'\"', '\"'rb'\"').read())['${_JSON_ROOT}']), '\"'utf-8'\"')).decode())' || echo \"e30=\")\n fi\n\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n\n # config.app_data_collection_default_enabled\n _APP_DATA_COLLECTION_ENABLED=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"app_data_collection_default_enabled\")\n if [[ $_APP_DATA_COLLECTION_ENABLED ]]; then\n _PLIST_ENTRY_KEYS+=(\"FirebaseDataCollectionDefaultEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_APP_DATA_COLLECTION_ENABLED\")\")\n fi\n\n # config.analytics_auto_collection_enabled\n _ANALYTICS_AUTO_COLLECTION=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"analytics_auto_collection_enabled\")\n if [[ $_ANALYTICS_AUTO_COLLECTION ]]; then\n _PLIST_ENTRY_KEYS+=(\"FIREBASE_ANALYTICS_COLLECTION_ENABLED\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_ANALYTICS_AUTO_COLLECTION\")\")\n fi\n\n # config.analytics_collection_deactivated\n _ANALYTICS_DEACTIVATED=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"analytics_collection_deactivated\")\n if [[ $_ANALYTICS_DEACTIVATED ]]; then\n _PLIST_ENTRY_KEYS+=(\"FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_ANALYTICS_DEACTIVATED\")\")\n fi\n\n # config.analytics_idfv_collection_enabled\n _ANALYTICS_IDFV_COLLECTION=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"analytics_idfv_collection_enabled\")\n if [[ $_ANALYTICS_IDFV_COLLECTION ]]; then\n _PLIST_ENTRY_KEYS+=(\"GOOGLE_ANALYTICS_IDFV_COLLECTION_ENABLED\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_ANALYTICS_IDFV_COLLECTION\")\")\n fi\n\n # config.analytics_default_allow_ad_personalization_signals\n _ANALYTICS_PERSONALIZATION=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"analytics_default_allow_ad_personalization_signals\")\n if [[ $_ANALYTICS_PERSONALIZATION ]]; then\n _PLIST_ENTRY_KEYS+=(\"GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_ANALYTICS_PERSONALIZATION\")\")\n fi\n\n # config.analytics_registration_with_ad_network_enabled\n _ANALYTICS_REGISTRATION_WITH_AD_NETWORK=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"google_analytics_registration_with_ad_network_enabled\")\n if [[ $_ANALYTICS_REGISTRATION_WITH_AD_NETWORK ]]; then\n _PLIST_ENTRY_KEYS+=(\"GOOGLE_ANALYTICS_REGISTRATION_WITH_AD_NETWORK_ENABLED\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_ANALYTICS_REGISTRATION_WITH_AD_NETWORK\")\")\n fi\n\n # config.google_analytics_automatic_screen_reporting_enabled\n _ANALYTICS_AUTO_SCREEN_REPORTING=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"google_analytics_automatic_screen_reporting_enabled\")\n if [[ $_ANALYTICS_AUTO_SCREEN_REPORTING ]]; then\n _PLIST_ENTRY_KEYS+=(\"FirebaseAutomaticScreenReportingEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_ANALYTICS_AUTO_SCREEN_REPORTING\")\")\n fi\n\n # config.perf_auto_collection_enabled\n _PERF_AUTO_COLLECTION=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"perf_auto_collection_enabled\")\n if [[ $_PERF_AUTO_COLLECTION ]]; then\n _PLIST_ENTRY_KEYS+=(\"firebase_performance_collection_enabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_PERF_AUTO_COLLECTION\")\")\n fi\n\n # config.perf_collection_deactivated\n _PERF_DEACTIVATED=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"perf_collection_deactivated\")\n if [[ $_PERF_DEACTIVATED ]]; then\n _PLIST_ENTRY_KEYS+=(\"firebase_performance_collection_deactivated\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_PERF_DEACTIVATED\")\")\n fi\n\n # config.messaging_auto_init_enabled\n _MESSAGING_AUTO_INIT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"messaging_auto_init_enabled\")\n if [[ $_MESSAGING_AUTO_INIT ]]; then\n _PLIST_ENTRY_KEYS+=(\"FirebaseMessagingAutoInitEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_MESSAGING_AUTO_INIT\")\")\n fi\n\n # config.in_app_messaging_auto_colllection_enabled\n _FIAM_AUTO_INIT=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"in_app_messaging_auto_collection_enabled\")\n if [[ $_FIAM_AUTO_INIT ]]; then\n _PLIST_ENTRY_KEYS+=(\"FirebaseInAppMessagingAutomaticDataCollectionEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_FIAM_AUTO_INIT\")\")\n fi\n\n # config.app_check_token_auto_refresh\n _APP_CHECK_TOKEN_AUTO_REFRESH=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"app_check_token_auto_refresh\")\n if [[ $_APP_CHECK_TOKEN_AUTO_REFRESH ]]; then\n _PLIST_ENTRY_KEYS+=(\"FirebaseAppCheckTokenAutoRefreshEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"$(jsonBoolToYesNo \"$_APP_CHECK_TOKEN_AUTO_REFRESH\")\")\n fi\n\n # config.crashlytics_disable_auto_disabler - undocumented for now - mainly for debugging, document if becomes useful\n _CRASHLYTICS_AUTO_DISABLE_ENABLED=$(getFirebaseJsonKeyValue \"$_JSON_OUTPUT_RAW\" \"crashlytics_disable_auto_disabler\")\n if [[ $_CRASHLYTICS_AUTO_DISABLE_ENABLED == \"true\" ]]; then\n echo \"Disabled Crashlytics auto disabler.\" # do nothing\n else\n _PLIST_ENTRY_KEYS+=(\"FirebaseCrashlyticsCollectionEnabled\")\n _PLIST_ENTRY_TYPES+=(\"bool\")\n _PLIST_ENTRY_VALUES+=(\"NO\")\n fi\nelse\n _PLIST_ENTRY_KEYS+=(\"firebase_json_raw\")\n _PLIST_ENTRY_TYPES+=(\"string\")\n _PLIST_ENTRY_VALUES+=(\"$_JSON_OUTPUT_BASE64\")\n echo \"warning: A firebase.json file was not found, whilst this file is optional it is recommended to include it to configure firebase services in React Native Firebase.\"\nfi;\n\necho \"info: 2) Injecting Info.plist entries: \"\n\n# Log out the keys we're adding\nfor i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n echo \" -> $i) ${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\"\ndone\n\nfor plist in \"${_TARGET_PLIST}\" \"${_DSYM_PLIST}\" ; do\n if [[ -f \"${plist}\" ]]; then\n\n # paths with spaces break the call to setPlistValue. temporarily modify\n # the shell internal field separator variable (IFS), which normally\n # includes spaces, to consist only of line breaks\n oldifs=$IFS\n IFS=\"\n\"\n\n for i in \"${!_PLIST_ENTRY_KEYS[@]}\"; do\n setPlistValue \"${_PLIST_ENTRY_KEYS[$i]}\" \"${_PLIST_ENTRY_TYPES[$i]}\" \"${_PLIST_ENTRY_VALUES[$i]}\" \"${plist}\"\n done\n\n # restore the original internal field separator value\n IFS=$oldifs\n else\n echo \"warning: A Info.plist build output file was not found (${plist})\"\n fi\ndone\n\necho \"info: <- RNFB build script finished\"\n"; + }; A55EABD7B0C7F3A422A6CC61 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -594,6 +612,14 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios", + "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios", + ); IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, @@ -668,6 +694,14 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core", + "${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios", + "${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers", + "${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios", + ); IPHONEOS_DEPLOYMENT_TARGET = 12.4; LD_RUNPATH_SEARCH_PATHS = ( /usr/lib/swift, diff --git a/ios/SmartStop/AppDelegate.mm b/ios/SmartStop/AppDelegate.mm index 59eac2f..27a0fc0 100644 --- a/ios/SmartStop/AppDelegate.mm +++ b/ios/SmartStop/AppDelegate.mm @@ -1,11 +1,15 @@ #import "AppDelegate.h" +#import + #import @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [FIRApp configure]; + self.moduleName = @"SmartStop"; // You can add your custom initial props in the dictionary below. // They will be passed down to the ViewController used by React Native. diff --git a/ios/SmartStop/GoogleService-Info.plist b/ios/SmartStop/GoogleService-Info.plist new file mode 100644 index 0000000..cb687d0 --- /dev/null +++ b/ios/SmartStop/GoogleService-Info.plist @@ -0,0 +1,30 @@ + + + + + API_KEY + AIzaSyB5Mbo_1XyOPLFq13kkhohBkKFxDJSxzx8 + GCM_SENDER_ID + 473250290916 + PLIST_VERSION + 1 + BUNDLE_ID + org.reactjs.native.example.SmartStop + PROJECT_ID + smartstop-7a69d + STORAGE_BUCKET + smartstop-7a69d.appspot.com + IS_ADS_ENABLED + + IS_ANALYTICS_ENABLED + + IS_APPINVITE_ENABLED + + IS_GCM_ENABLED + + IS_SIGNIN_ENABLED + + GOOGLE_APP_ID + 1:473250290916:ios:a0dc0e9ba3d23cd463e0f1 + + \ No newline at end of file diff --git a/package.json b/package.json index 5b5d702..181e4cd 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "test": "jest" }, "dependencies": { + "@react-native-firebase/app": "^18.7.3", + "@react-native-firebase/remote-config": "^18.7.3", "axios": "^1.6.2", "moment": "^2.29.4", "react": "18.2.0", diff --git a/src/infraestructure/api/models/DeviceInfoResponse.ts b/src/infraestructure/api/models/DeviceInfoResponse.ts index 5a209da..a6bd913 100644 --- a/src/infraestructure/api/models/DeviceInfoResponse.ts +++ b/src/infraestructure/api/models/DeviceInfoResponse.ts @@ -1,4 +1,4 @@ -import LineDetail from './LineDetail'; +import LineDetail from '../../../domain/repositories/LineDetail'; interface DeviceInfoResponse { stopMessage: string; diff --git a/src/infraestructure/hooks/__tests__/useDevices.spec.ts b/src/infraestructure/hooks/__tests__/useDevices.spec.ts index 0e14db7..2b8c617 100644 --- a/src/infraestructure/hooks/__tests__/useDevices.spec.ts +++ b/src/infraestructure/hooks/__tests__/useDevices.spec.ts @@ -1,13 +1,163 @@ +import {renderHook, waitFor} from '@testing-library/react-native'; +import useDevices from '../useDevices'; +import AuthRepositoryImpl from '../../repositories/AuthRepositoryImpl'; +import DevicesRepositoryImpl from '../../repositories/DevicesRepositoryImpl'; + describe('useDevices tests', () => { + beforeAll(() => { + jest.spyOn(AuthRepositoryImpl.prototype, 'auth').mockResolvedValue('token'); + jest + .spyOn(DevicesRepositoryImpl.prototype, 'getDeviceInfo') + .mockResolvedValue({ + lineDetails: [ + { + lineNumber: '803010', + description: 'Tucapel', + locomotionType: 1, + backgroundColor: 'Hexadecimal', + letterColor: 'Hexadecimal', + lineMessage: '', + arrivals: [ + { + carPlate: 'RPDA-98', + planned: '', + estimatedGPS: '15:08', + distanceGPS: '1.0 KM', + }, + { + carPlate: 'WYXYZ-22', + planned: '', + estimatedGPS: '15:42', + distanceGPS: '5.0 KM', + }, + { + carPlate: 'ABCA-65', + planned: '', + estimatedGPS: '16:18', + distanceGPS: '13.4 KM', + }, + ], + }, + { + lineNumber: '5487', + description: 'Centauro', + locomotionType: 1, + backgroundColor: 'Hexadecimal', + letterColor: 'Hexadecimal', + lineMessage: 'Sin info. GPS, la informacion es estimada', + arrivals: [ + { + carPlate: 'PLKJ-32', + planned: '15:13', + estimatedGPS: '', + distanceGPS: '', + }, + { + carPlate: 'GHLK-11', + planned: '15:39', + estimatedGPS: '', + distanceGPS: '', + }, + { + carPlate: 'DFQW-55', + planned: '16:22', + estimatedGPS: '', + distanceGPS: '', + }, + ], + }, + ], + stopMessage: 'No considerar, uso futuro', + }); + jest.spyOn(DevicesRepositoryImpl.prototype, 'whoAmI').mockResolvedValue({ + stopNumber: '37477', + stopName: "O'Higgins - entre Angol y Salas", + }); + }); + it('should be defined', () => { expect(true).toBeTruthy(); }); - it('should return stop information', () => { - expect(true).toBeTruthy(); + it('should return stop information', async () => { + const {result} = renderHook(() => useDevices()); + + await waitFor(() => { + expect(result.current.state.stopName).toStrictEqual( + "O'Higgins - entre Angol y Salas", + ); + expect(result.current.state.stopMessage).toStrictEqual( + 'No considerar, uso futuro', + ); + }); }); - it('should return a list of devices', () => { - expect(true).toBeTruthy(); + it('should return a list of devices', async () => { + const mockDate = new Date('2023-01-01T14:00:00Z'); + const spy = jest.spyOn(global, 'Date').mockImplementation(() => mockDate); + const {result} = renderHook(() => useDevices()); + + await waitFor(() => { + expect(result.current.state.lines).toMatchObject([ + { + arrivals: [ + { + carPlate: 'RPDA-98', + distanceGPS: '1.0 KM', + estimatedGPS: '15:08', + planned: '', + }, + { + carPlate: 'WYXYZ-22', + distanceGPS: '5.0 KM', + estimatedGPS: '15:42', + planned: '', + }, + { + carPlate: 'ABCA-65', + distanceGPS: '13.4 KM', + estimatedGPS: '16:18', + planned: '', + }, + ], + backgroundColor: 'Hexadecimal', + description: 'Tucapel', + letterColor: 'Hexadecimal', + lineMessage: '', + lineNumber: '803010', + locomotionType: 1, + }, + { + arrivals: [ + { + carPlate: 'PLKJ-32', + distanceGPS: '', + estimatedGPS: '', + planned: '15:13', + }, + { + carPlate: 'GHLK-11', + distanceGPS: '', + estimatedGPS: '', + planned: '15:39', + }, + { + carPlate: 'DFQW-55', + distanceGPS: '', + estimatedGPS: '', + planned: '16:22', + }, + ], + backgroundColor: 'Hexadecimal', + description: 'Centauro', + letterColor: 'Hexadecimal', + lineMessage: 'Sin info. GPS, la informacion es estimada', + lineNumber: '5487', + locomotionType: 1, + }, + ]); + }); + + spy.mockRestore(); }); }); diff --git a/src/infraestructure/hooks/__tests__/useLogin.spec.ts b/src/infraestructure/hooks/__tests__/useLogin.spec.ts deleted file mode 100644 index bb8af15..0000000 --- a/src/infraestructure/hooks/__tests__/useLogin.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -describe('useLogin tests', () => { - it('should be defined', () => { - expect(true).toBeTruthy(); - }); - - it('should return a token', () => { - expect(true).toBeTruthy(); - }); -}); diff --git a/src/infraestructure/hooks/useDevices.ts b/src/infraestructure/hooks/useDevices.ts index c7af1f5..c30e759 100644 --- a/src/infraestructure/hooks/useDevices.ts +++ b/src/infraestructure/hooks/useDevices.ts @@ -1,4 +1,5 @@ import {useCallback, useEffect, useMemo, useState} from 'react'; +import remoteConfig from '@react-native-firebase/remote-config'; import DevicesRepositoryImpl from '../repositories/DevicesRepositoryImpl'; import DevicesAPI from '../api/clients/DevicesAPI'; import AuthRepositoryImpl from '../repositories/AuthRepositoryImpl'; @@ -7,6 +8,7 @@ import LineDetail from '../../domain/repositories/LineDetail'; import {Line} from '../../presentation/screens/BusStopInfoScreen'; import BusStopInfoService from '../../domain/services/BusStopInfoService'; +import RemoteConfigKeys from '../../utils/RemoteConfigKeys'; export enum Status { LOADING = 'LOADING', @@ -24,9 +26,6 @@ interface State { } const DEVICE_ID = 'TTM543870hyt'; -const BASE_URL = 'https://transporte.hz.kursor.cl'; -const USER = 'usuario1'; -const PASSWORD = 'usuario1'; const useDevices = () => { const [state, setState] = useState({ @@ -38,11 +37,15 @@ const useDevices = () => { stopName: 'Sin información - Sin información', }); - const baseUrl = BASE_URL; // TODO: remoteconfig ? - const username = USER; - const password = PASSWORD; - const deviceApi = useMemo(() => new DevicesAPI(baseUrl), [baseUrl]); - const authApi = useMemo(() => new AuthAPI(baseUrl), [baseUrl]); + const baseURL = remoteConfig().getString(RemoteConfigKeys.BASE_URL); + const username = remoteConfig().getString(RemoteConfigKeys.USER); + const password = remoteConfig().getString(RemoteConfigKeys.PASS); + const updateInterval = remoteConfig().getNumber( + RemoteConfigKeys.UPDATE_INTERVAL, + ); + + const deviceApi = useMemo(() => new DevicesAPI(baseURL), [baseURL]); + const authApi = useMemo(() => new AuthAPI(baseURL), [baseURL]); const devicesRepository = useMemo( () => new DevicesRepositoryImpl(deviceApi), [deviceApi], @@ -76,7 +79,7 @@ const useDevices = () => { busStopInfoService = new BusStopInfoService(linesWithArrivals); const linesToDisplay: Line[] = busStopInfoService - .pruneBusList(state.currentIndex, 21) // result 7 * 3 + .pruneBusList(state.currentIndex, 21) // result 7 rows * 3 columns .map(line => { try { const nextArraival = busStopInfoService.getNextArraival( @@ -142,7 +145,6 @@ const useDevices = () => { const init = async () => { try { const token = await authRepository.auth({username, password}); - const {lineDetails, stopMessage} = await devicesRepository.getDeviceInfo({ deviceId: DEVICE_ID, @@ -204,7 +206,7 @@ const useDevices = () => { return () => { clearInterval(interval); }; - }, [state.lines, state.status]); + }, [state.lines, state.status, updateInterval]); return {state}; }; diff --git a/src/infraestructure/hooks/useLogin.ts b/src/infraestructure/hooks/useLogin.ts deleted file mode 100644 index e69de29..0000000 diff --git a/src/presentation/components/Header.tsx b/src/presentation/components/Header.tsx index c76bb80..514c3bc 100644 --- a/src/presentation/components/Header.tsx +++ b/src/presentation/components/Header.tsx @@ -1,18 +1,30 @@ -import {View, Text, StyleSheet, StyleProp, ViewStyle} from 'react-native'; +import { + View, + Text, + StyleSheet, + StyleProp, + ViewStyle, + Image, +} from 'react-native'; import Container from './Container'; -import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; interface HeaderProps { title?: string; subTitle?: string; style?: StyleProp; + image?: string; } -const Header = ({title, subTitle, style}: HeaderProps) => { +const Header = ({title, subTitle, style, image}: HeaderProps) => { return ( - + {title} @@ -39,17 +51,21 @@ const styles = StyleSheet.create({ flexDirection: 'row', alignItems: 'stretch', }, + icon: { + width: 100, + height: 100, + resizeMode: 'contain', + }, iconContainer: { justifyContent: 'center', - alignContent: 'center', - overflow: 'hidden', + alignItems: 'center', + marginHorizontal: 8, }, titleContainer: { flex: 1, flexDirection: 'column', justifyContent: 'center', - alignItems: 'center', - marginRight: 16, + marginHorizontal: 16, }, title: { fontSize: 24, diff --git a/src/presentation/components/__tests__/__snapshots__/Header.spec.tsx.snap b/src/presentation/components/__tests__/__snapshots__/Header.spec.tsx.snap index ed78955..e2853f1 100644 --- a/src/presentation/components/__tests__/__snapshots__/Header.spec.tsx.snap +++ b/src/presentation/components/__tests__/__snapshots__/Header.spec.tsx.snap @@ -20,42 +20,34 @@ exports[`Header tests should render correctly 1`] = ` - - 󰃧 - + style={ + { + "height": 100, + "resizeMode": "contain", + "width": 100, + } + } + /> diff --git a/src/presentation/screens/BusStopInfoScreen.tsx b/src/presentation/screens/BusStopInfoScreen.tsx index 51a761e..af54cb8 100644 --- a/src/presentation/screens/BusStopInfoScreen.tsx +++ b/src/presentation/screens/BusStopInfoScreen.tsx @@ -4,6 +4,9 @@ import Header from '../components/Header'; import {Text} from 'react-native'; import useDevices, {Status} from '../../infraestructure/hooks/useDevices'; import Banner from '../components/Banner'; +import {useEffect, useState} from 'react'; +import remoteConfig from '@react-native-firebase/remote-config'; +import RemoteConfigKeys from '../../utils/RemoteConfigKeys'; export interface Line { lineNumber: string; @@ -91,17 +94,52 @@ const BusStopInfoScreen = () => { const { state: {status, displayedLines, stopName}, } = useDevices(); + const [isLoading, setIsLoading] = useState(true); + const image = remoteConfig().getString(RemoteConfigKeys.HEADER_IMAGE_URL); + + useEffect(() => { + const init = async () => { + await remoteConfig().setConfigSettings({ + minimumFetchIntervalMillis: 3600000, + }); + + await remoteConfig().setDefaults({ + BASE_URL: '', + HEADER_IMAGE_URL: '', + UPDATE_INTERVAL: 0, + USER: '', + PASS: '', + }); + + const isActivated = await remoteConfig().fetchAndActivate(); + + if (isActivated) { + setIsLoading(false); + } + }; + + init(); + }, []); const splitStopName = stopName.split('-'); let title = splitStopName[0] ? `${splitStopName[0].trim()}` : ''; const subTitle = splitStopName[1] ? `${splitStopName[1].trim()}` : ''; + if (isLoading) { + return ( + + + + ); + } + return (