Skip to content

Commit

Permalink
feat: render pdf and share (#206)
Browse files Browse the repository at this point in the history
* feat: render pdf

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* feat: add qrcode in certificate

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* feat: add encrypted qrcode in certificate

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* fix: schema url in qrcodes

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* fix: UI issues

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* chore: bump version

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* feat: connection reuse

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* fix: w3c credential detail navigation

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* refactor: pick encryption key from env file

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

* fix: restore wallet flow

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>

---------

Signed-off-by: Sai Ranjit Tummalapalli <[email protected]>
  • Loading branch information
sairanjit committed Sep 5, 2024
1 parent 716a941 commit d6280aa
Show file tree
Hide file tree
Showing 26 changed files with 435 additions and 164 deletions.
3 changes: 3 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ PROOF_TEMPLATE_URL=
# Google Signin
GOOGLE_WEB_CLIENT_ID=CLIENT_ID
GOOGLE_IOS_CLIENT_ID=CLIENT_ID

# DATA ENCYPTION KEY
DATA_ENCRYPTION_KEY=DATA_ENCRYPTION_KEY
13 changes: 11 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ android {
applicationId "id.credebl.adeya"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 12
versionName "1.0.9"
versionCode 16
versionName "1.0.10"

missingDimensionStrategy 'react-native-camera', 'general'
}
Expand Down Expand Up @@ -114,6 +114,15 @@ android {
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}

packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
minSdkVersion = 24
compileSdkVersion = 34
targetSdkVersion = 34

Expand Down
5 changes: 3 additions & 2 deletions app/components/misc/CredentialCard11.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const CredentialCard11: React.FC<CredentialCard11Props> = ({
},
primaryBodyContainer: {
flexGrow: 1,
padding,
padding: 15,
},
imageAttr: {
height: 150,
Expand Down Expand Up @@ -309,6 +309,7 @@ const CredentialCard11: React.FC<CredentialCard11Props> = ({
styles.textContainer,
{
lineHeight: 24,
width: '85%',
fontWeight: 'bold',
},
]}
Expand Down Expand Up @@ -380,7 +381,7 @@ const CredentialCard11: React.FC<CredentialCard11Props> = ({
{
fontWeight: 'bold',
lineHeight: 24,
flex: 1,
width: '85%',
flexWrap: 'wrap',
},
]}>
Expand Down
35 changes: 22 additions & 13 deletions app/components/record/W3CCredentialRecord.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { W3cCredentialRecord } from '@adeya/ssi'
import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { FlatList, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
import { ActivityIndicator, FlatList, StyleSheet, Text, TouchableOpacity, View } from 'react-native'

import { useTheme } from '../../contexts/theme'
import { Field, W3CCredentialAttributeField } from '../../types/record'
Expand All @@ -23,6 +23,7 @@ export interface RecordProps {
}
}
renderCertificate?: () => void
isCertificateLoading?: boolean
}

const W3CCredentialRecord: React.FC<RecordProps> = ({
Expand All @@ -32,12 +33,16 @@ const W3CCredentialRecord: React.FC<RecordProps> = ({
tables,
w3cCredential,
renderCertificate,
isCertificateLoading,
}) => {
const { t } = useTranslation()
const [shown, setShown] = useState<boolean[][]>([])
const [showAll, setShowAll] = useState<boolean>(true)
const { ListItems, TextTheme, ColorPallet } = useTheme()

const isPrettyVcAvailable =
w3cCredential?.credential?.prettyVc && Object.keys(w3cCredential?.credential?.prettyVc).length > 0

const styles = StyleSheet.create({
linkContainer: {
...ListItems.recordContainer,
Expand All @@ -56,7 +61,7 @@ const W3CCredentialRecord: React.FC<RecordProps> = ({
},
rowContainer: {
flexDirection: 'row',
justifyContent: w3cCredential?.credential?.prettyVc ? 'space-between' : 'flex-end',
justifyContent: isPrettyVcAvailable ? 'space-between' : 'flex-end',
backgroundColor: ColorPallet.grayscale.white,
},
linkText: {
Expand Down Expand Up @@ -118,19 +123,23 @@ const W3CCredentialRecord: React.FC<RecordProps> = ({
<RecordHeader>
{header()}
<View style={styles.rowContainer}>
{w3cCredential?.credential?.prettyVc ? (
{isPrettyVcAvailable && (
<View style={styles.linkContainer}>
<TouchableOpacity
style={styles.link}
activeOpacity={1}
onPress={renderCertificate}
testID={testIdWithKey('ViewCertificate')}
accessible={true}
accessibilityLabel={t('Record.ViewCertificate')}>
<Text style={[ListItems.recordLink, styles.linkText]}>{t('Record.ViewCertificate')}</Text>
</TouchableOpacity>
{isCertificateLoading ? (
<ActivityIndicator size={'small'} />
) : (
<TouchableOpacity
style={styles.link}
activeOpacity={1}
onPress={renderCertificate}
testID={testIdWithKey('ViewCertificate')}
accessible={true}
accessibilityLabel={t('Record.ViewCertificate')}>
<Text style={[ListItems.recordLink, styles.linkText]}>{t('Record.ViewCertificate')}</Text>
</TouchableOpacity>
)}
</View>
) : null}
)}

{hideFieldValues ? (
<View style={styles.linkContainer}>
Expand Down
2 changes: 2 additions & 0 deletions app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,5 @@ export const domain = 'didcomm://invite'
export const tourMargin = 25

export const hitSlop = { top: 44, bottom: 44, left: 44, right: 44 }

export const CREDENTIAL = 'Credential'
8 changes: 4 additions & 4 deletions app/navigators/RootStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ const RootStack: React.FC = () => {
}

// Try connection based
const { connectionRecord } = await connectFromInvitation(agent, invitationUrl)
const { connectionRecord, outOfBandRecord } = await connectFromInvitation(agent, invitationUrl)
navigation.navigate(Stacks.ConnectionStack as any, {
screen: Screens.Connection,
params: { connectionId: connectionRecord?.id },
params: { connectionId: connectionRecord?.id, outOfBandId: outOfBandRecord.id },
})
} catch {
try {
Expand Down Expand Up @@ -146,11 +146,11 @@ const RootStack: React.FC = () => {
return
}

const { connectionRecord } = await connectFromInvitation(agent, urlData)
const { connectionRecord, outOfBandRecord } = await connectFromInvitation(agent, urlData)

navigation.getParent()?.navigate(Stacks.ConnectionStack, {
screen: Screens.Connection,
params: { connectionId: connectionRecord?.id },
params: { connectionId: connectionRecord?.id, outOfBandId: outOfBandRecord.id },
})
return
}
Expand Down
15 changes: 12 additions & 3 deletions app/screens/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,18 @@ const Chat: React.FC<ChatProps> = ({ navigation, route }) => {
[ProofState.PresentationSent]: toProofDetails,
[ProofState.PresentationReceived]: toProofDetails,
[ProofState.RequestReceived]: () => {
navigation.navigate(Stacks.ContactStack as any, {
screen: Screens.ProofRequest,
params: { proofId: record.id },
agent.proofs.getFormatData(record.id).then(value => {
if (value?.request?.indy) {
navigation.navigate(Stacks.ContactStack as any, {
screen: Screens.ProofRequest,
params: { proofId: record.id },
})
} else {
navigation.navigate(Stacks.ContactStack as any, {
screen: Screens.ProofRequestW3C,
params: { proofId: record.id },
})
}
})
},
}
Expand Down
9 changes: 5 additions & 4 deletions app/screens/Connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Button, { ButtonType } from '../components/buttons/Button'
import { useAnimatedComponents } from '../contexts/animated-components'
import { useConfiguration } from '../contexts/configuration'
import { useTheme } from '../contexts/theme'
import { useOutOfBandByConnectionId } from '../hooks/connections'
import { useOutOfBandById } from '../hooks/connections'
import { useNotifications } from '../hooks/notifications'
import { Screens, TabStacks, DeliveryStackParams, Stacks } from '../types/navigators'
import { useAppAgent } from '../utils/agent'
Expand All @@ -35,15 +35,15 @@ const Connection: React.FC<ConnectionProps> = ({ navigation, route }) => {
// delay message, the user should be redirected to the home screen.
const { connectionTimerDelay, autoRedirectConnectionToHome } = useConfiguration()
const connTimerDelay = connectionTimerDelay ?? 10000 // in ms
const { connectionId, threadId } = route.params
const { connectionId, outOfBandId, threadId } = route.params
const timerRef = useRef<NodeJS.Timeout | null>(null)
const connection = connectionId ? useConnectionById(connectionId) : undefined
const { t } = useTranslation()
const { notifications } = useNotifications()
const { ColorPallet, TextTheme } = useTheme()
const { ConnectionLoading } = useAnimatedComponents()
const { agent } = useAppAgent()
const oobRecord = useOutOfBandByConnectionId(agent, connectionId ?? '')
const oobRecord = useOutOfBandById(agent, outOfBandId ?? '')
const goalCode = oobRecord?.outOfBandInvitation.goalCode
const merge: MergeFunction = (current, next) => ({ ...current, ...next })
const [state, dispatch] = useReducer(merge, {
Expand All @@ -52,6 +52,7 @@ const Connection: React.FC<ConnectionProps> = ({ navigation, route }) => {
shouldShowDelayMessage: false,
connectionIsActive: false,
})

const styles = StyleSheet.create({
container: {
height: '100%',
Expand Down Expand Up @@ -168,7 +169,7 @@ const Connection: React.FC<ConnectionProps> = ({ navigation, route }) => {
if (state.notificationRecord && goalCode) {
goalCodeAction(goalCode)()
}
}, [connection, goalCode, state.notificationRecord])
}, [connection, oobRecord, goalCode, state.notificationRecord])

useMemo(() => {
startTimer()
Expand Down
10 changes: 5 additions & 5 deletions app/screens/CreateWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useNavigation } from '@react-navigation/core'
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { View, StyleSheet, Text, Platform, Modal, TouchableOpacity } from 'react-native'
import Icon from 'react-native-vector-icons/FontAwesome'
import Icon from 'react-native-vector-icons/MaterialIcons'

import Button, { ButtonType } from '../components/buttons/Button'
import { useTheme } from '../contexts/theme'
Expand All @@ -20,7 +20,9 @@ const CreateWallet: React.FC = () => {

const proceedWithRestore = () => {
toggleModal()
navigation.navigate(Screens.ImportWalletVerify as never)
setTimeout(() => {
navigation.navigate(Screens.ImportWalletVerify as never)
}, 300)
}

const styles = StyleSheet.create({
Expand Down Expand Up @@ -101,9 +103,7 @@ const CreateWallet: React.FC = () => {
</View>
<Text style={styles.instructionsText}>{t('Restore.RestoreInstructions')}</Text>
{Platform.OS === 'ios' && (
<Text style={styles.instructionsText}>
<Text style={{ fontWeight: 'bold' }}>For iOS users:</Text> {t('Restore.RestoreInstructionsIOS')}
</Text>
<Text style={styles.instructionsText}>{t('Restore.RestoreInstructionsIOS')}</Text>
)}
<View style={styles.restoreWalletView}>
<Button
Expand Down
Loading

0 comments on commit d6280aa

Please sign in to comment.