From afaa2d22ebb7b9c3edce7f3ce8b34d316d217987 Mon Sep 17 00:00:00 2001 From: luciatugui Date: Fri, 27 Sep 2024 10:44:25 +0300 Subject: [PATCH] fix: [Contracts #410]- android scroll in identity/account data screens --- mobile/src/assets/locales/en/translation.json | 8 ++++++- mobile/src/assets/locales/ro/translation.json | 8 ++++++- mobile/src/layouts/PageLayout.tsx | 21 +++++++++++++++++-- mobile/src/screens/AccountData.tsx | 1 + mobile/src/screens/IdentityData.tsx | 1 + mobile/src/screens/RejectContract.tsx | 20 +++++++++++++----- 6 files changed, 50 insertions(+), 9 deletions(-) diff --git a/mobile/src/assets/locales/en/translation.json b/mobile/src/assets/locales/en/translation.json index bcb9bcd8..e592b4e6 100644 --- a/mobile/src/assets/locales/en/translation.json +++ b/mobile/src/assets/locales/en/translation.json @@ -839,12 +839,18 @@ "reject": { "title": "Reject contract", "reason": "Reason for rejection", + "reject_reason": { + "incorrect_identity_data": "The identity data is incorrect", + "dont_agree_with_clauses": "I don't agree with the clauses", + "wrong_contract_period": "The contract period is wrong", + "other": "Other reason" + }, "description": "The coordinator will receive your response. You may receive a new contract later. Mention the reason why the contract does not meet your expectations, or contact the coordinator of your organization.", "send": "Send", "sheet": { "title": "Response sent", "description": "Your response and the reason for rejecting the signature have been sent to the organization.", - "close": "Close", + "back_to_contracts": "Back to contracts", "identity": { "description": "Your response has been sent to the organization. Attention! The identity data in the contract is automatically taken from your account. Make sure it is correct and complete.", "action_btn_label": "Update identity data" diff --git a/mobile/src/assets/locales/ro/translation.json b/mobile/src/assets/locales/ro/translation.json index 9ef4b9cc..ef79756b 100644 --- a/mobile/src/assets/locales/ro/translation.json +++ b/mobile/src/assets/locales/ro/translation.json @@ -840,12 +840,18 @@ "reject": { "title": "Respinge contract", "reason": "Motivul respingerii", + "reject_reason": { + "incorrect_identity_data": "Datele de identitate nu sunt corecte", + "dont_agree_with_clauses": "Nu sunt de acord cu clauzele", + "wrong_contract_period": "Perioada contractului este greșită", + "other": "Alt motiv" + }, "description": "Coordonatorul va primi răspunsul tău. Poți primi un contract nou ulterior. Menționează motivul pentru care contractul nu este conform cu așteptările tale, sau ia legătura cu coordonatorul organizației tale.", "send": "Trimite", "sheet": { "title": "Răspuns înregistrat", "description": "Răspunsul tău și motivul pentru care ai refuzat semnarea au fost trimise către organizație.", - "close": "Închide", + "back_to_contracts": "Înapoi la contracte", "identity": { "description": "Răspunsul tău a fost trimis către organizație. Atenție! Datele de identitate din contract sunt preluate automat din contul tău. Asigură-te că acestea sunt corecte și complete.", "action_btn_label": "Actualizează datele de identitate" diff --git a/mobile/src/layouts/PageLayout.tsx b/mobile/src/layouts/PageLayout.tsx index 7d6c9a4d..93ae564c 100644 --- a/mobile/src/layouts/PageLayout.tsx +++ b/mobile/src/layouts/PageLayout.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode } from 'react'; +import React, { ReactNode, useEffect, useState } from 'react'; import { Layout, TopNavigation, @@ -34,6 +34,7 @@ interface PageLayoutProps { onEditButtonPress?: () => void; actionsOptions?: ActionsOptionsProps; headerStyle?: ViewStyle; + androidKeyboardAvoidingViewBehavior?: 'height' | 'padding' | 'position' | 'explicitUndefined'; } export const BackIcon = (props: any) => ; @@ -57,9 +58,17 @@ export const PageLayout = ({ onEditButtonPress, actionsOptions, headerStyle, + androidKeyboardAvoidingViewBehavior, }: PageLayoutProps) => { const theme = useTheme(); const insets = useSafeAreaInsets(); + const [ + internalAndroidKeyboardAvoidingViewBehavior, + setInternalAndroidKeyboardAvoidingViewBehavior, + ] = useState<'height' | 'padding' | 'position' | undefined>( + Platform.OS === 'ios' ? 'padding' : 'height', + ); + const renderLeftControl = () => { if (!onBackButtonPress) { return <>; @@ -76,6 +85,14 @@ export const PageLayout = ({ return ; }; + // sometimes we might want to set the keyboard avoiding view behavior to undefined on android + // but because sending undefined directly would be overwritten by the default value, we need to set it to 'explicitUndefined' and set it to undefined here + useEffect(() => { + if (Platform.OS === 'android' && androidKeyboardAvoidingViewBehavior === 'explicitUndefined') { + setInternalAndroidKeyboardAvoidingViewBehavior(undefined); + } + }, [androidKeyboardAvoidingViewBehavior]); + return ( <> diff --git a/mobile/src/screens/AccountData.tsx b/mobile/src/screens/AccountData.tsx index 7ba46761..063297f5 100644 --- a/mobile/src/screens/AccountData.tsx +++ b/mobile/src/screens/AccountData.tsx @@ -175,6 +175,7 @@ const AccountData = ({ navigation }: any) => { loading: isUpdatingProfile, }} headerStyle={{ paddingTop }} + androidKeyboardAvoidingViewBehavior="explicitUndefined" > diff --git a/mobile/src/screens/IdentityData.tsx b/mobile/src/screens/IdentityData.tsx index e849135d..d515ecdf 100644 --- a/mobile/src/screens/IdentityData.tsx +++ b/mobile/src/screens/IdentityData.tsx @@ -319,6 +319,7 @@ const IdentityData = ({ navigation, route }: any) => { loading: isUpdateingPersonalData, }} headerStyle={{ paddingTop }} + androidKeyboardAvoidingViewBehavior="explicitUndefined" > {`${t('description')}`} diff --git a/mobile/src/screens/RejectContract.tsx b/mobile/src/screens/RejectContract.tsx index 5ed65f8a..9b92c149 100644 --- a/mobile/src/screens/RejectContract.tsx +++ b/mobile/src/screens/RejectContract.tsx @@ -20,12 +20,22 @@ import upsIcon from '../assets/svg/ups-icon'; import InlineLink from '../components/InlineLink'; import Button from '../components/Button'; import { useQueryClient } from 'react-query'; +import i18n from '../common/config/i18n'; const rejectionOptionsArray = [ - { key: RejectionReason.INCORRECT_IDENTITY_DATA, label: 'Datele de identitate nu sunt corecte' }, - { key: RejectionReason.DONT_AGREE_WITH_CLAUSES, label: 'Nu sunt de acord cu clauzele' }, - { key: RejectionReason.WRONG_CONTRACT_PERIOD, label: 'Perioada contractului este greșită' }, - { key: RejectionReason.OTHER, label: 'Alt motiv' }, + { + key: RejectionReason.INCORRECT_IDENTITY_DATA, + label: i18n.t('documents-contract:reject.reject_reason.incorrect_identity_data'), + }, + { + key: RejectionReason.DONT_AGREE_WITH_CLAUSES, + label: i18n.t('documents-contract:reject.reject_reason.dont_agree_with_clauses'), + }, + { + key: RejectionReason.WRONG_CONTRACT_PERIOD, + label: i18n.t('documents-contract:reject.reject_reason.wrong_contract_period'), + }, + { key: RejectionReason.OTHER, label: i18n.t('documents-contract:reject.reject_reason.other') }, ]; interface FieldValues { @@ -181,7 +191,7 @@ export const RejectContract = ({ navigation, route }: any) => { /> )} { onCloseBottomSheet();