Skip to content

Commit

Permalink
refactor(INJI-474): add a dismiss-able popup w buttons
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh Vardhan <[email protected]>
  • Loading branch information
vharsh committed Nov 13, 2023
1 parent da67e93 commit 9088719
Show file tree
Hide file tree
Showing 13 changed files with 278 additions and 37 deletions.
5 changes: 3 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fileignoreconfig:
- filename: ios/Podfile.lock
checksum: cc123c3e1f04d41b394ceb16843b15c08bac3ba619ae853ff322717739761a85
checksum: cc123c3e1f04d41b394ceb16843b15c08bac3ba619ae853ff322717739761a85
- filename: package.json
checksum: fdd5905228a1afbfb004c710fd6c61adf073a12840200327c0592b76bea5e7e3
- filename: package-lock.json
Expand Down Expand Up @@ -76,5 +76,6 @@ fileignoreconfig:
checksum: a0686e9a5c006176fd720b84bc36ca947db1422caf65c90cd0c2d1102a9e96df
- filename: ios/fastlane/Fastfile
checksum: feea5a7f044ef6961d53e7d1e1ffb92a3e0f72761496424f6e64288e3718d605
- filename: machines/bleShare/scan/scanMachine.ts
checksum: a514c958ca3da3c5b22a1a95ad680af8f05fb22638fab79b3842aa8fcc1b4a17
version: ""

1 change: 1 addition & 0 deletions locales/ara.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@
"enableBluetoothMessage": "يرجى تمكين أذونات البلوتوث لدعم المشاركة المحلية",
"enableBluetoothButtonText": "السماح لأذونات البلوتوث",
"scanningGuide": "امسك الهاتف بثبات وامسح رمز الاستجابة السريعة ضوئيًا",
"invalidQR": "يرجى مسح QR صالح",
"sharingVc": "مشاركة بطاقة ",
"errors": {
"locationDisabled": {
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@
"enableBluetoothMessage": "Please enable bluetooth permissions to support local sharing",
"enableBluetoothButtonText": "Allow bluetooth permissions",
"scanningGuide": "Hold the phone steady and scan the QR code",
"invalidQR": "Please scan a valid QR",
"errors": {
"locationDisabled": {
"message": "Location services must be enabled to share card",
Expand Down
1 change: 1 addition & 0 deletions locales/fil.json
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@
"enableBluetoothMessage": "Mangyaring paganahin ang mga pahintulot ng bluetooth upang suportahan ang lokal na pagbabahagi",
"enableBluetoothButtonText": "Payagan ang mga pahintulot ng bluetooth",
"scanningGuide": "Panatilihin ang telepono at i-scan ang QR code",
"invalidQR": "Mangyaring mag-scan ng wastong QR",
"errors": {
"locationDisabled": {
"message": "Dapat na nakabukas ang Location services ng iyong mobile para maaaring makapag-scan",
Expand Down
1 change: 1 addition & 0 deletions locales/hin.json
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@
"enableBluetoothMessage": "कृपया स्थानीय साझाकरण का समर्थन करने के लिए ब्लूटूथ अनुमतियाँ सक्षम करें",
"enableBluetoothButtonText": "ब्लूटूथ अनुमतियाँ दें",
"scanningGuide": "फ़ोन को स्थिर रखें और QR कोड को स्कैन करें",
"invalidQR": "कृपया एक वैध क्यूआर स्कैन करें",
"errors": {
"locationDisabled": {
"message": "स्थान सेवाओं को स्कैनिंग कार्यक्षमता के लिए सक्षम किया जाना चाहिए",
Expand Down
1 change: 1 addition & 0 deletions locales/kan.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@
"enableBluetoothMessage": "ದಯವಿಟ್ಟು ಸ್ಥಳೀಯ ಹಂಚಿಕೆಯನ್ನು ಬೆಂಬಲಿಸಲು ಬ್ಲೂಟೂತ್ ಅನುಮತಿಗಳನ್ನು ಸಕ್ರಿಯಗೊಳಿಸಿ",
"enableBluetoothButtonText": "ಬ್ಲೂಟೂತ್ ಅನುಮತಿಗಳನ್ನು ಅನುಮತಿಸಿ",
"scanningGuide": "ಫೋನ್ ಅನ್ನು ಸ್ಥಿರವಾಗಿ ಹಿಡಿದುಕೊಳ್ಳಿ ಮತ್ತು QR ಕೋಡ್ ಅನ್ನು ಸ್ಕ್ಯಾನ್ ಮಾಡಿ",
"invalidQR": "ದಯವಿಟ್ಟು ಮಾನ್ಯವಾದ QR ಅನ್ನು ಸ್ಕ್ಯಾನ್ ಮಾಡಿ",
"errors": {
"locationDisabled": {
"message": "ಸ್ಕ್ಯಾನಿಂಗ್ ಕಾರ್ಯಕ್ಕಾಗಿ ಸ್ಥಳ ಸೇವೆಗಳನ್ನು ಸಕ್ರಿಯಗೊಳಿಸಬೇಕು",
Expand Down
1 change: 1 addition & 0 deletions locales/spa.json
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@
"bluetoothStateIos": "Por favor, activa el Bluetooth desde el centro de control para admitir el intercambio local",
"enableBluetoothMessage": "Por favor, habilita los permisos de Bluetooth para admitir el intercambio local",
"enableBluetoothButtonText": "Permitir permisos de Bluetooth",
"invalidQR": "Por favor escanea un QR válido",
"errors": {
"locationDisabled": {
"message": "Los servicios de ubicación deben estar habilitados para compartir la tarjeta",
Expand Down
1 change: 1 addition & 0 deletions locales/tam.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@
"enableBluetoothMessage": "உள்ளூர் பகிர்வை ஆதரிக்க புளூடூத் அனுமதிகளை இயக்கவும்",
"enableBluetoothButtonText": "புளூடூத் அனுமதிகளை அனுமதிக்கவும்",
"scanningGuide": "ஃபோனை நிலையாகப் பிடித்து, QR குறியீட்டை ஸ்கேன் செய்யவும்s",
"invalidQR": "ದಯವಿಟ್ಟು ಮಾನ್ಯವಾದ QR ಅನ್ನು ಸ್ಕ್ಯಾನ್ ಮಾಡಿ",
"errors": {
"locationDisabled": {
"message": "ஸ்கேனிங் செயல்பாட்டிற்கு இருப்பிடச் சேவைகள் இயக்கப்பட வேண்டும்",
Expand Down
29 changes: 7 additions & 22 deletions machines/bleShare/scan/scanMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,23 +402,14 @@ export const scanMachine =
{
target: 'connecting',
cond: 'isOpenIdQr',
actions: [
'sendVcSharingStartEvent',
'setUri',
'offlineaccepted',
],
actions: ['sendVcSharingStartEvent', 'setUri'],
},
{
target: 'showQrLogin',
cond: 'isQrLogin',
actions: [
'sendVcSharingStartEvent',
'setLinkCode',
'onlineaccepted',
],
actions: ['sendVcSharingStartEvent', 'setLinkCode'],
},
{
actions: 'invalidaccepted',
target: 'invalid',
},
],
Expand Down Expand Up @@ -732,9 +723,6 @@ export const scanMachine =
},
{
actions: {
offlineaccepted: () => console.log('>> offline QR accepted'),
onlineaccepted: () => console.log('>> online QR accepted'),
invalidaccepted: () => console.log('>> invalid QR accepted'),
setChildRef: assign({
QrLoginRef: context => {
const service = spawn(
Expand Down Expand Up @@ -881,14 +869,9 @@ export const scanMachine =
}),

setLinkCode: assign({
// TODO: set link code refactor required
linkCode: (_context, event) =>
event.params.substring(
event.params.indexOf('linkCode=') + 9,
event.params.indexOf('&'),
),
new URL(event.params).searchParams.get('linkCode'),
}),

setStayInProgress: assign({
stayInProgress: context => !context.stayInProgress,
}),
Expand Down Expand Up @@ -1190,11 +1173,13 @@ export const scanMachine =
},

guards: {
isOpenIdQr: (_context, event) => event.params.includes('OPENID4VP://'),
// sample: 'OPENID4VP://connect:?name=OVPMOSIP&key=69dc92a2cc91f02258aa8094d6e2b62877f5b6498924fbaedaaa46af30abb364'
isOpenIdQr: (_context, event) =>
event.params.startsWith('OPENID4VP://'),
isQrLogin: (_context, event) => {
try {
let linkCode = new URL(event.params);
// does it have a linkCode & an linkExpireDateTime
// sample: 'inji://landing-page-name?linkCode=sTjp0XVH3t3dGCU&linkExpireDateTime=2023-11-09T06:56:18.482Z'
return (
linkCode.searchParams.get('linkCode') &&
linkCode.searchParams.get('linkExpireDateTime')
Expand Down
241 changes: 241 additions & 0 deletions machines/bleShare/scan/scanMachine.typegen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
// This file was automatically generated. Edits will be overwritten

export interface Typegen0 {
'@@xstate/typegen': true;
internalEvents: {
'': {type: ''};
'done.invoke.QrLogin': {
type: 'done.invoke.QrLogin';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.scan.checkStorage:invocation[0]': {
type: 'done.invoke.scan.checkStorage:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'done.invoke.scan.reviewing.creatingVp:invocation[0]': {
type: 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
data: unknown;
__tip: 'See the XState TS docs to learn how to strongly type this.';
};
'xstate.after(CONNECTION_TIMEOUT)#scan.connecting.inProgress': {
type: 'xstate.after(CONNECTION_TIMEOUT)#scan.connecting.inProgress';
};
'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection': {
type: 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection';
};
'xstate.after(SHARING_TIMEOUT)#scan.reviewing.sendingVc.inProgress': {
type: 'xstate.after(SHARING_TIMEOUT)#scan.reviewing.sendingVc.inProgress';
};
'xstate.init': {type: 'xstate.init'};
'xstate.stop': {type: 'xstate.stop'};
};
invokeSrcNameMap: {
checkBluetoothPermission: 'done.invoke.scan.checkBluetoothPermission.checking:invocation[0]';
checkBluetoothState:
| 'done.invoke.scan.checkBluetoothState.checking:invocation[0]'
| 'done.invoke.scan.recheckBluetoothState.checking:invocation[0]';
checkLocationPermission: 'done.invoke.scan.checkingLocationService.checkingPermissionStatus:invocation[0]';
checkNearByDevicesPermission: 'done.invoke.scan.checkNearbyDevicesPermission.checking:invocation[0]';
checkStorageAvailability: 'done.invoke.scan.checkStorage:invocation[0]';
createVp: 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
disconnect:
| 'done.invoke.scan.clearingConnection:invocation[0]'
| 'done.invoke.scan.disconnectDevice:invocation[0]';
monitorConnection: 'done.invoke.scan:invocation[0]';
requestBluetooth: 'done.invoke.scan.checkBluetoothState.requesting:invocation[0]';
requestNearByDevicesPermission: 'done.invoke.scan.checkNearbyDevicesPermission.requesting:invocation[0]';
requestToEnableLocationPermission: 'done.invoke.scan.checkingLocationService.requestToEnableLocation:invocation[0]';
sendVc: 'done.invoke.scan.reviewing.sendingVc:invocation[0]';
startConnection: 'done.invoke.scan.connecting:invocation[0]';
};
missingImplementations: {
actions: never;
delays: never;
guards: never;
services: never;
};
eventsCausingActions: {
clearCreatedVp:
| ''
| 'BLE_ERROR'
| 'DISCONNECT'
| 'DISMISS'
| 'RESET'
| 'SCREEN_BLUR'
| 'SCREEN_FOCUS'
| 'xstate.stop';
clearReason:
| ''
| 'BLE_ERROR'
| 'DISCONNECT'
| 'DISMISS'
| 'RESET'
| 'SCREEN_BLUR'
| 'SCREEN_FOCUS'
| 'xstate.stop';
clearUri:
| 'DISCONNECT'
| 'DISMISS'
| 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection';
logFailedVerification: 'FACE_INVALID';
logShared: 'VC_ACCEPTED';
openAppPermission: 'GOTO_SETTINGS' | 'LOCATION_REQUEST';
openBluetoothSettings: 'GOTO_SETTINGS';
registerLoggers:
| 'DISCONNECT'
| 'DISMISS'
| 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection';
removeLoggers:
| 'DISCONNECT'
| 'DISMISS'
| 'SCREEN_BLUR'
| 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection'
| 'xstate.init';
resetShouldVerifyPresence: 'CANCEL' | 'CONNECTED' | 'DISMISS' | 'RETRY';
sendBLEConnectionErrorEvent: 'BLE_ERROR';
sendScanData: 'SCAN';
sendVCShareFlowCancelEndEvent: 'CANCEL';
sendVCShareFlowTimeoutEndEvent: 'CANCEL' | 'RETRY';
sendVcShareSuccessEvent: 'VC_ACCEPTED';
sendVcSharingStartEvent: 'SCAN';
setBleError: 'BLE_ERROR';
setChildRef:
| 'DISCONNECT'
| 'DISMISS'
| 'xstate.after(DESTROY_TIMEOUT)#scan.clearingConnection';
setCreatedVp: 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
setLinkCode: 'SCAN';
setPromptHint: 'CANCEL' | 'RETRY';
setReadyForBluetoothStateCheck: 'BLUETOOTH_PERMISSION_ENABLED';
setReason: 'UPDATE_REASON';
setReceiverInfo: 'CONNECTED';
setSelectedVc: 'SELECT_VC';
setSenderInfo: 'CONNECTED';
setShareLogTypeUnverified: 'ACCEPT_REQUEST';
setShareLogTypeVerified: 'FACE_VALID';
setStayInProgress:
| 'STAY_IN_PROGRESS'
| 'xstate.after(CONNECTION_TIMEOUT)#scan.connecting.inProgress'
| 'xstate.after(SHARING_TIMEOUT)#scan.reviewing.sendingVc.inProgress';
setUri: 'SCAN';
storeLoginItem: 'done.invoke.QrLogin';
storingActivityLog: 'STORE_RESPONSE';
toggleShouldVerifyPresence: 'TOGGLE_USER_CONSENT';
};
eventsCausingDelays: {
CONNECTION_TIMEOUT: 'SCAN';
DESTROY_TIMEOUT: '' | 'DISMISS' | 'LOCATION_ENABLED';
SHARING_TIMEOUT:
| 'ACCEPT_REQUEST'
| 'FACE_VALID'
| 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
};
eventsCausingGuards: {
isIOS: 'BLUETOOTH_STATE_DISABLED' | 'START_PERMISSION_CHECK';
isMinimumStorageRequiredForAuditEntryReached: 'done.invoke.scan.checkStorage:invocation[0]';
isOpenIdQr: 'SCAN';
isQrLogin: 'SCAN';
uptoAndroid11: '' | 'START_PERMISSION_CHECK';
};
eventsCausingServices: {
QrLogin: 'SCAN';
checkBluetoothPermission:
| ''
| 'BLUETOOTH_STATE_DISABLED'
| 'NEARBY_ENABLED'
| 'START_PERMISSION_CHECK';
checkBluetoothState: '' | 'APP_ACTIVE';
checkLocationPermission: '' | 'APP_ACTIVE';
checkNearByDevicesPermission: 'APP_ACTIVE' | 'START_PERMISSION_CHECK';
checkStorageAvailability: 'RESET' | 'SCREEN_FOCUS';
createVp: never;
disconnect: '' | 'DISMISS' | 'LOCATION_ENABLED' | 'SCREEN_BLUR';
monitorConnection: 'DISMISS' | 'SCREEN_BLUR' | 'xstate.init';
requestBluetooth: 'BLUETOOTH_STATE_DISABLED';
requestNearByDevicesPermission: 'NEARBY_DISABLED';
requestToEnableLocationPermission: 'LOCATION_DISABLED';
sendVc:
| 'ACCEPT_REQUEST'
| 'FACE_VALID'
| 'done.invoke.scan.reviewing.creatingVp:invocation[0]';
startConnection: 'SCAN';
};
matchesStates:
| 'bluetoothDenied'
| 'bluetoothPermissionDenied'
| 'checkBluetoothPermission'
| 'checkBluetoothPermission.checking'
| 'checkBluetoothPermission.enabled'
| 'checkBluetoothState'
| 'checkBluetoothState.checking'
| 'checkBluetoothState.enabled'
| 'checkBluetoothState.requesting'
| 'checkNearbyDevicesPermission'
| 'checkNearbyDevicesPermission.checking'
| 'checkNearbyDevicesPermission.enabled'
| 'checkNearbyDevicesPermission.requesting'
| 'checkStorage'
| 'checkingLocationService'
| 'checkingLocationService.checkingPermissionStatus'
| 'checkingLocationService.denied'
| 'checkingLocationService.requestToEnableLocation'
| 'clearingConnection'
| 'connecting'
| 'connecting.inProgress'
| 'connecting.timeout'
| 'disconnectDevice'
| 'disconnected'
| 'findingConnection'
| 'handlingBleError'
| 'inactive'
| 'invalid'
| 'nearByDevicesPermissionDenied'
| 'recheckBluetoothState'
| 'recheckBluetoothState.checking'
| 'recheckBluetoothState.enabled'
| 'restrictSharingVc'
| 'reviewing'
| 'reviewing.accepted'
| 'reviewing.cancelling'
| 'reviewing.creatingVp'
| 'reviewing.invalidIdentity'
| 'reviewing.navigatingToHome'
| 'reviewing.rejected'
| 'reviewing.selectingVc'
| 'reviewing.sendingVc'
| 'reviewing.sendingVc.inProgress'
| 'reviewing.sendingVc.sent'
| 'reviewing.sendingVc.timeout'
| 'reviewing.verifyingIdentity'
| 'showQrLogin'
| 'showQrLogin.idle'
| 'showQrLogin.navigatingToHistory'
| 'showQrLogin.storing'
| 'startPermissionCheck'
| {
checkBluetoothPermission?: 'checking' | 'enabled';
checkBluetoothState?: 'checking' | 'enabled' | 'requesting';
checkNearbyDevicesPermission?: 'checking' | 'enabled' | 'requesting';
checkingLocationService?:
| 'checkingPermissionStatus'
| 'denied'
| 'requestToEnableLocation';
connecting?: 'inProgress' | 'timeout';
recheckBluetoothState?: 'checking' | 'enabled';
reviewing?:
| 'accepted'
| 'cancelling'
| 'creatingVp'
| 'invalidIdentity'
| 'navigatingToHome'
| 'rejected'
| 'selectingVc'
| 'sendingVc'
| 'verifyingIdentity'
| {sendingVc?: 'inProgress' | 'sent' | 'timeout'};
showQrLogin?: 'idle' | 'navigatingToHistory' | 'storing';
};
tags: never;
}
1 change: 0 additions & 1 deletion screens/Scan/ScanLayoutController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export function useScanLayout() {
const isQrLoginDone = useSelector(scanService, selectIsQrLoginDone);

useEffect(() => {
console.log('>> reviewing: ', isReviewing);
if (isDone) {
changeTabBarVisible('flex');
navigation.navigate(BOTTOM_TAB_ROUTES.home);
Expand Down
Loading

0 comments on commit 9088719

Please sign in to comment.