Skip to content

Commit

Permalink
feat: export connection alert modal (#1408)
Browse files Browse the repository at this point in the history
Signed-off-by: ZouidiSamih <[email protected]>
  • Loading branch information
ZouidiSamih authored Jan 23, 2025
1 parent 410b369 commit 313b374
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/legacy/core/App/container-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const COMPONENT_TOKENS = {
COMPONENT_PIN_CREATE_HEADER: 'component.pin-create-header',
COMPONENT_CONTACT_LIST_ITEM: 'component.contact-list-item',
COMPONENT_CONTACT_DETAILS_CRED_LIST_ITEM: 'component.contact-details-cred-list-item',
COMPONENT_CONNECTION_ALERT: 'component.connection-alert',
} as const

export const NOTIFICATION_TOKENS = {
Expand Down Expand Up @@ -195,6 +196,7 @@ export type TokenMapping = {
[TOKENS.COMPONENT_CONTACT_DETAILS_CRED_LIST_ITEM]: React.FC<ContactCredentialListItemProps>
[TOKENS.INLINE_ERRORS]: InlineErrorConfig
[TOKENS.CUSTOM_NAV_STACK_1]: React.FC
[TOKENS.COMPONENT_CONNECTION_ALERT]: React.FC<{ connectionID?: string }>
}

export interface Container {
Expand Down
2 changes: 2 additions & 0 deletions packages/legacy/core/App/container-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import ContactListItem from './components/listItems/ContactListItem'
import ContactCredentialListItem from './components/listItems/ContactCredentialListItem'
import { InlineErrorPosition } from './types/error'
import { DefaultScreenLayoutOptions } from './navigators/defaultLayoutOptions'
import ConnectionAlert from './components/misc/ConnectionAlert'

export const defaultConfig: Config = {
PINSecurity: { rules: PINRules, displayHelper: false },
Expand Down Expand Up @@ -144,6 +145,7 @@ export class MainContainer implements Container {
this._container.registerInstance(TOKENS.COMPONENT_RECORD, Record)
this._container.registerInstance(TOKENS.COMPONENT_CONTACT_LIST_ITEM, ContactListItem)
this._container.registerInstance(TOKENS.COMPONENT_CONTACT_DETAILS_CRED_LIST_ITEM, ContactCredentialListItem)
this._container.registerInstance(TOKENS.COMPONENT_CONNECTION_ALERT, ConnectionAlert)
this._container.registerInstance(TOKENS.CACHE_CRED_DEFS, [])
this._container.registerInstance(TOKENS.CACHE_SCHEMAS, [])
this._container.registerInstance(TOKENS.INLINE_ERRORS, {
Expand Down
6 changes: 3 additions & 3 deletions packages/legacy/core/App/screens/CredentialOffer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { DeviceEventEmitter, StyleSheet, Text, View } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'

import Button, { ButtonType } from '../components/buttons/Button'
import ConnectionAlert from '../components/misc/ConnectionAlert'
import ConnectionImage from '../components/misc/ConnectionImage'
import CredentialCard from '../components/misc/CredentialCard'
import CommonRemoveModal from '../components/modals/CommonRemoveModal'
Expand Down Expand Up @@ -75,6 +74,7 @@ const CredentialOffer: React.FC<CredentialOfferProps> = ({ navigation, credentia
const { start } = useTour()
const screenIsFocused = useIsFocused()
const goalCode = useOutOfBandByConnectionId(credential?.connectionId ?? '')?.outOfBandInvitation?.goalCode
const [ConnectionAlert] = useServices([TOKENS.COMPONENT_CONNECTION_ALERT])

const styles = StyleSheet.create({
headerTextContainer: {
Expand Down Expand Up @@ -278,9 +278,9 @@ const CredentialOffer: React.FC<CredentialOfferProps> = ({ navigation, credentia
}}
>
{loading ? <RecordLoading /> : null}
{credentialConnectionLabel && goalCode === 'aries.vc.issue' ? (
{(credentialConnectionLabel && goalCode === 'aries.vc.issue') && (
<ConnectionAlert connectionID={credentialConnectionLabel} />
) : null}
)}
<View style={styles.footerButton}>
<Button
title={t('Global.Accept')}
Expand Down
6 changes: 3 additions & 3 deletions packages/legacy/core/App/screens/ProofRequest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import Icon from 'react-native-vector-icons/MaterialIcons'

import Button, { ButtonType } from '../components/buttons/Button'
import { CredentialCard } from '../components/misc'
import ConnectionAlert from '../components/misc/ConnectionAlert'
import ConnectionImage from '../components/misc/ConnectionImage'
import { InfoBoxType } from '../components/misc/InfoBox'
import CommonRemoveModal from '../components/modals/CommonRemoveModal'
Expand Down Expand Up @@ -104,6 +103,7 @@ const ProofRequest: React.FC<ProofRequestProps> = ({ navigation, proofId }) => {
const [attestationLoading, setAttestationLoading] = useState(false)
const [store, dispatch] = useStore()
const credProofPromise = useAllCredentialsForProof(proofId)
const [ConnectionAlert] = useServices([TOKENS.COMPONENT_CONNECTION_ALERT])
const proofConnectionLabel = useMemo(
() => getConnectionName(connection, store.preferences.alternateContactNames),
[connection, store.preferences.alternateContactNames]
Expand Down Expand Up @@ -714,9 +714,9 @@ const ProofRequest: React.FC<ProofRequestProps> = ({ navigation, proofId }) => {
{t('ProofRequest.SensitiveInformation')}
</InfoTextBox>
)}
{!loading && proofConnectionLabel && goalCode === 'aries.vc.verify' ? (
{(!loading && proofConnectionLabel && goalCode === 'aries.vc.verify') && (
<ConnectionAlert connectionID={proofConnectionLabel} />
) : null}
)}
{!loading && isShareDisabled() ? (
<View style={styles.footerButton}>
<Button
Expand Down

0 comments on commit 313b374

Please sign in to comment.