Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/warn when replacing #2176

Merged
merged 42 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
88b5040
mock login changes
rickycodes Jan 26, 2021
145c996
mock warning modal
rickycodes Jan 27, 2021
3e0c74f
mock delete modal
rickycodes Jan 27, 2021
872e07f
mock delete warning and submitDelete
rickycodes Jan 27, 2021
dc0d64c
Add isTextDelete
rickycodes Jan 27, 2021
6ca3cb8
Add autoFocus
rickycodes Jan 27, 2021
fe79bd8
clean up
rickycodes Jan 27, 2021
fc7206e
"delete"
rickycodes Jan 27, 2021
02a5a42
undo design changes
rickycodes Jan 27, 2021
c63a242
Add en translations
rickycodes Jan 28, 2021
9d589d3
Update unit tests
rickycodes Jan 28, 2021
282a69e
fix
rickycodes Jan 28, 2021
9bb4fd5
Make this async await and catch and log failure
rickycodes Jan 28, 2021
a4ac42e
Remove 12-word
rickycodes Jan 28, 2021
639d476
Adjust lineHeight
rickycodes Jan 28, 2021
c201aed
fix typo
rickycodes Feb 1, 2021
3d4d047
Add logic to show delete notification
rickycodes Feb 1, 2021
b29e786
Hide back button
rickycodes Feb 2, 2021
cdd14f9
Disable hardware back button press
rickycodes Feb 2, 2021
4245333
Add notification
rickycodes Feb 2, 2021
2cb85bc
Add closeButtonDisabled functionality
rickycodes Feb 2, 2021
647a65e
Update styles
rickycodes Feb 2, 2021
524bba0
Hide back button better on Congratulations screen
rickycodes Feb 2, 2021
4923e92
Update translation
rickycodes Feb 4, 2021
2de534e
Add breakpoint for small devices
rickycodes Feb 4, 2021
f7ecce9
add missing "a"
rickycodes Feb 4, 2021
3e450ef
fix warning modal
rickycodes Feb 4, 2021
096fc2a
Clean up BaseNotification component
rickycodes Feb 8, 2021
aa9fd1e
Remove added styles
rickycodes Feb 8, 2021
f341a50
Remove eslint-disable-next-line
rickycodes Feb 8, 2021
bd56293
Use InteractionManager
Feb 10, 2021
bd5206a
Remove empty onHide
rickycodes Feb 10, 2021
26ab86e
update empty callback
rickycodes Feb 10, 2021
80b3477
Cleanup
rickycodes Feb 10, 2021
89a3f45
Add flexDirection: 'row'
Feb 10, 2021
e0ca1af
Move styles to WarningExistingUserModal
Feb 10, 2021
6663d78
Dismiss keyboard
Feb 10, 2021
629baa8
Add strings to locales
rickycodes Feb 10, 2021
e70c70e
Simplify
rickycodes Feb 10, 2021
02e0a17
Add loading screen for delete
rickycodes Feb 11, 2021
61f671f
Actually delete wallet
rickycodes Feb 10, 2021
193c0fe
Fix modal tap area
Feb 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/actions/user/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@ export function protectWalletModalNotVisible() {
type: 'PROTECT_MODAL_NOT_VISIBLE'
};
}

export function loadingSet() {
return {
type: 'LOADING_SET'
};
}

export function loadingUnset() {
return {
type: 'LOADING_UNSET'
};
}
4 changes: 4 additions & 0 deletions app/components/UI/ActionModal/ActionContent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default function ActionContent({
confirmText,
confirmDisabled,
cancelButtonMode,
cancelButtonDisabled,
confirmButtonMode,
displayCancelButton,
displayConfirmButton,
Expand All @@ -76,6 +77,7 @@ export default function ActionContent({
>
{displayCancelButton && (
<StyledButton
disabled={cancelButtonDisabled}
testID={cancelTestID}
type={cancelButtonMode}
onPress={onCancelPress}
Expand Down Expand Up @@ -103,6 +105,7 @@ export default function ActionContent({

ActionContent.defaultProps = {
cancelButtonMode: 'neutral',
cancelButtonDisabled: false,
confirmButtonMode: 'warning',
confirmTestID: '',
cancelTestID: '',
Expand All @@ -117,6 +120,7 @@ ActionContent.defaultProps = {
};

ActionContent.propTypes = {
cancelButtonDisabled: PropTypes.bool,
/**
* TestID for the cancel button
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ exports[`ActionModal should render correctly 1`] = `
useNativeDriver={false}
>
<ActionContent
cancelButtonDisabled={false}
cancelButtonMode="neutral"
cancelTestID=""
cancelText="Cancel"
Expand Down
6 changes: 5 additions & 1 deletion app/components/UI/ActionModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export default function ActionModal({
actionContainerStyle,
childrenContainerStyle,
verticalButtons,
propagateSwipe
propagateSwipe,
cancelButtonDisabled
}) {
return (
<Modal
Expand All @@ -55,6 +56,7 @@ export default function ActionModal({
confirmText={confirmText}
confirmDisabled={confirmDisabled}
cancelButtonMode={cancelButtonMode}
cancelButtonDisabled={cancelButtonDisabled}
confirmButtonMode={confirmButtonMode}
displayCancelButton={displayCancelButton}
displayConfirmButton={displayConfirmButton}
Expand All @@ -74,6 +76,7 @@ export default function ActionModal({

ActionModal.defaultProps = {
cancelButtonMode: 'neutral',
cancelButtonDisabled: false,
confirmButtonMode: 'warning',
confirmTestID: '',
cancelTestID: '',
Expand All @@ -85,6 +88,7 @@ ActionModal.defaultProps = {
};

ActionModal.propTypes = {
cancelButtonDisabled: PropTypes.bool,
/**
* TestID for the cancel button
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`HintModal should render correctly 1`] = `
<ActionModal
cancelButtonDisabled={false}
cancelButtonMode="neutral"
cancelTestID=""
cancelText="Cancel"
Expand Down
190 changes: 100 additions & 90 deletions app/components/UI/Notification/BaseNotification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,102 +51,112 @@ const styles = StyleSheet.create({
}
});

/**
* BaseNotification component used to render in-app notifications
*/
export default function BaseNotification(props) {
const { status, data, onPress, onHide } = props;
// eslint-disable-next-line
_getIcon = () => {
switch (status) {
case 'pending':
case 'pending_withdrawal':
case 'pending_deposit':
case 'speedup':
return <AnimatedSpinner size={36} />;
case 'success_deposit':
case 'success_withdrawal':
case 'success':
case 'received':
case 'received_payment':
return <IonicIcon color={colors.green500} size={36} name="md-checkmark" style={styles.checkIcon} />;
case 'cancelled':
case 'error':
return (
<MaterialIcon color={colors.red} size={36} name="alert-circle-outline" style={styles.checkIcon} />
);
case 'simple_notification_rejected':
return <AntIcon color={colors.red} size={36} name="closecircleo" style={styles.checkIcon} />;
case 'simple_notification':
return <AntIcon color={colors.green500} size={36} name="checkcircleo" style={styles.checkIcon} />;
}
};
const getIcon = status => {
switch (status) {
case 'pending':
case 'pending_withdrawal':
case 'pending_deposit':
case 'speedup':
return <AnimatedSpinner size={36} />;
case 'success_deposit':
case 'success_withdrawal':
case 'success':
case 'received':
case 'received_payment':
return <IonicIcon color={colors.green500} size={36} name="md-checkmark" style={styles.checkIcon} />;
case 'cancelled':
case 'error':
return <MaterialIcon color={colors.red} size={36} name="alert-circle-outline" style={styles.checkIcon} />;
case 'simple_notification_rejected':
return <AntIcon color={colors.red} size={36} name="closecircleo" style={styles.checkIcon} />;
case 'simple_notification':
return <AntIcon color={colors.green500} size={36} name="checkcircleo" style={styles.checkIcon} />;
}
};

// eslint-disable-next-line no-undef
_getTitle = () => {
switch (status) {
case 'pending':
return strings('notifications.pending_title');
case 'pending_deposit':
return strings('notifications.pending_deposit_title');
case 'pending_withdrawal':
return strings('notifications.pending_withdrawal_title');
case 'success':
return strings('notifications.success_title', { nonce: parseInt(data.nonce) });
case 'success_deposit':
return strings('notifications.success_deposit_title');
case 'success_withdrawal':
return strings('notifications.success_withdrawal_title');
case 'received':
return strings('notifications.received_title', {
amount: data.amount,
assetType: data.assetType
});
case 'speedup':
return strings('notifications.speedup_title', { nonce: parseInt(data.nonce) });
case 'received_payment':
return strings('notifications.received_payment_title');
case 'cancelled':
return strings('notifications.cancelled_title');
case 'error':
return strings('notifications.error_title');
}
};
const getTitle = (status, { nonce, amount, assetType }) => {
switch (status) {
case 'pending':
return strings('notifications.pending_title');
case 'pending_deposit':
return strings('notifications.pending_deposit_title');
case 'pending_withdrawal':
return strings('notifications.pending_withdrawal_title');
case 'success':
return strings('notifications.success_title', { nonce: parseInt(nonce) });
case 'success_deposit':
return strings('notifications.success_deposit_title');
case 'success_withdrawal':
return strings('notifications.success_withdrawal_title');
case 'received':
return strings('notifications.received_title', {
amount,
assetType
});
case 'speedup':
return strings('notifications.speedup_title', { nonce: parseInt(nonce) });
case 'received_payment':
return strings('notifications.received_payment_title');
case 'cancelled':
return strings('notifications.cancelled_title');
case 'error':
return strings('notifications.error_title');
}
};

// eslint-disable-next-line no-undef
_getDescription = () => {
if (data && data.amount) {
return strings(`notifications.${status}_message`, { amount: data.amount });
}
return strings(`notifications.${status}_message`);
};
const getDescription = (status, { amount = null }) => {
if (amount) {
return strings(`notifications.${status}_message`, { amount });
}
return strings(`notifications.${status}_message`);
};

return (
<View style={baseStyles.flexGrow}>
<TouchableOpacity
style={styles.defaultFlashFloating}
testID={'press-notification-button'}
onPress={onPress}
activeOpacity={0.8}
>
<View style={styles.flashIcon}>{this._getIcon()}</View>
<View style={styles.flashLabel}>
<Text style={styles.flashTitle} testID={'notification-title'}>
{!data.title ? this._getTitle() : data.title}
</Text>
<Text style={styles.flashText}>{!data.title ? this._getDescription() : data.description}</Text>
</View>
<TouchableOpacity style={styles.closeTouchable} onPress={onHide}>
<IonicIcon name="ios-close" size={36} style={styles.closeIcon} />
</TouchableOpacity>
</TouchableOpacity>
</View>
);
}
/**
* BaseNotification component used to render in-app notifications
*/
const BaseNotification = ({
status,
data = null,
data: { description = null, title = null },
onPress,
onHide,
autoDismiss
}) => (
<View style={baseStyles.flexGrow}>
<TouchableOpacity
style={styles.defaultFlashFloating}
testID={'press-notification-button'}
onPress={onPress}
activeOpacity={0.8}
>
<View style={styles.flashIcon}>{getIcon(status)}</View>
<View style={styles.flashLabel}>
<Text style={styles.flashTitle} testID={'notification-title'}>
{!title ? getTitle(status, data) : title}
</Text>
<Text style={styles.flashText}>{!title ? getDescription(status, data) : description}</Text>
</View>
<View>
{autoDismiss && (
<TouchableOpacity style={styles.closeTouchable} onPress={onHide}>
<IonicIcon name="ios-close" size={36} style={styles.closeIcon} />
</TouchableOpacity>
)}
</View>
</TouchableOpacity>
</View>
);

BaseNotification.propTypes = {
status: PropTypes.string,
data: PropTypes.object,
onPress: PropTypes.func,
onHide: PropTypes.func
onHide: PropTypes.func,
autoDismiss: PropTypes.bool
};

BaseNotification.defaultProps = {
autoDismiss: false
};

export default BaseNotification;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`SeedphraseModal should render correctly 1`] = `
"borderTopWidth": 0,
}
}
cancelButtonDisabled={false}
cancelButtonMode="neutral"
cancelTestID=""
cancelText="Cancel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`HintModal should render correctly 1`] = `
"borderTopWidth": 0,
}
}
cancelButtonDisabled={false}
cancelButtonMode="normal"
cancelTestID=""
cancelText="Secure now"
Expand Down
Loading