Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 21 additions & 10 deletions src/components/CalendarPicker/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'underscore';
import React from 'react';
import {View, TouchableOpacity, Pressable} from 'react-native';
import {View} from 'react-native';
import moment from 'moment';
import Str from 'expensify-common/lib/str';
import Text from '../Text';
Expand All @@ -14,6 +14,8 @@ import ROUTES from '../../ROUTES';
import CONST from '../../CONST';
import getButtonState from '../../libs/getButtonState';
import * as StyleUtils from '../../styles/StyleUtils';
import PressableWithFeedback from '../Pressable/PressableWithFeedback';
import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback';

class CalendarPicker extends React.PureComponent {
constructor(props) {
Expand Down Expand Up @@ -101,9 +103,12 @@ class CalendarPicker extends React.PureComponent {
return (
<View>
<View style={[styles.calendarHeader, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ph4, styles.pr1]}>
<TouchableOpacity
<PressableWithFeedback
onPress={this.onYearPickerPressed}
style={[styles.alignItemsCenter, styles.flexRow, styles.flex1, styles.justifyContentStart]}
wrapperStyle={[styles.alignItemsCenter]}
hoverDimmingValue={1}
accessibilityLabel={this.props.translate('common.currentYear')}
>
<Text
style={styles.sidebarLinkTextBold}
Expand All @@ -113,7 +118,7 @@ class CalendarPicker extends React.PureComponent {
{currentYearView}
</Text>
<ArrowIcon />
</TouchableOpacity>
</PressableWithFeedback>
<View style={[styles.alignItemsCenter, styles.flexRow, styles.flex1, styles.justifyContentEnd]}>
<Text
style={styles.sidebarLinkTextBold}
Expand All @@ -122,23 +127,27 @@ class CalendarPicker extends React.PureComponent {
>
{monthNames[currentMonthView]}
</Text>
<TouchableOpacity
<PressableWithFeedback
testID="prev-month-arrow"
disabled={!hasAvailableDatesPrevMonth}
onPress={this.moveToPrevMonth}
hoverDimmingValue={1}
accessibilityLabel={this.props.translate('common.previous')}
>
<ArrowIcon
disabled={!hasAvailableDatesPrevMonth}
direction={CONST.DIRECTION.LEFT}
/>
</TouchableOpacity>
<TouchableOpacity
</PressableWithFeedback>
<PressableWithFeedback
testID="next-month-arrow"
disabled={!hasAvailableDatesNextMonth}
onPress={this.moveToNextMonth}
hoverDimmingValue={1}
accessibilityLabel={this.props.translate('common.next')}
>
<ArrowIcon disabled={!hasAvailableDatesNextMonth} />
</TouchableOpacity>
</PressableWithFeedback>
</View>
</View>
<View style={styles.flexRow}>
Expand All @@ -164,25 +173,27 @@ class CalendarPicker extends React.PureComponent {
const isSelected = moment(this.props.value).isSame(moment([currentYearView, currentMonthView, day]), 'day');

return (
<Pressable
<PressableWithoutFeedback
key={`${index}_day-${day}`}
disabled={isDisabled}
onPress={() => this.onDayPressed(day)}
style={styles.calendarDayRoot}
accessibilityLabel={day ? day.toString() : undefined}
focusable={Boolean(day)}
accessible={Boolean(day)}
>
{({hovered, pressed}) => (
<View
style={[
styles.calendarDayContainer,
isSelected ? styles.calendarDayContainerSelected : {},
StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed)),
!isDisabled ? StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed)) : {},
]}
>
<Text style={isDisabled ? styles.buttonOpacityDisabled : styles.dayText}>{day}</Text>
</View>
)}
</Pressable>
</PressableWithoutFeedback>
);
})}
</View>
Expand Down
10 changes: 10 additions & 0 deletions src/components/Pressable/PressableWithFeedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ const omittedProps = ['style', 'pressStyle', 'hoverStyle', 'focusStyle', 'wrappe

const PressableWithFeedbackPropTypes = {
..._.omit(GenericPressablePropTypes.pressablePropTypes, omittedProps),
/**
* Determines what opacity value should be applied to the underlaying view when Pressable is pressed.
* To disable dimming, pass 1 as pressDimmingValue
* @default variables.pressDimValue
*/
pressDimmingValue: propTypes.number,
/**
* Determines what opacity value should be applied to the underlaying view when pressable is hovered.
* To disable dimming, pass 1 as hoverDimmingValue
* @default variables.hoverDimValue
*/
hoverDimmingValue: propTypes.number,
};

Expand Down