Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: credential overview #4

Merged
merged 40 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b68a32c
feat: qr scanner (without parsing)
May 15, 2023
3f44a85
Update packages/app/provider/index.tsx
May 19, 2023
ddec381
chore: qr scanner cleanup
May 22, 2023
a61a2e5
chore: yarn.lock
May 22, 2023
a56fd0a
chore: revert agent changes
May 22, 2023
9dba53c
chore: permissions and background
May 22, 2023
c2f1485
fix: restore agent changes
May 22, 2023
2e86ae5
fix: scanner
May 22, 2023
eb8f024
feat: added initial flow
May 23, 2023
dd736ed
chore: flow
May 23, 2023
84016f8
chore: styling
May 23, 2023
bd67cfd
fix: make jsonld openid flow work
TimoGlastra May 23, 2023
8fb20f2
feat: credential notification
May 25, 2023
085cfeb
feat: moved loading to notification modal
May 25, 2023
c1b1ac1
fix: image cleanup
May 25, 2023
4a158c9
chore: clean up
May 25, 2023
b5c3aaf
chore: refactor
May 25, 2023
715b6be
feat: credential overview
May 29, 2023
50d299c
fix: colors
May 29, 2023
9a73b12
chore: comment to clarify utils
May 29, 2023
dff6b24
chore: refactor
May 29, 2023
cc87fa8
fix: comment
May 31, 2023
af4a1bd
feat: accept credential request (#3)
May 31, 2023
055ce3d
feat: added initial flow
May 23, 2023
f782d04
chore: flow
May 23, 2023
e5bbde2
feat: credential notification
May 25, 2023
4373e72
feat: moved loading to notification modal
May 25, 2023
b79ac1a
chore: clean up
May 25, 2023
35770eb
chore: refactor
May 25, 2023
7a70acb
feat: credential overview
May 29, 2023
89a46e0
chore: comment to clarify utils
May 29, 2023
cb496ee
chore: refactor
May 29, 2023
5f27932
fix: rebase fix
Jun 1, 2023
f707472
fix: removed unused packages
Jun 1, 2023
ef1a638
Merge branch 'main' into feat/credential-overview
Jun 1, 2023
28735ad
fix: comment
Jun 1, 2023
56d3a82
fix: minor improvements
Jun 1, 2023
c6db8a6
chore: update lock-file
TimoGlastra Jun 2, 2023
4bbce90
chore: package.json updates
TimoGlastra Jun 2, 2023
1a909dd
chore: theme refactoring
Jun 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QrScannerScreen } from 'app/features/scan/screen'
import { QrScannerScreen } from 'app/features/scan/ScanScreen'

export default function Screen() {
return <QrScannerScreen />
Expand Down
21 changes: 21 additions & 0 deletions apps/expo/app/(home)/wallet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { XStack, color } from '@internal/ui'
import { WalletScreen } from 'app/features/wallet/WalletScreen'
import { Stack } from 'expo-router'

const HEADER_STATUS_BAR_HEIGHT = 56
janrtvld marked this conversation as resolved.
Show resolved Hide resolved

export default function Screen() {
return (
<>
<Stack.Screen
options={{
headerShown: true,
header: () => {
return <XStack h={HEADER_STATUS_BAR_HEIGHT} bg={color['grey-200']} />
janrtvld marked this conversation as resolved.
Show resolved Hide resolved
},
}}
/>
<WalletScreen />
</>
)
}
51 changes: 0 additions & 51 deletions apps/expo/app/(tabs)/_layout.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions apps/expo/app/(tabs)/wallet.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion apps/expo/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function HomeLayout() {
<AgentProvider agent={agent}>
<ThemeProvider value={scheme === 'dark' ? DarkTheme : DefaultTheme}>
<Stack screenOptions={{ headerShown: false }}>
<Stack.Screen name="(tabs)" />
<Stack.Screen options={{ presentation: 'modal' }} name="(home)/scan" />
<Stack.Screen options={{ presentation: 'modal' }} name="notifications/credential" />
<Stack.Screen options={{ presentation: 'modal' }} name="credentials/[id]" />
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion apps/expo/app/credentials/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CredentialDetailScreen } from 'app/features/credentials/detail-screen'
import { CredentialDetailScreen } from 'app/features/credentials/CredentialDetailScreen'
import { Stack } from 'expo-router'

export default function Screen() {
Expand Down
9 changes: 0 additions & 9 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"@babel/runtime": "^7.18.9",
"@hyperledger/aries-askar-react-native": "0.1.0-dev.8",
"@internal/agent": "*",
"@internal/scanner": "*",
"@internal/ui": "*",
"@react-native-community/blur": "^4.3.2",
"@react-native-masked-view/masked-view": "^0.2.9",
Expand Down Expand Up @@ -52,13 +51,5 @@
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"metro-minify-terser": "^0.74.1",
"typescript": "^4.7.4"
},
"resolutions": {
"metro": "0.76.0",
"metro-resolver": "0.76.0"
},
"overrides": {
"metro": "0.76.0",
"metro-resolver": "0.76.0"
}
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
},
"resolutions": {
"@unimodules/react-native-adapter": "./noop",
"@unimodules/core": "./noop"
"@unimodules/core": "./noop",
"metro": "0.76.0",
"metro-resolver": "0.76.0"
},
"dependencies": {
"@babel/runtime": "^7.18.9",
Expand Down
3 changes: 1 addition & 2 deletions packages/agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"@aries-framework/core": "^0.4.0-alpha.126",
"@aries-framework/openid4vc-client": "^0.4.0-alpha.126",
"@aries-framework/react-hooks": "0.4.2",
"@aries-framework/react-native": "^0.4.0-alpha.126",
"@sphereon/openid4vci-client": "^0.4.0"
"@aries-framework/react-native": "^0.4.0-alpha.126"
},
"peerDependencies": {
"@hyperledger/aries-askar-react-native": "0.1.0-dev.8"
Expand Down
2 changes: 0 additions & 2 deletions packages/agent/src/parsers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { AppAgent } from './agent'

import { DidKey } from '@aries-framework/core'
import { didKeyToInstanceOfKey } from '@aries-framework/core/build/modules/dids/helpers'
import { IssuanceInitiation } from '@sphereon/openid4vci-client'

export enum QrTypes {
OPENID_INITIATE_ISSUANCE = 'openid-initiate-issuance',
Expand Down
14 changes: 7 additions & 7 deletions packages/agent/src/providers/W3cCredentialsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as React from 'react'

type W3cCredentialRecordState = {
w3cCredentialRecords: Array<W3cCredentialRecord>
loading: boolean
isLoading: boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this change. Reason I kept it loading as that's the pattern used by the react-hooks AFJ extension and if we start using more types from there it will be inconsistent.

}

const addRecord = (
Expand All @@ -22,7 +22,7 @@ const addRecord = (
const newRecordsState = [...state.w3cCredentialRecords]
newRecordsState.unshift(record)
return {
loading: state.loading,
isLoading: state.isLoading,
w3cCredentialRecords: newRecordsState,
}
}
Expand All @@ -37,7 +37,7 @@ const updateRecord = (
newRecordsState[index] = record
}
return {
loading: state.loading,
isLoading: state.isLoading,
w3cCredentialRecords: newRecordsState,
}
}
Expand All @@ -48,7 +48,7 @@ const removeRecord = (
): W3cCredentialRecordState => {
const newRecordsState = state.w3cCredentialRecords.filter((r) => r.id !== record.id)
return {
loading: state.loading,
isLoading: state.isLoading,
w3cCredentialRecords: newRecordsState,
}
}
Expand Down Expand Up @@ -81,17 +81,17 @@ export const W3cCredentialRecordProvider: React.FC<PropsWithChildren<Props>> = (
}) => {
const [state, setState] = useState<W3cCredentialRecordState>({
w3cCredentialRecords: [],
loading: true,
isLoading: true,
})

useEffect(() => {
void agent.w3cCredentials
.getAllCredentialRecords()
.then((w3cCredentialRecords) => setState({ w3cCredentialRecords, loading: false }))
.then((w3cCredentialRecords) => setState({ w3cCredentialRecords, isLoading: false }))
}, [])

useEffect(() => {
if (!state.loading && agent) {
if (!state.isLoading && agent) {
const credentialAdded$ = recordsAddedByType(agent, W3cCredentialRecord).subscribe((record) =>
setState(addRecord(record, state))
)
Expand Down
31 changes: 25 additions & 6 deletions packages/app/components/CredentialCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,31 @@ import {
Heading,
Spacer,
Icon,
color,
} from '@internal/ui'

import { getTextColorBasedOnBg } from 'app/utils/utilts'
import { darken, getTextColorBasedOnBg } from 'app/utils/utils'

type CredentialCardProps = {
onPress?(): void
name?: string
issuerName?: string
subtitle?: string
iconUrl?: string
bgColor?: string
shadow?: boolean
}

export default function CredentialCard({
onPress,
iconUrl,
name = 'Credential',
subtitle,
issuerName = 'Unknown',
bgColor,
shadow = true,
}: CredentialCardProps) {
const textColor = getTextColorBasedOnBg(bgColor ?? '#000')
const textColor = getTextColorBasedOnBg(bgColor ?? color.black)

const icon = iconUrl ? (
<Image src={iconUrl} width={48} height={48} />
Expand All @@ -37,9 +42,21 @@ export default function CredentialCard({
)

return (
<YStack pad="lg" g="xl" br={borderRadiusSizes.xl} bg={bgColor ?? '$grey-900'} shadow>
<YStack
pad="lg"
g="xl"
br={borderRadiusSizes.xl}
bg={bgColor ?? '$grey-900'}
shadow={shadow}
width="100%"
border
pressStyle={{
backgroundColor: darken(bgColor ?? color['grey-900'], 0.025),
janrtvld marked this conversation as resolved.
Show resolved Hide resolved
}}
onPress={onPress}
>
<XStack jc="space-between">
{icon}
<XStack>{icon}</XStack>
<YStack>
<Heading variant="h3" textAlign="right" color={textColor}>
{name}
Expand All @@ -52,10 +69,12 @@ export default function CredentialCard({
<Spacer />
<XStack>
<YStack>
<Paragraph variant="sub" secondary color={textColor}>
<Paragraph variant="annotation" secondary color={textColor}>
Issuer
</Paragraph>
<Paragraph color={textColor}>{issuerName}</Paragraph>
<Paragraph variant="sub" color={textColor}>
{issuerName}
</Paragraph>
</YStack>
</XStack>
</YStack>
Expand Down
35 changes: 35 additions & 0 deletions packages/app/components/CredentialRowCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Heading, Paragraph, XStack, YStack, borderRadiusSizes, paddingSizes } from '@internal/ui'

interface CredentialRowCardProps {
name: string
issuer: string
onPress(): void
bgColor?: string
}

export default function CredentialRowCard({
name,
issuer,
bgColor,
onPress,
}: CredentialRowCardProps) {
return (
<XStack
onPress={onPress}
pad="md"
py={paddingSizes.sm}
g="lg"
pressStyle={{ backgroundColor: '$grey-100' }}
>
<XStack bg={bgColor ?? '$feature-500'} h="100%" w="25%" br={borderRadiusSizes.md} border />
<YStack>
<Heading variant="h3" numberOfLines={1}>
{name}
</Heading>
<Paragraph variant="sub" secondary>
{issuer}
</Paragraph>
</YStack>
</XStack>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function CredentialDetailScreen() {
}

const record = useW3cCredentialRecordById(id)
const credential = record?.credential as unknown as W3cCredential | undefined
const credential = record?.credential as unknown as W3cCredential

if (!credential) return null

Expand Down
23 changes: 0 additions & 23 deletions packages/app/features/home/screen.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export function CredentialNotificationScreen() {

const credential = credentialRecord.credential

if (!credential) return null

return (
<ScrollView>
<YStack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function QrScannerScreen() {
const onScan = (data: string) => {
// don't do anything if we already scanned the data
if (scannedData === readData) return

setScannedData(data)
if (isOpenIdCredentialOffer(scannedData)) {
void Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success)
Expand Down
Loading