From 5f248ebeb56af0732c7128e71928adf372df3c71 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Wed, 22 Jun 2022 09:24:25 -0300 Subject: [PATCH] [NEW] Delete my account (#4219) * create new delete account button Co-Authored-By: Danish Ahmed Mirza * change modal to action sheet * better naming * remove ? from translation * update translations * change to new figma layout * fix export * remove unused state * add new text input to base input * clean up * update bottom sheet and create a mock * remove unecessary bracket and fix type * fix header * migrate buttons to action sheet * fix imports * update yarn.lock * add separator to styles * add ternary verification * minor tweaks: keyboard for landscape android tablet, interface IactionSheetProvider and remove navigation options to get ismasterdetail from redux, fix jest setup * fix colors * disconnect from sdk when delete the account * update snapshot Co-authored-by: Danish Ahmed Mirza Co-authored-by: Reinaldo Neto --- app/actions/actionsTypes.ts | 1 + app/actions/login.ts | 6 + app/containers/ActionSheet/ActionSheet.tsx | 7 +- app/containers/ActionSheet/FooterButtons.tsx | 36 +++++ app/containers/ActionSheet/Provider.tsx | 2 +- app/containers/ActionSheet/styles.ts | 7 + app/containers/TextInput/FormTextInput.tsx | 19 ++- app/definitions/rest/v1/users.ts | 3 + app/i18n/locales/en.json | 11 +- app/i18n/locales/pt-BR.json | 11 +- app/lib/constants/colors.ts | 3 + app/lib/constants/defaultSettings.ts | 3 + app/lib/methods/helpers/log/events.ts | 6 +- app/lib/methods/logout.ts | 4 +- app/lib/services/restApi.ts | 4 + app/reducers/login.ts | 5 + app/sagas/login.js | 38 ++++++ app/stacks/MasterDetailStack/index.tsx | 6 +- .../getTranslations.ts | 36 +++++ .../DeleteAccountActionSheetContent/index.tsx | 128 ++++++++++++++++++ .../DeleteAccountActionSheetContent/styles.ts | 28 ++++ app/views/ProfileView/index.tsx | 43 +++++- jest.setup.js | 9 ++ package.json | 2 +- .../stories/__snapshots__/List.storyshot | 22 +-- yarn.lock | 29 ++-- 26 files changed, 420 insertions(+), 49 deletions(-) create mode 100644 app/containers/ActionSheet/FooterButtons.tsx create mode 100644 app/views/ProfileView/components/DeleteAccountActionSheetContent/getTranslations.ts create mode 100644 app/views/ProfileView/components/DeleteAccountActionSheetContent/index.tsx create mode 100644 app/views/ProfileView/components/DeleteAccountActionSheetContent/styles.ts diff --git a/app/actions/actionsTypes.ts b/app/actions/actionsTypes.ts index a920e27e..29c38478 100644 --- a/app/actions/actionsTypes.ts +++ b/app/actions/actionsTypes.ts @@ -54,6 +54,7 @@ export const SERVER = createRequestTypes('SERVER', [ ]); export const METEOR = createRequestTypes('METEOR_CONNECT', [...defaultTypes, 'DISCONNECT']); export const LOGOUT = 'LOGOUT'; // logout is always success +export const DELETE_ACCOUNT = 'DELETE_ACCOUNT'; export const SNIPPETED_MESSAGES = createRequestTypes('SNIPPETED_MESSAGES', ['OPEN', 'READY', 'CLOSE', 'MESSAGES_RECEIVED']); export const DEEP_LINKING = createRequestTypes('DEEP_LINKING', ['OPEN']); export const SORT_PREFERENCES = createRequestTypes('SORT_PREFERENCES', ['SET_ALL', 'SET']); diff --git a/app/actions/login.ts b/app/actions/login.ts index 990c9f85..17174145 100644 --- a/app/actions/login.ts +++ b/app/actions/login.ts @@ -121,3 +121,9 @@ export function setLocalAuthenticated(isLocalAuthenticated: boolean): ISetLocalA isLocalAuthenticated }; } + +export function deleteAccount(): Action { + return { + type: types.DELETE_ACCOUNT + }; +} diff --git a/app/containers/ActionSheet/ActionSheet.tsx b/app/containers/ActionSheet/ActionSheet.tsx index c5cd66de..83c2e8ff 100644 --- a/app/containers/ActionSheet/ActionSheet.tsx +++ b/app/containers/ActionSheet/ActionSheet.tsx @@ -116,6 +116,10 @@ const ActionSheet = React.memo( const bottomSheet = isLandscape || isTablet ? styles.bottomSheet : {}; + // Must need this prop to avoid keyboard dismiss + // when is android tablet and the input text is focused + const androidTablet: any = isTablet && isLandscape && !isIOS ? { android_keyboardInputMode: 'adjustResize' } : {}; + return ( <> {children} @@ -130,7 +134,8 @@ const ActionSheet = React.memo( enablePanDownToClose style={{ ...styles.container, ...bottomSheet }} backgroundStyle={{ backgroundColor: colors.focusedBackground }} - onChange={index => index === -1 && toggleVisible()}> + onChange={index => index === -1 && toggleVisible()} + {...androidTablet}> )} diff --git a/app/containers/ActionSheet/FooterButtons.tsx b/app/containers/ActionSheet/FooterButtons.tsx new file mode 100644 index 00000000..ecdf0455 --- /dev/null +++ b/app/containers/ActionSheet/FooterButtons.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import { View } from 'react-native'; + +import Button from '../Button'; +import { useTheme } from '../../theme'; +import styles from './styles'; + +const FooterButtons = ({ + cancelAction = () => {}, + confirmAction = () => {}, + cancelTitle = '', + confirmTitle = '', + disabled = false, + cancelBackgroundColor = '', + confirmBackgroundColor = '' +}): React.ReactElement => { + const { colors } = useTheme(); + return ( + +