Skip to content

Commit

Permalink
fix: [Contracts #410]- android scroll in identity/account data screens
Browse files Browse the repository at this point in the history
  • Loading branch information
luciatugui committed Sep 27, 2024
1 parent 5556808 commit afaa2d2
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
8 changes: 7 additions & 1 deletion mobile/src/assets/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion mobile/src/assets/locales/ro/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 19 additions & 2 deletions mobile/src/layouts/PageLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode } from 'react';
import React, { ReactNode, useEffect, useState } from 'react';
import {
Layout,
TopNavigation,
Expand Down Expand Up @@ -34,6 +34,7 @@ interface PageLayoutProps {
onEditButtonPress?: () => void;
actionsOptions?: ActionsOptionsProps;
headerStyle?: ViewStyle;
androidKeyboardAvoidingViewBehavior?: 'height' | 'padding' | 'position' | 'explicitUndefined';
}

export const BackIcon = (props: any) => <Icon {...props} name="arrow-left" />;
Expand All @@ -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 <></>;
Expand All @@ -76,6 +85,14 @@ export const PageLayout = ({
return <TopNavigationAction icon={EditIcon} onPress={onEditButtonPress} />;
};

// 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 (
<>
<TopNavigation
Expand All @@ -87,7 +104,7 @@ export const PageLayout = ({
/>
<Layout style={styles.layout}>
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
behavior={Platform.OS === 'ios' ? 'padding' : internalAndroidKeyboardAvoidingViewBehavior}
style={styles.keyboardAvoidingContainer}
keyboardVerticalOffset={-100} // This is the distance between the top of the user screen and the react native view - because we have put the avoiding view after the navigation
>
Expand Down
1 change: 1 addition & 0 deletions mobile/src/screens/AccountData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const AccountData = ({ navigation }: any) => {
loading: isUpdatingProfile,
}}
headerStyle={{ paddingTop }}
androidKeyboardAvoidingViewBehavior="explicitUndefined"
>
<FormLayout>
<View style={styles.container}>
Expand Down
1 change: 1 addition & 0 deletions mobile/src/screens/IdentityData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ const IdentityData = ({ navigation, route }: any) => {
loading: isUpdateingPersonalData,
}}
headerStyle={{ paddingTop }}
androidKeyboardAvoidingViewBehavior="explicitUndefined"
>
<FormLayout ref={scrollViewRef}>
<Paragraph>{`${t('description')}`}</Paragraph>
Expand Down
20 changes: 15 additions & 5 deletions mobile/src/screens/RejectContract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -181,7 +191,7 @@ export const RejectContract = ({ navigation, route }: any) => {
/>
)}
<InlineLink
label={t('reject.sheet.close')}
label={t('reject.sheet.back_to_contracts')}
style={{ color: theme['cool-gray-700'] }}
onPress={() => {
onCloseBottomSheet();
Expand Down

0 comments on commit afaa2d2

Please sign in to comment.