Skip to content

Commit

Permalink
feat: enable send video demo
Browse files Browse the repository at this point in the history
Signed-off-by: Jason C. Leach <[email protected]>
  • Loading branch information
jleach authored and moazan-ad committed Dec 28, 2024
1 parent 4eec768 commit bff613d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 40 deletions.
9 changes: 5 additions & 4 deletions packages/legacy/core/App/localization/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,27 @@ import { initReactI18next } from 'react-i18next'
import * as RNLocalize from 'react-native-localize'
import { PersistentStorage } from '../services/storage'
import { LocalStorageKeys } from '../constants'
import { en as sendVideoEn, fr as sendVideoFr, ptBr as sendVideoPtBr } from '../modules/send-video/localization'

import en from './en'
import fr from './fr'
import ptBr from './pt-br'

export type Translation = typeof en
export type Translation = typeof en & typeof sendVideoEn

export type TranslationResources = {
[key: string]: any
}

export const translationResources: TranslationResources = {
en: {
translation: en,
translation: { ...en, ...sendVideoEn },
},
fr: {
translation: fr,
translation: { ...fr, ...sendVideoFr },
},
'pt-BR': {
translation: ptBr,
translation: { ...ptBr, ...sendVideoPtBr },
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { useAgent } from '@credo-ts/react-hooks'
type VideoInstructionsProps = StackScreenProps<SendVideoStackParams, Screens.VideoInstructions>

const sendVideoSvs = new SentVideoServices({
sendVideoAgentInvitation: Config.VIDEO_VERIFIER_AGENT_INVITATION,
sendVideoAgentInvitation: Config.VIDEO_VERIFIER_AGENT_INVITATION ?? '',
sendVideoAPIBaseUrl: Config.VIDEO_VERIFIER_HOST ?? '',
})

Expand Down
23 changes: 11 additions & 12 deletions packages/legacy/core/App/navigators/RootStack.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { ProofState } from '@credo-ts/core'
import { useAgent, useProofByState } from '@credo-ts/react-hooks'
import { ProofCustomMetadata, ProofMetadata } from '@hyperledger/aries-bifold-verifier'
import {
CardStyleInterpolators,
StackCardStyleInterpolator,
createStackNavigator,
} from '@react-navigation/stack'
import { CardStyleInterpolators, StackCardStyleInterpolator, createStackNavigator } from '@react-navigation/stack'
import React, { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { DeviceEventEmitter } from 'react-native'
Expand All @@ -17,7 +13,8 @@ import { DispatchAction } from '../contexts/reducers/store'
import { useStore } from '../contexts/store'
import { useTheme } from '../contexts/theme'
import { useDeepLinks } from '../hooks/deep-links'
import HistoryStack from '../modules/history/navigation/HistoryStack'
import HistoryStack from '../modules/history/navigators/HistoryStack'
import SendVideoStack from '../modules/send-video/navigators/SendVideoStack'
import Chat from '../screens/Chat'
import { BifoldError } from '../types/error'
import { Screens, Stacks, TabStacks } from '../types/navigators'
Expand All @@ -38,12 +35,7 @@ const RootStack: React.FC = () => {
const { t } = useTranslation()
const theme = useTheme()
const defaultStackOptions = useDefaultStackOptions(theme)
const [
splash,
OnboardingStack,
CustomNavStack1,
loadState,
] = useServices([
const [splash, OnboardingStack, CustomNavStack1, loadState] = useServices([
TOKENS.SCREEN_SPLASH,
TOKENS.STACK_ONBOARDING,
TOKENS.CUSTOM_NAV_STACK_1,
Expand Down Expand Up @@ -136,6 +128,13 @@ const RootStack: React.FC = () => {
cardStyleInterpolator: forFade,
}}
/>
<Stack.Screen
name={Stacks.SendVideoStack}
component={SendVideoStack}
options={{
cardStyleInterpolator: forFade,
}}
/>
{CustomNavStack1 ? <Stack.Screen name={Stacks.CustomNavStack1} component={CustomNavStack1} /> : null}
</Stack.Navigator>
)
Expand Down
59 changes: 36 additions & 23 deletions packages/legacy/core/App/screens/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import { DispatchAction } from '../contexts/reducers/store'
import { useStore } from '../contexts/store'
import { useTheme } from '../contexts/theme'
import { useTour } from '../contexts/tour/tour-context'
import { HomeStackParams, Screens } from '../types/navigators'
import { HomeStackParams, Screens, Stacks } from '../types/navigators'
import { TourID } from '../types/tour'
import Button, { ButtonType } from '../components/buttons/Button'
import { useNavigation } from '@react-navigation/native'

type HomeProps = StackScreenProps<HomeStackParams, Screens.Home>

Expand All @@ -39,36 +41,40 @@ const Home: React.FC<HomeProps> = () => {
const { start, stop } = useTour()
const [showTourPopup, setShowTourPopup] = useState(false)
const screenIsFocused = useIsFocused()
const navigation = useNavigation()

const styles = StyleSheet.create({
flatlist: {
marginBottom: 35,
},
})

const DisplayListItemType = useCallback((item: any): React.ReactNode => {
let component: React.ReactNode
if (item.type === 'BasicMessageRecord') {
component = <NotificationListItem notificationType={NotificationType.BasicMessage} notification={item} />
} else if (item.type === 'CredentialRecord') {
let notificationType = NotificationType.CredentialOffer
if (item.revocationNotification) {
notificationType = NotificationType.Revocation
const DisplayListItemType = useCallback(
(item: any): React.ReactNode => {
let component: React.ReactNode
if (item.type === 'BasicMessageRecord') {
component = <NotificationListItem notificationType={NotificationType.BasicMessage} notification={item} />
} else if (item.type === 'CredentialRecord') {
let notificationType = NotificationType.CredentialOffer
if (item.revocationNotification) {
notificationType = NotificationType.Revocation
}
component = <NotificationListItem notificationType={notificationType} notification={item} />
} else if (item.type === 'CustomNotification' && customNotification) {
component = (
<NotificationListItem
notificationType={NotificationType.Custom}
notification={item}
customNotification={customNotification}
/>
)
} else {
component = <NotificationListItem notificationType={NotificationType.ProofRequest} notification={item} />
}
component = <NotificationListItem notificationType={notificationType} notification={item} />
} else if (item.type === 'CustomNotification' && customNotification) {
component = (
<NotificationListItem
notificationType={NotificationType.Custom}
notification={item}
customNotification={customNotification}
/>
)
} else {
component = <NotificationListItem notificationType={NotificationType.ProofRequest} notification={item} />
}
return component
}, [customNotification, NotificationListItem])
return component
},
[customNotification, NotificationListItem]
)

useEffect(() => {
const shouldShowTour = enableToursConfig && store.tours.enableTours && !store.tours.seenHomeTour
Expand Down Expand Up @@ -163,6 +169,13 @@ const Home: React.FC<HomeProps> = () => {
onDismissPressed={onDismissPressed}
/>
)}
<View style={{ marginBottom: 100 }}>
<Button
title={'Verify by Video (DEMO)'}
onPress={() => navigation.getParent()?.navigate('Send Video', { screen: 'Instructions' })}
buttonType={ButtonType.Primary}
/>
</View>
</>
)
}
Expand Down
1 change: 1 addition & 0 deletions packages/legacy/core/App/types/navigators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export enum Stacks {
ConnectionStack = 'Connection Stack',
HistoryStack = 'History Stack',
CustomNavStack1 = 'Custom Nav Stack 1',
SendVideoStack = 'Send Video Stack',
}

export enum TabStacks {
Expand Down

0 comments on commit bff613d

Please sign in to comment.