Skip to content

Commit

Permalink
[INJIMOB-864] disable backup button when restoring and vice versa (#1279
Browse files Browse the repository at this point in the history
)

Signed-off-by: KiruthikaJeyashankar <81218987+KiruthikaJeyashankar@users.noreply.github.com>
  • Loading branch information
KiruthikaJeyashankar authored Feb 20, 2024
1 parent 688a33f commit 854d8e2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
9 changes: 8 additions & 1 deletion components/ui/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ export const Button: React.FC<ButtonProps> = props => {
const buttonStyle: StyleProp<ViewStyle> = [
props.fill ? Theme.ButtonStyles.fill : null,
Theme.ButtonStyles[type],
props.disabled && props.type === 'outline'
? Theme.ButtonStyles.disabledOutlineButton
: null,
{width: props.width ?? '100%'},
];
const containerStyle: StyleProp<ViewStyle> = [
!(type === 'gradient') ? Theme.ButtonStyles.container : null,
props.disabled ? Theme.ButtonStyles.disabled : null,
props.disabled && props.type !== 'outline'
? Theme.ButtonStyles.disabled
: null,
props.margin ? Theme.spacing('margin', props.margin) : null,
type === 'gradient'
? props.isVcThere
Expand Down Expand Up @@ -53,6 +58,8 @@ export const Button: React.FC<ButtonProps> = props => {
? Theme.Colors.whiteText
: type === 'plain'
? Theme.Colors.plainText
: type === 'outline' && props.disabled
? Theme.Colors.textLabel
: Theme.Colors.AddIdBtnTxt
}>
{props.title}
Expand Down
5 changes: 5 additions & 0 deletions components/ui/themes/DefaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,11 @@ export const DefaultTheme = {
backgroundColor: Colors.Transparent,
borderColor: Colors.Orange,
},
disabledOutlineButton: {
backgroundColor: Colors.Transparent,
color: Colors.Grey,
borderColor: Colors.Grey,
},
container: {
height: 45,
flexDirection: 'row',
Expand Down
5 changes: 5 additions & 0 deletions components/ui/themes/PurpleTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,11 @@ export const PurpleTheme = {
backgroundColor: Colors.Transparent,
borderColor: Colors.Purple,
},
disabledOutlineButton: {
backgroundColor: Colors.Transparent,
color: Colors.Grey,
borderColor: Colors.Grey,
},
container: {
height: 45,
flexDirection: 'row',
Expand Down
16 changes: 13 additions & 3 deletions screens/backupAndRestore/BackupAndRestoreScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ const BackupAndRestoreScreen: React.FC<BackupAndRestoreProps> = props => {
props.shouldTriggerAutoBackup,
]);

function handleRestore() {
!backupController.isBackupInProgress && restoreController.BACKUP_RESTORE();
}

function handleBackup() {
!restoreController.isBackUpRestoring && backupController.DATA_BACKUP(false);
}

const Loading = testID => (
<Centered fill>
<LoaderAnimation testID={testID} showLogo={false} />
Expand Down Expand Up @@ -116,8 +124,9 @@ const BackupAndRestoreScreen: React.FC<BackupAndRestoreProps> = props => {
testID="backup"
type="gradient"
title={t('backup')}
onPress={() => backupController.DATA_BACKUP(false)}
styles={{...Theme.MessageOverlayStyles.button, flex: 1}}
disabled={restoreController.isBackUpRestoring}
onPress={handleBackup}
styles={{flex: 1}}
/>
)}
</Row>
Expand Down Expand Up @@ -172,7 +181,8 @@ const BackupAndRestoreScreen: React.FC<BackupAndRestoreProps> = props => {
testID="restore"
type="outline"
title={t('restore')}
onPress={restoreController.BACKUP_RESTORE}
disabled={backupController.isBackupInProgress}
onPress={handleRestore}
styles={{...Theme.MessageOverlayStyles.button, marginTop: 10}}
/>
)}
Expand Down

0 comments on commit 854d8e2

Please sign in to comment.