Skip to content

Commit

Permalink
added person credential loading screen
Browse files Browse the repository at this point in the history
Signed-off-by: wadeking98 <[email protected]>
  • Loading branch information
wadeking98 committed Jul 26, 2024
1 parent 9142f09 commit 5bae6a0
Show file tree
Hide file tree
Showing 8 changed files with 400 additions and 259 deletions.
26 changes: 26 additions & 0 deletions app/container-imp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ import { DependencyContainer } from 'tsyringe'
import { autoDisableRemoteLoggingIntervalInMinutes } from './src/constants'
import { expirationOverrideInMinutes } from './src/helpers/utils'
import Developer from './src/screens/Developer'
import PersonCredential from './src/screens/PersonCredential'
import PersonCredentialLoading from './src/screens/PersonCredentialLoading'
import Preface from './src/screens/Preface'
import Terms, { TermsVersion } from './src/screens/Terms'
import {
BCDispatchAction,
BCLocalStorageKeys,
BCState,
DismissPersonCredentialOffer,
Expand Down Expand Up @@ -157,6 +160,29 @@ export class AppContainer implements Container {
})
this._container.registerInstance(TOKENS.UTIL_OCA_RESOLVER, resolver)

this._container.registerInstance(TOKENS.CUSTOM_NOTIFICATION, {
component: PersonCredential,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onCloseAction: (dispatch?: React.Dispatch<ReducerAction<any>>) => {
if (dispatch) {
dispatch({
type: BCDispatchAction.PERSON_CREDENTIAL_OFFER_DISMISSED,
payload: [{ personCredentialOfferDismissed: true }],
})
}
},
additionalStackItems: [
{
component: PersonCredentialLoading,
name: 'PersonCredentialLoading',
},
],
pageTitle: 'PersonCredential.PageTitle',
title: 'PersonCredentialNotification.Title',
description: 'PersonCredentialNotification.Description',
buttonTitle: 'PersonCredentialNotification.ButtonTitle',
})

this._container.registerInstance(TOKENS.UTIL_PROOF_TEMPLATE, useProofRequestTemplates)
this._container.registerInstance(TOKENS.LOAD_STATE, async (dispatch: React.Dispatch<ReducerAction<unknown>>) => {
const loadState = async <Type>(key: LocalStorageKeys | BCLocalStorageKeys, updateVal: (val: Type) => void) => {
Expand Down
10 changes: 5 additions & 5 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@
"@formatjs/intl-relativetimeformat": "9.3.1",
"@hyperledger/anoncreds-react-native": "0.2.2",
"@hyperledger/aries-askar-react-native": "0.2.3",
"@hyperledger/aries-bifold-core": "1.0.0-alpha.284",
"@hyperledger/aries-bifold-remote-logs": "1.0.0-alpha.284",
"@hyperledger/aries-bifold-verifier": "1.0.0-alpha.284",
"@hyperledger/aries-oca": "1.0.0-alpha.284",
"@hyperledger/aries-react-native-attestation": "1.0.0-alpha.284",
"@hyperledger/aries-bifold-core": "1.0.0-alpha.285",
"@hyperledger/aries-bifold-remote-logs": "1.0.0-alpha.285",
"@hyperledger/aries-bifold-verifier": "1.0.0-alpha.285",
"@hyperledger/aries-oca": "1.0.0-alpha.285",
"@hyperledger/aries-react-native-attestation": "1.0.0-alpha.285",
"@hyperledger/indy-vdr-react-native": "0.2.2",
"@hyperledger/indy-vdr-shared": "0.2.2",
"@react-native-async-storage/async-storage": "1.15.11",
Expand Down
16 changes: 16 additions & 0 deletions app/src/assets/img/personCredLoadingIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions app/src/components/PersonCredentialSpinner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { useTheme } from '@hyperledger/aries-bifold-core'
import React, { useEffect, useRef } from 'react'
import { View, StyleSheet, Animated } from 'react-native'

import ActivityIndicator from '../assets/img/activity-indicator-circle.svg'
import EmptyWallet from '../assets/img/personCredLoadingIcon.svg'

const PersonCredentialSpinner: React.FC = () => {
const { ColorPallet } = useTheme()
const rotationAnim = useRef(new Animated.Value(0)).current
const timing: Animated.TimingAnimationConfig = {
toValue: 1,
duration: 2000,
useNativeDriver: true,
}
const rotation = rotationAnim.interpolate({
inputRange: [0, 1],
outputRange: ['0deg', '360deg'],
})
const style = StyleSheet.create({
container: {
alignItems: 'center',
justifyContent: 'center',
},
animation: {
position: 'absolute',
zIndex: 1,
},
})
const displayOptions = {
fill: ColorPallet.notification.infoText,
}
const animatedCircleDisplayOptions = {
fill: ColorPallet.notification.infoText,
height: 250,
width: 250,
}

useEffect(() => {
Animated.loop(Animated.timing(rotationAnim, timing)).start()
}, [rotationAnim])

return (
<View style={style.container}>
<EmptyWallet style={style.animation} {...displayOptions} />
<Animated.View style={{ transform: [{ rotate: rotation }] }}>
<ActivityIndicator {...animatedCircleDisplayOptions} />
</Animated.View>
</View>
)
}

export default PersonCredentialSpinner
19 changes: 0 additions & 19 deletions app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Agent,
} from '@hyperledger/aries-bifold-core'
import merge from 'lodash.merge'
import { ReducerAction } from 'react'
import { Config } from 'react-native-config'

import AddCredentialButton from './components/AddCredentialButton'
Expand All @@ -23,11 +22,9 @@ import fr from './localization/fr'
import ptBr from './localization/pt-br'
import Developer from './screens/Developer'
import { pages } from './screens/OnboardingPages'
import PersonCredential from './screens/PersonCredential'
import Preface from './screens/Preface'
import Splash from './screens/Splash'
import Terms from './screens/Terms'
import { BCDispatchAction } from './store'
import { defaultTheme as theme } from './theme'

const localization = merge({}, translationResources, {
Expand All @@ -50,22 +47,6 @@ const configuration: ConfigurationContext = {
proofTemplateBaseUrl: Config.PROOF_TEMPLATE_URL,
record: Record,
settings: [],
customNotification: {
component: PersonCredential,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
onCloseAction: (dispatch?: React.Dispatch<ReducerAction<any>>) => {
if (dispatch) {
dispatch({
type: BCDispatchAction.PERSON_CREDENTIAL_OFFER_DISMISSED,
payload: [{ personCredentialOfferDismissed: true }],
})
}
},
pageTitle: 'PersonCredential.PageTitle',
title: 'PersonCredentialNotification.Title',
description: 'PersonCredentialNotification.Description',
buttonTitle: 'PersonCredentialNotification.ButtonTitle',
},
enableTours: true,
showPreface: true,
disableOnboardingSkip: true,
Expand Down
Loading

0 comments on commit 5bae6a0

Please sign in to comment.