Changeset View
Changeset View
Standalone View
Standalone View
native/account/fullscreen-siwe-panel.react.js
// @flow | // @flow | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { ActivityIndicator, View } from 'react-native'; | import { Alert, ActivityIndicator, View } from 'react-native'; | ||||
import { useSIWEServerCall } from './siwe-hooks.js'; | |||||
import SIWEPanel from './siwe-panel.react.js'; | import SIWEPanel from './siwe-panel.react.js'; | ||||
type Props = { | type Props = { | ||||
+onClose: () => mixed, | +onClose: () => mixed, | ||||
+closing: boolean, | +closing: boolean, | ||||
}; | }; | ||||
function FullscreenSIWEPanel(props: Props): React.Node { | function FullscreenSIWEPanel(props: Props): React.Node { | ||||
const [loading, setLoading] = React.useState(true); | const [loading, setLoading] = React.useState(true); | ||||
const activity = loading ? <ActivityIndicator size="large" /> : null; | const activity = loading ? <ActivityIndicator size="large" /> : null; | ||||
const activityContainer = React.useMemo( | const activityContainer = React.useMemo( | ||||
() => ({ | () => ({ | ||||
flex: 1, | flex: 1, | ||||
}), | }), | ||||
[], | [], | ||||
); | ); | ||||
const { onClose, closing } = props; | const { onClose } = props; | ||||
const siweServerCallParams = React.useMemo(() => { | |||||
const onServerCallFailure = () => { | |||||
Alert.alert( | |||||
'Unknown error', | |||||
'Uhh... try again?', | |||||
[{ text: 'OK', onPress: onClose }], | |||||
{ cancelable: false }, | |||||
); | |||||
}; | |||||
return { onFailure: onServerCallFailure }; | |||||
}, [onClose]); | |||||
const siweServerCall = useSIWEServerCall(siweServerCallParams); | |||||
const { closing } = props; | |||||
return ( | return ( | ||||
<> | <> | ||||
<View style={activityContainer}>{activity}</View> | <View style={activityContainer}>{activity}</View> | ||||
<SIWEPanel | <SIWEPanel | ||||
closing={closing} | closing={closing} | ||||
onClosed={onClose} | onClosed={onClose} | ||||
onClosing={onClose} | onClosing={onClose} | ||||
onSuccessfulWalletSignature={siweServerCall} | |||||
setLoading={setLoading} | setLoading={setLoading} | ||||
/> | /> | ||||
</> | </> | ||||
); | ); | ||||
} | } | ||||
export default FullscreenSIWEPanel; | export default FullscreenSIWEPanel; |