-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wallet screen detail screen (#148)
Signed-off-by: Timo Glastra <[email protected]>
- Loading branch information
1 parent
c16fbf4
commit d61d4b1
Showing
48 changed files
with
478 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
import { QrScannerScreen } from '@package/app' | ||
|
||
export default function Screen() { | ||
return ( | ||
<> | ||
<QrScannerScreen /> | ||
</> | ||
) | ||
return <QrScannerScreen allowedInvitationTypes={['openid-authorization-request']} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { FunkePidCredentialDetailScreen } from '@ausweis/features/wallet/FunkePidCredentialDetailScreen' | ||
import { Stack } from 'expo-router' | ||
|
||
export default function Screen() { | ||
return ( | ||
<> | ||
<Stack.Screen | ||
options={{ | ||
title: 'Credential', | ||
// TODO: would be nice if header dissapears when scrolling but can't get | ||
// the header to not show... :( | ||
}} | ||
/> | ||
<FunkePidCredentialDetailScreen /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
apps/ausweis/src/app/(app)/notifications/openIdCredential.tsx
This file was deleted.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
apps/ausweis/src/app/(app)/notifications/openIdPresentation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { OpenIdPresentationNotificationScreen } from '@package/app' | ||
import { ModalProvider, OpenIdPresentationNotificationScreen } from '@package/app' | ||
|
||
export default function Screen() { | ||
return ( | ||
<> | ||
<ModalProvider> | ||
<OpenIdPresentationNotificationScreen /> | ||
</> | ||
</ModalProvider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apps/ausweis/src/features/wallet/FunkePidCredentialDetailScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Button, Heading, HeroIcons, IdCard, ScrollView, Spacer, Stack, YStack } from '@package/ui' | ||
import React from 'react' | ||
import { useRouter } from 'solito/router' | ||
|
||
import { CredentialAttributes } from '@package/app/src/components' | ||
import { useScrollViewPosition } from '@package/app/src/hooks' | ||
|
||
import germanIssuerImage from '../../../assets/german-issuer-image.png' | ||
import { usePidCredential } from '../../hooks' | ||
|
||
export function FunkePidCredentialDetailScreen() { | ||
const { handleScroll, isScrolledByOffset, scrollEventThrottle } = useScrollViewPosition() | ||
const router = useRouter() | ||
|
||
const { isLoading, credential } = usePidCredential() | ||
if (isLoading) { | ||
return null | ||
} | ||
|
||
return ( | ||
<YStack bg="$background" height="100%"> | ||
<Spacer size="$13" /> | ||
<YStack borderWidth={isScrolledByOffset ? 0.5 : 0} borderColor="$grey-300" /> | ||
<ScrollView onScroll={handleScroll} scrollEventThrottle={scrollEventThrottle}> | ||
<YStack g="xl" pad="lg" py="$4"> | ||
<IdCard issuerImage={germanIssuerImage} small /> | ||
<Stack g="md"> | ||
<Heading variant="title">Personalausweis</Heading> | ||
<CredentialAttributes subject={credential.attributes} headerTitle="Attributes" /> | ||
<Button.Text onPress={() => router.back()} icon={<HeroIcons.ArrowLeft size={20} />}> | ||
Back | ||
</Button.Text> | ||
</Stack> | ||
</YStack> | ||
</ScrollView> | ||
</YStack> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Heading, HeroIcons, IdCard, Page, ScrollView, Spacer, Spinner, Stack, XStack, YStack } from '@package/ui' | ||
import { useSafeAreaInsets } from 'react-native-safe-area-context' | ||
import { useRouter } from 'solito/router' | ||
|
||
import { usePidCredential } from '@ausweis/hooks' | ||
import { useNetworkCallback } from '@package/app/src/hooks' | ||
import { capitalizeFirstLetter } from '@package/utils' | ||
import Reanimated from 'react-native-reanimated' | ||
import germanIssuerImage from '../../../assets/german-issuer-image.png' | ||
|
||
export function FunkeWalletScreen() { | ||
const { push } = useRouter() | ||
const { isLoading, credential } = usePidCredential() | ||
const { bottom } = useSafeAreaInsets() | ||
const navigateToPidDetail = () => push('/credentials/pid') | ||
const navigateToScanner = useNetworkCallback(() => push('/scan')) | ||
|
||
if (isLoading) { | ||
return ( | ||
<Page jc="center" ai="center"> | ||
<Spinner /> | ||
</Page> | ||
) | ||
} | ||
|
||
return ( | ||
<> | ||
<XStack position="absolute" width="100%" zIndex={5} justifyContent="center" bottom={bottom ?? '$6'}> | ||
<YStack | ||
bg="$grey-900" | ||
br="$12" | ||
borderWidth="$2" | ||
borderColor="#e9e9eb" | ||
p="$3.5" | ||
pressStyle={{ backgroundColor: '$grey-800' }} | ||
shadowOffset={{ width: 5, height: 5 }} | ||
shadowColor="$grey-500" | ||
shadowOpacity={0.5} | ||
shadowRadius={10} | ||
onPress={() => navigateToScanner()} | ||
> | ||
<HeroIcons.QrCode color="$grey-100" size={48} /> | ||
</YStack> | ||
</XStack> | ||
<YStack bg="$background" py="$4" height="100%" position="relative"> | ||
<ScrollView px="$4" gap="$2"> | ||
<YStack gap="$4"> | ||
<Heading variant="title" fontWeight="$bold"> | ||
{capitalizeFirstLetter(credential.attributes.given_name.toLowerCase())}'s Wallet | ||
</Heading> | ||
<IdCard issuerImage={germanIssuerImage} onPress={navigateToPidDetail} hideUserName /> | ||
<Spacer /> | ||
<Heading variant="h1">Recent Activity</Heading> | ||
</YStack> | ||
</ScrollView> | ||
</YStack> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './usePidCredential' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { useCredentialsForDisplay } from '@package/agent' | ||
import { capitalizeFirstLetter } from '@package/utils' | ||
import { useMemo } from 'react' | ||
|
||
export function usePidCredential() { | ||
const { isLoading, credentials } = useCredentialsForDisplay() | ||
const credential = credentials[0] | ||
|
||
const pidCredential = useMemo(() => { | ||
if (!credential) return undefined | ||
|
||
const attributes = credential.attributes as { | ||
given_name: string | ||
family_name: string | ||
birth_family_name: string | ||
place_of_birth: { | ||
locality: string | ||
} | ||
address: { | ||
locality: string | ||
street_address: string | ||
country: string | ||
} | ||
[key: string]: unknown | ||
} | ||
|
||
return { | ||
id: credential.id, | ||
attributes, | ||
userName: `${capitalizeFirstLetter(attributes.given_name.toLowerCase())} ${capitalizeFirstLetter(attributes.family_name.toLowerCase())}`, | ||
} | ||
}, [credential]) | ||
|
||
if (isLoading || !pidCredential) { | ||
return { | ||
credential: undefined, | ||
isLoading: true, | ||
} as const | ||
} | ||
|
||
return { | ||
isLoading, | ||
credential: pidCredential, | ||
} as const | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.