forked from cerc-io/laconic-wallet
Add toast on session approval (#46)
* Add toast on session_approval * Handle case where request icon is null * Change camera permission message * Fix comments * Fix import order --------- Co-authored-by: Adw8 <adwait@deepstacksoft.com>
This commit is contained in:
parent
d7ebdd6063
commit
4b0ed0ba9f
17
App.tsx
17
App.tsx
@ -1,4 +1,5 @@
|
|||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
|
import { Snackbar } from 'react-native-paper';
|
||||||
|
|
||||||
import { SignClientTypes } from '@walletconnect/types';
|
import { SignClientTypes } from '@walletconnect/types';
|
||||||
import { NavigationContainer } from '@react-navigation/native';
|
import { NavigationContainer } from '@react-navigation/native';
|
||||||
@ -30,7 +31,7 @@ const App = (): React.JSX.Element => {
|
|||||||
const { requestSession, setRequestSession } = useRequests();
|
const { requestSession, setRequestSession } = useRequests();
|
||||||
|
|
||||||
const [modalVisible, setModalVisible] = useState(false);
|
const [modalVisible, setModalVisible] = useState(false);
|
||||||
//TODO: Remove any
|
const [toastVisible, setToastVisible] = useState(false);
|
||||||
const [currentProposal, setCurrentProposal] = useState<
|
const [currentProposal, setCurrentProposal] = useState<
|
||||||
SignClientTypes.EventArguments['session_proposal'] | undefined
|
SignClientTypes.EventArguments['session_proposal'] | undefined
|
||||||
>();
|
>();
|
||||||
@ -85,7 +86,7 @@ const App = (): React.JSX.Element => {
|
|||||||
web3wallet?.off('session_proposal', onSessionProposal);
|
web3wallet?.off('session_proposal', onSessionProposal);
|
||||||
web3wallet?.off('session_request', onSessionRequest);
|
web3wallet?.off('session_request', onSessionRequest);
|
||||||
};
|
};
|
||||||
//TODO: Investigate dependancies
|
//TODO: Investigate dependencies
|
||||||
});
|
});
|
||||||
|
|
||||||
const linking = {
|
const linking = {
|
||||||
@ -147,7 +148,19 @@ const App = (): React.JSX.Element => {
|
|||||||
currentProposal={currentProposal}
|
currentProposal={currentProposal}
|
||||||
setCurrentProposal={setCurrentProposal}
|
setCurrentProposal={setCurrentProposal}
|
||||||
currentEthAddresses={currentEthAddresses}
|
currentEthAddresses={currentEthAddresses}
|
||||||
|
setToastVisible={setToastVisible}
|
||||||
/>
|
/>
|
||||||
|
<Snackbar
|
||||||
|
visible={toastVisible}
|
||||||
|
onDismiss={() => setToastVisible(false)}
|
||||||
|
action={{
|
||||||
|
label: 'Ok',
|
||||||
|
onPress: () => {
|
||||||
|
setToastVisible(false);
|
||||||
|
},
|
||||||
|
}}>
|
||||||
|
Session approved
|
||||||
|
</Snackbar>
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -15,6 +15,7 @@ const PairingModal = ({
|
|||||||
currentEthAddresses,
|
currentEthAddresses,
|
||||||
setCurrentProposal,
|
setCurrentProposal,
|
||||||
setModalVisible,
|
setModalVisible,
|
||||||
|
setToastVisible,
|
||||||
}: PairingModalProps) => {
|
}: PairingModalProps) => {
|
||||||
const url = currentProposal?.params?.proposer?.metadata.url;
|
const url = currentProposal?.params?.proposer?.metadata.url;
|
||||||
const methods = currentProposal?.params?.requiredNamespaces.eip155.methods;
|
const methods = currentProposal?.params?.requiredNamespaces.eip155.methods;
|
||||||
@ -47,6 +48,7 @@ const PairingModal = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
setModalVisible(false);
|
setModalVisible(false);
|
||||||
|
setToastVisible(true);
|
||||||
setCurrentProposal(undefined);
|
setCurrentProposal(undefined);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -160,12 +160,12 @@ const SignRequest = ({ route }: SignRequestProps) => {
|
|||||||
) : (
|
) : (
|
||||||
<View style={styles.appContainer}>
|
<View style={styles.appContainer}>
|
||||||
<View style={styles.dappDetails}>
|
<View style={styles.dappDetails}>
|
||||||
<Image
|
{requestIcon && (
|
||||||
style={styles.dappLogo}
|
<Image
|
||||||
source={{
|
style={styles.dappLogo}
|
||||||
uri: requestIcon,
|
source={requestIcon ? { uri: requestIcon } : undefined}
|
||||||
}}
|
/>
|
||||||
/>
|
)}
|
||||||
<Text>{requestName}</Text>
|
<Text>{requestName}</Text>
|
||||||
<Text variant="bodyMedium">{requestURL}</Text>
|
<Text variant="bodyMedium">{requestURL}</Text>
|
||||||
</View>
|
</View>
|
||||||
|
@ -62,7 +62,9 @@ const WalletConnect = () => {
|
|||||||
<View style={styles.appContainer}>
|
<View style={styles.appContainer}>
|
||||||
{!hasPermission || !device ? (
|
{!hasPermission || !device ? (
|
||||||
<Text>
|
<Text>
|
||||||
{!hasPermission ? 'No Camera Permission!' : 'No Camera Selected!'}
|
{!hasPermission
|
||||||
|
? 'No Camera Permission granted'
|
||||||
|
: 'No Camera Selected'}
|
||||||
</Text>
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
|
1
types.ts
1
types.ts
@ -98,6 +98,7 @@ export interface PairingModalProps {
|
|||||||
setCurrentProposal: (
|
setCurrentProposal: (
|
||||||
arg1: SignClientTypes.EventArguments['session_proposal'] | undefined,
|
arg1: SignClientTypes.EventArguments['session_proposal'] | undefined,
|
||||||
) => void;
|
) => void;
|
||||||
|
setToastVisible: (arg1: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SignModalProps {
|
export interface SignModalProps {
|
||||||
|
Loading…
Reference in New Issue
Block a user