mirror of https://gitlab.com/m3f_usm/SmartStopAPK
feat: remote-config is added
parent
67aa6e9e36
commit
465a220a97
|
@ -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;
|
|
@ -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']
|
||||
]
|
||||
|
|
|
@ -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"
|
||||
}
|
|
@ -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'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
109
ios/Podfile.lock
109
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
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,11 +1,15 @@
|
|||
#import "AppDelegate.h"
|
||||
|
||||
#import <Firebase.h>
|
||||
|
||||
#import <React/RCTBundleURLProvider.h>
|
||||
|
||||
@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.
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>API_KEY</key>
|
||||
<string>AIzaSyB5Mbo_1XyOPLFq13kkhohBkKFxDJSxzx8</string>
|
||||
<key>GCM_SENDER_ID</key>
|
||||
<string>473250290916</string>
|
||||
<key>PLIST_VERSION</key>
|
||||
<string>1</string>
|
||||
<key>BUNDLE_ID</key>
|
||||
<string>org.reactjs.native.example.SmartStop</string>
|
||||
<key>PROJECT_ID</key>
|
||||
<string>smartstop-7a69d</string>
|
||||
<key>STORAGE_BUCKET</key>
|
||||
<string>smartstop-7a69d.appspot.com</string>
|
||||
<key>IS_ADS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_ANALYTICS_ENABLED</key>
|
||||
<false></false>
|
||||
<key>IS_APPINVITE_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_GCM_ENABLED</key>
|
||||
<true></true>
|
||||
<key>IS_SIGNIN_ENABLED</key>
|
||||
<true></true>
|
||||
<key>GOOGLE_APP_ID</key>
|
||||
<string>1:473250290916:ios:a0dc0e9ba3d23cd463e0f1</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -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",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import LineDetail from './LineDetail';
|
||||
import LineDetail from '../../../domain/repositories/LineDetail';
|
||||
|
||||
interface DeviceInfoResponse {
|
||||
stopMessage: string;
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
describe('useLogin tests', () => {
|
||||
it('should be defined', () => {
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return a token', () => {
|
||||
expect(true).toBeTruthy();
|
||||
});
|
||||
});
|
|
@ -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<State>({
|
||||
|
@ -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};
|
||||
};
|
||||
|
|
|
@ -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<ViewStyle>;
|
||||
image?: string;
|
||||
}
|
||||
const Header = ({title, subTitle, style}: HeaderProps) => {
|
||||
const Header = ({title, subTitle, style, image}: HeaderProps) => {
|
||||
return (
|
||||
<Container style={style}>
|
||||
<View style={styles.contentContainer}>
|
||||
<View style={styles.iconContainer}>
|
||||
<Icon name="bus" size={70} color={'white'} />
|
||||
<Image
|
||||
source={{
|
||||
uri: 'https://cdn-icons-png.flaticon.com/512/8371/8371047.png',
|
||||
}}
|
||||
style={styles.icon}
|
||||
/>
|
||||
</View>
|
||||
<View style={styles.titleContainer}>
|
||||
<Text style={styles.title}>{title}</Text>
|
||||
|
@ -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,
|
||||
|
|
|
@ -20,42 +20,34 @@ exports[`Header tests should render correctly 1`] = `
|
|||
<View
|
||||
style={
|
||||
{
|
||||
"alignContent": "center",
|
||||
"alignItems": "center",
|
||||
"justifyContent": "center",
|
||||
"overflow": "hidden",
|
||||
"marginHorizontal": 8,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Text
|
||||
allowFontScaling={false}
|
||||
selectable={false}
|
||||
style={
|
||||
[
|
||||
{
|
||||
"color": "white",
|
||||
"fontSize": 70,
|
||||
},
|
||||
undefined,
|
||||
{
|
||||
"fontFamily": "Material Design Icons",
|
||||
"fontStyle": "normal",
|
||||
"fontWeight": "normal",
|
||||
},
|
||||
{},
|
||||
]
|
||||
<Image
|
||||
source={
|
||||
{
|
||||
"uri": "https://cdn-icons-png.flaticon.com/512/8371/8371047.png",
|
||||
}
|
||||
}
|
||||
>
|
||||
|
||||
</Text>
|
||||
style={
|
||||
{
|
||||
"height": 100,
|
||||
"resizeMode": "contain",
|
||||
"width": 100,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
style={
|
||||
{
|
||||
"alignItems": "center",
|
||||
"flex": 1,
|
||||
"flexDirection": "column",
|
||||
"justifyContent": "center",
|
||||
"marginRight": 16,
|
||||
"marginHorizontal": 16,
|
||||
}
|
||||
}
|
||||
>
|
||||
|
|
|
@ -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 (
|
||||
<Container style={styles.container}>
|
||||
<ActivityIndicator />
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Container style={styles.container}>
|
||||
<Header
|
||||
style={styles.headerContainer}
|
||||
subTitle={subTitle}
|
||||
title={title}
|
||||
image={image}
|
||||
/>
|
||||
<Banner
|
||||
style={styles.bannerContainer}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
enum RemoteConfigKeys {
|
||||
BASE_URL = 'BASE_URL',
|
||||
HEADER_IMAGE_URL = 'HEADER_IMAGE_URL',
|
||||
UPDATE_INTERVAL = 'UPDATE_INTERVAL',
|
||||
USER = 'USER',
|
||||
PASS = 'PASSWORD',
|
||||
}
|
||||
export default RemoteConfigKeys;
|
82
yarn.lock
82
yarn.lock
|
@ -1889,6 +1889,19 @@
|
|||
resolved "https://registry.yarnpkg.com/@react-native-community/eslint-plugin/-/eslint-plugin-1.3.0.tgz#9e558170c106bbafaa1ef502bd8e6d4651012bf9"
|
||||
integrity sha512-+zDZ20NUnSWghj7Ku5aFphMzuM9JulqCW+aPXT6IfIXFbb8tzYTTOSeRFOtuekJ99ibW2fUCSsjuKNlwDIbHFg==
|
||||
|
||||
"@react-native-firebase/app@^18.7.3":
|
||||
version "18.7.3"
|
||||
resolved "https://registry.yarnpkg.com/@react-native-firebase/app/-/app-18.7.3.tgz#e2d7d41b8df6173d270116762638f7e75cca76fe"
|
||||
integrity sha512-KlUuLSCYrBMHXE2Evye1fzrqunUjFEPihxcpzuUyJ5yQyAuCNws7VGdEPIaXoKz1esof0uv8wMSxD+G6W+Vi8Q==
|
||||
dependencies:
|
||||
opencollective-postinstall "^2.0.3"
|
||||
superstruct "^0.6.2"
|
||||
|
||||
"@react-native-firebase/remote-config@^18.7.3":
|
||||
version "18.7.3"
|
||||
resolved "https://registry.yarnpkg.com/@react-native-firebase/remote-config/-/remote-config-18.7.3.tgz#9993d7ada08d119ef12320bfade317c71545a815"
|
||||
integrity sha512-Cxntq5X/Gk1xGZyU+LKVl4boKDaVh2UVZCOmHGJZ7sTCmxbKPN/t2GU5MUHQc28PvB9uLewXesm7qL6E30I8Iw==
|
||||
|
||||
"@react-native/assets-registry@^0.72.0":
|
||||
version "0.72.0"
|
||||
resolved "https://registry.yarnpkg.com/@react-native/assets-registry/-/assets-registry-0.72.0.tgz#c82a76a1d86ec0c3907be76f7faf97a32bbed05d"
|
||||
|
@ -2918,6 +2931,16 @@ cliui@^8.0.1:
|
|||
strip-ansi "^6.0.1"
|
||||
wrap-ansi "^7.0.0"
|
||||
|
||||
clone-deep@^2.0.1:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-2.0.2.tgz#00db3a1e173656730d1188c3d6aced6d7ea97713"
|
||||
integrity sha512-SZegPTKjCgpQH63E+eN6mVEEPdQBOUzjyJm5Pora4lrwWRFS8I0QAxV/KD6vV/i0WuijHZWQC1fMsPEdxfdVCQ==
|
||||
dependencies:
|
||||
for-own "^1.0.0"
|
||||
is-plain-object "^2.0.4"
|
||||
kind-of "^6.0.0"
|
||||
shallow-clone "^1.0.0"
|
||||
|
||||
clone-deep@^4.0.1:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387"
|
||||
|
@ -3842,6 +3865,23 @@ for-each@^0.3.3:
|
|||
dependencies:
|
||||
is-callable "^1.1.3"
|
||||
|
||||
for-in@^0.1.3:
|
||||
version "0.1.8"
|
||||
resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.8.tgz#d8773908e31256109952b1fdb9b3fa867d2775e1"
|
||||
integrity sha512-F0to7vbBSHP8E3l6dCjxNOLuSFAACIxFy3UehTUlG7svlXi37HHsDkyVcHo0Pq8QwrE+pXvWSVX3ZT1T9wAZ9g==
|
||||
|
||||
for-in@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
||||
integrity sha512-7EwmXrOjyL+ChxMhmG5lnW9MPt1aIeZEwKhQzoBUdTV0N3zuwWDZYVJatDvZ2OyzPUvdIAZDsCetk3coyMfcnQ==
|
||||
|
||||
for-own@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/for-own/-/for-own-1.0.0.tgz#c63332f415cedc4b04dbfe70cf836494c53cb44b"
|
||||
integrity sha512-0OABksIGrxKK8K4kynWkQ7y1zounQxP+CWnyclVwj81KW3vlLlGUx57DKGcP/LH216GzqnstnPocF16Nxs0Ycg==
|
||||
dependencies:
|
||||
for-in "^1.0.1"
|
||||
|
||||
form-data@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
|
||||
|
@ -4297,6 +4337,11 @@ is-directory@^0.3.1:
|
|||
resolved "https://registry.yarnpkg.com/is-directory/-/is-directory-0.3.1.tgz#61339b6f2475fc772fd9c9d83f5c8575dc154ae1"
|
||||
integrity sha512-yVChGzahRFvbkscn2MlwGismPO12i9+znNruC5gVEntG3qu0xQMzsGg/JFbrsqDOHtHFPci+V5aP5T9I+yeKqw==
|
||||
|
||||
is-extendable@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
|
||||
integrity sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==
|
||||
|
||||
is-extglob@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
|
||||
|
@ -5092,7 +5137,12 @@ keyv@^4.5.3:
|
|||
dependencies:
|
||||
json-buffer "3.0.1"
|
||||
|
||||
kind-of@^6.0.2, kind-of@^6.0.3:
|
||||
kind-of@^5.0.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d"
|
||||
integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==
|
||||
|
||||
kind-of@^6.0.0, kind-of@^6.0.1, kind-of@^6.0.2, kind-of@^6.0.3:
|
||||
version "6.0.3"
|
||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
|
||||
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==
|
||||
|
@ -5646,6 +5696,14 @@ minimist@^1.2.6:
|
|||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
|
||||
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==
|
||||
|
||||
mixin-object@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/mixin-object/-/mixin-object-2.0.1.tgz#4fb949441dab182540f1fe035ba60e1947a5e57e"
|
||||
integrity sha512-ALGF1Jt9ouehcaXaHhn6t1yGWRqGaHkPFndtFVHfZXOvkIZ/yoGaSi0AHVTafb3ZBGg4dr/bDwnaEKqCXzchMA==
|
||||
dependencies:
|
||||
for-in "^0.1.3"
|
||||
is-extendable "^0.1.1"
|
||||
|
||||
mkdirp@^0.5.1:
|
||||
version "0.5.6"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6"
|
||||
|
@ -5874,6 +5932,11 @@ open@^6.2.0:
|
|||
dependencies:
|
||||
is-wsl "^1.1.0"
|
||||
|
||||
opencollective-postinstall@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz#7a0fff978f6dbfa4d006238fbac98ed4198c3259"
|
||||
integrity sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==
|
||||
|
||||
optionator@^0.9.3:
|
||||
version "0.9.3"
|
||||
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.9.3.tgz#007397d44ed1872fdc6ed31360190f81814e2c64"
|
||||
|
@ -6601,6 +6664,15 @@ setprototypeof@1.2.0:
|
|||
resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424"
|
||||
integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==
|
||||
|
||||
shallow-clone@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-1.0.0.tgz#4480cd06e882ef68b2ad88a3ea54832e2c48b571"
|
||||
integrity sha512-oeXreoKR/SyNJtRJMAKPDSvd28OqEwG4eR/xc856cRGBII7gX9lvAqDxusPm0846z/w/hWYjI1NpKwJ00NHzRA==
|
||||
dependencies:
|
||||
is-extendable "^0.1.1"
|
||||
kind-of "^5.0.0"
|
||||
mixin-object "^2.0.1"
|
||||
|
||||
shallow-clone@^3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3"
|
||||
|
@ -6885,6 +6957,14 @@ sudo-prompt@^9.0.0:
|
|||
resolved "https://registry.yarnpkg.com/sudo-prompt/-/sudo-prompt-9.2.1.tgz#77efb84309c9ca489527a4e749f287e6bdd52afd"
|
||||
integrity sha512-Mu7R0g4ig9TUuGSxJavny5Rv0egCEtpZRNMrZaYS1vxkiIxGiGUwoezU3LazIQ+KE04hTrTfNPgxU5gzi7F5Pw==
|
||||
|
||||
superstruct@^0.6.2:
|
||||
version "0.6.2"
|
||||
resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.6.2.tgz#c5eb034806a17ff98d036674169ef85e4c7f6a1c"
|
||||
integrity sha512-lvA97MFAJng3rfjcafT/zGTSWm6Tbpk++DP6It4Qg7oNaeM+2tdJMuVgGje21/bIpBEs6iQql1PJH6dKTjl4Ig==
|
||||
dependencies:
|
||||
clone-deep "^2.0.1"
|
||||
kind-of "^6.0.1"
|
||||
|
||||
supports-color@^5.3.0:
|
||||
version "5.5.0"
|
||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
|
||||
|
|
Loading…
Reference in New Issue