-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
497 additions
and
211 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
65 changes: 65 additions & 0 deletions
65
app/components/UI/InstallSnapApproval/InstallSnapApproval.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,65 @@ | ||
import React from 'react'; | ||
import { Text, View } from 'react-native'; | ||
import { useSelector } from 'react-redux'; | ||
import { InstallSnapApprovalArgs } from './types'; | ||
import createStyles from './styles'; | ||
import { useAppThemeFromContext, mockTheme } from '../../../util/theme'; | ||
import StyledButton from '../StyledButton'; | ||
import { strings } from '../../../../locales/i18n'; | ||
import { | ||
ACCOUNT_APROVAL_MODAL_CONTAINER_ID, | ||
CANCEL_BUTTON_ID, | ||
} from '../../../constants/test-ids'; | ||
|
||
const InstallSnapApproval = ({ | ||
requestData, | ||
onConfirm, | ||
onCancel, | ||
}: InstallSnapApprovalArgs) => { | ||
const { colors } = useAppThemeFromContext() || mockTheme; | ||
const styles = createStyles(colors); | ||
|
||
const selectedAddress = useSelector( | ||
(state: any) => | ||
state.engine.backgroundState.PreferencesController.selectedAddress, | ||
); | ||
|
||
const confirm = (): void => { | ||
// eslint-disable-next-line no-console | ||
console.log('confirm', onConfirm); | ||
onConfirm(); | ||
// Add track event | ||
}; | ||
|
||
const cancel = (): void => { | ||
// Add track event | ||
onCancel(); | ||
}; | ||
|
||
return ( | ||
<View style={styles.root} testID={ACCOUNT_APROVAL_MODAL_CONTAINER_ID}> | ||
{/* <Text>SNAP ID: {`${requestData.data.snapId}`}</Text> */} | ||
<Text>{`${selectedAddress} ${JSON.stringify(requestData)}`}</Text> | ||
<View style={styles.actionContainer}> | ||
<StyledButton | ||
type={'cancel'} | ||
onPress={cancel} | ||
containerStyle={[styles.button, styles.cancel]} | ||
testID={CANCEL_BUTTON_ID} | ||
> | ||
{strings('accountApproval.cancel')} | ||
</StyledButton> | ||
<StyledButton | ||
type={'confirm'} | ||
onPress={confirm} | ||
containerStyle={[styles.button, styles.confirm]} | ||
testID={'connect-approve-button'} | ||
> | ||
Approve | ||
</StyledButton> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
export default InstallSnapApproval; |
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,6 @@ | ||
import InstallSnapApproval from './InstallSnapApproval'; | ||
import { InstallSnapApprovalArgs } from './types'; | ||
|
||
export { InstallSnapApproval }; | ||
|
||
export type { InstallSnapApprovalArgs }; |
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,52 @@ | ||
import { StyleSheet } from 'react-native'; | ||
import { fontStyles } from '../../../styles/common'; | ||
import Device from '../../../util/device'; | ||
|
||
const createStyles = (colors: any) => | ||
StyleSheet.create({ | ||
root: { | ||
backgroundColor: colors.background.default, | ||
paddingTop: 24, | ||
borderTopLeftRadius: 20, | ||
borderTopRightRadius: 20, | ||
minHeight: 200, | ||
paddingBottom: Device.isIphoneX() ? 20 : 0, | ||
}, | ||
accountCardWrapper: { | ||
paddingHorizontal: 24, | ||
}, | ||
intro: { | ||
...fontStyles.bold, | ||
textAlign: 'center', | ||
color: colors.text.default, | ||
fontSize: Device.isSmallDevice() ? 16 : 20, | ||
marginBottom: 8, | ||
marginTop: 16, | ||
}, | ||
warning: { | ||
...fontStyles.thin, | ||
color: colors.text.default, | ||
paddingHorizontal: 24, | ||
marginBottom: 16, | ||
fontSize: 14, | ||
width: '100%', | ||
textAlign: 'center', | ||
}, | ||
actionContainer: { | ||
flex: 0, | ||
flexDirection: 'row', | ||
paddingVertical: 16, | ||
paddingHorizontal: 24, | ||
}, | ||
button: { | ||
flex: 1, | ||
}, | ||
cancel: { | ||
marginRight: 8, | ||
}, | ||
confirm: { | ||
marginLeft: 8, | ||
}, | ||
}); | ||
|
||
export default createStyles; |
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,9 @@ | ||
interface InstallSnapApprovalArgs { | ||
requestData: any; | ||
onConfirm: () => void; | ||
onCancel: () => void; | ||
chainId?: string; | ||
} | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export type { InstallSnapApprovalArgs }; |
Oops, something went wrong.