Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3db9586
refactor: remove navigation, fix props passing, remove unused functio…
ArekChr Jun 22, 2023
1fab207
refactor: move CalendarPicker components to NewDatePicker dir
ArekChr Jun 22, 2023
cc26bc1
refactor: move ScreenSlideAnimation to separated file
ArekChr Jun 22, 2023
9bd8759
refactor: move ScreenSlideAnimation to separated file
ArekChr Jun 22, 2023
dc1c96c
refactor: YearPickerPage constructor
ArekChr Jun 22, 2023
c65f5a1
fix: withlocalizeprops import
ArekChr Jun 22, 2023
a6a69de
refactor: remove old functionalities
ArekChr Jun 27, 2023
be2e0d0
fix: window animation jumping bug
ArekChr Jun 28, 2023
8abedfd
refactor: undo imports order
ArekChr Jun 28, 2023
0481fe3
refactor: mv default props to calendar picker
ArekChr Jun 28, 2023
ad29d05
fix: eslint-disable-next-line in useImperativeHandle and useEffect
ArekChr Jun 28, 2023
ab4ca50
refactor: remove Select Year from navigator
ArekChr Jun 28, 2023
ede1cdb
cr
ArekChr Jun 28, 2023
4057bca
fix: cr
ArekChr Jun 29, 2023
762cb47
fix: cr
ArekChr Jun 29, 2023
58ce600
fix: typo
ArekChr Jun 29, 2023
12088f7
chore: replace ScreenSlideAnimation for Modal
thiagobrez Jul 6, 2023
1b4731f
chore: fix conflicts
thiagobrez Jul 7, 2023
55f930d
chore: address YearPickerModal performance
thiagobrez Jul 7, 2023
cd3a520
chore: fix YearPickerModal propTypes
thiagobrez Jul 7, 2023
a050f8e
chore: fix tests
thiagobrez Jul 7, 2023
a457069
chore: move filtering to YearPickerModal
thiagobrez Jul 10, 2023
b85195e
test: fix unit tests
thiagobrez Jul 10, 2023
0a1fad4
chore: prevent searching for non-num chars
thiagobrez Jul 10, 2023
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
2 changes: 0 additions & 2 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ export default {
getReportShareCodeRoute: (reportID) => `r/${reportID}/details/shareCode`,
REPORT_ATTACHMENTS: 'r/:reportID/attachment',
getReportAttachmentRoute: (reportID, source) => `r/${reportID}/attachment?source=${encodeURI(source)}`,
SELECT_YEAR: 'select-year',
getYearSelectionRoute: (minYear, maxYear, currYear, backTo) => `select-year?min=${minYear}&max=${maxYear}&year=${currYear}&backTo=${backTo}`,

/** This is a utility route used to go to the user's concierge chat, or the sign-in page if the user's not authenticated */
CONCIERGE: 'concierge',
Expand Down
42 changes: 0 additions & 42 deletions src/components/CalendarPicker/calendarPickerPropTypes.js

This file was deleted.

9 changes: 9 additions & 0 deletions src/components/Modal/modalPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ const propTypes = {
/** Whether the modal should avoid the keyboard */
avoidKeyboard: PropTypes.bool,

/**
* Whether the modal should hide its content while animating. On iOS, set to true
* if `useNativeDriver` is also true, to avoid flashes in the UI.
*
* See: https://github.com/react-native-modal/react-native-modal/pull/116
* */
hideModalContentWhileAnimating: PropTypes.bool,

...windowDimensionsPropTypes,
};

Expand All @@ -75,6 +83,7 @@ const defaultProps = {
innerContainerStyle: {},
statusBarTranslucent: true,
avoidKeyboard: false,
hideModalContentWhileAnimating: false,
};

export {propTypes, defaultProps};
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../../styles/styles';
import * as Expensicons from '../Icon/Expensicons';
import * as StyleUtils from '../../styles/StyleUtils';
import Icon from '../Icon';
import CONST from '../../CONST';
import styles from '../../../styles/styles';
import * as Expensicons from '../../Icon/Expensicons';
import * as StyleUtils from '../../../styles/StyleUtils';
import Icon from '../../Icon';
import CONST from '../../../CONST';

const propTypes = {
/** Specifies if the arrow icon should be disabled or not. */
Expand Down
85 changes: 85 additions & 0 deletions src/components/NewDatePicker/CalendarPicker/YearPickerModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React, {useEffect, useMemo, useState} from 'react';
import PropTypes from 'prop-types';
import _ from 'underscore';
import HeaderWithBackButton from '../../HeaderWithBackButton';
import CONST from '../../../CONST';
import SelectionListRadio from '../../SelectionListRadio';
import Modal from '../../Modal';
import {radioListItemPropTypes} from '../../SelectionListRadio/selectionListRadioPropTypes';
import useLocalize from '../../../hooks/useLocalize';

const propTypes = {
/** Whether the modal is visible */
isVisible: PropTypes.bool.isRequired,

/** The list of years to render */
years: PropTypes.arrayOf(PropTypes.shape(radioListItemPropTypes)).isRequired,

/** Currently selected year */
currentYear: PropTypes.number,

/** Function to call when the user selects a year */
onYearChange: PropTypes.func,

/** Function to call when the user closes the year picker */
onClose: PropTypes.func,
};

const defaultProps = {
currentYear: new Date().getFullYear(),
onYearChange: () => {},
onClose: () => {},
};

function YearPickerModal(props) {
const {translate} = useLocalize();
const [searchText, setSearchText] = useState('');
const {sections, headerMessage} = useMemo(() => {
const yearsList = searchText === '' ? props.years : _.filter(props.years, (year) => year.text.includes(searchText));
return {
headerMessage: !yearsList.length ? translate('common.noResultsFound') : '',
sections: [{data: yearsList, indexOffset: 0}],
};
}, [props.years, searchText, translate]);

useEffect(() => {
if (props.isVisible) {
return;
}
setSearchText('');
}, [props.isVisible]);

return (
<Modal
type={CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED}
isVisible={props.isVisible}
onClose={props.onClose}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should include shouldHandleNavigationBack props to handle physical back button on mWeb. More details in:
#52383 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hungvu193 shouldHandleNavigationBack was not present when this PR was implemented. It was added in #38693.

onModalHide={props.onClose}
hideModalContentWhileAnimating
Comment thread
mountiny marked this conversation as resolved.
useNativeDriver
>
<HeaderWithBackButton
title={translate('yearPickerPage.year')}
onBackButtonPress={props.onClose}
/>
<SelectionListRadio
shouldDelayFocus
textInputLabel={translate('yearPickerPage.selectYear')}
textInputValue={searchText}
textInputMaxLength={4}
onChangeText={(text) => setSearchText(text.replace(CONST.REGEX.NON_NUMERIC, '').trim())}
keyboardType={CONST.KEYBOARD_TYPE.NUMBER_PAD}
headerMessage={headerMessage}
sections={sections}
onSelectRow={(option) => props.onYearChange(option.value)}
initiallyFocusedOptionKey={props.currentYear.toString()}
/>
</Modal>
);
}

YearPickerModal.propTypes = propTypes;
YearPickerModal.defaultProps = defaultProps;
YearPickerModal.displayName = 'YearPickerModal';

export default YearPickerModal;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment';
import CONST from '../../CONST';
import CONST from '../../../CONST';

/**
* Generates a matrix representation of a month's calendar given the year and month.
Expand Down
Loading