Skip to content

Commit

Permalink
Merge branch 'main' into ts/ScreenWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Jan 3, 2024
2 parents cd7c599 + 4a86066 commit 1a20d7f
Show file tree
Hide file tree
Showing 45 changed files with 663 additions and 504 deletions.
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ const CONST = {
CLOSED: 'CLOSED',
CREATED: 'CREATED',
IOU: 'IOU',
MARKEDREIMBURSED: 'MARKEDREIMBURSED',
MODIFIEDEXPENSE: 'MODIFIEDEXPENSE',
MOVED: 'MOVED',
REIMBURSEMENTQUEUED: 'REIMBURSEMENTQUEUED',
Expand Down
1 change: 1 addition & 0 deletions src/NAVIGATORS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* */
export default {
CENTRAL_PANE_NAVIGATOR: 'CentralPaneNavigator',
LEFT_MODAL_NAVIGATOR: 'LeftModalNavigator',
RIGHT_MODAL_NAVIGATOR: 'RightModalNavigator',
FULL_SCREEN_NAVIGATOR: 'FullScreenNavigator',
} as const;
4 changes: 3 additions & 1 deletion src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ const SCREENS = {
SAVE_THE_WORLD: {
ROOT: 'SaveTheWorld_Root',
},
LEFT_MODAL: {
SEARCH: 'Search',
},
RIGHT_MODAL: {
SETTINGS: 'Settings',
NEW_CHAT: 'NewChat',
SEARCH: 'Search',
DETAILS: 'Details',
PROFILE: 'Profile',
REPORT_DETAILS: 'Report_Details',
Expand Down
2 changes: 1 addition & 1 deletion src/components/AttachmentModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ function AttachmentModal(props) {
setIsAuthTokenRequired(props.isAuthTokenRequired);
}, [props.isAuthTokenRequired]);

const sourceForAttachmentView = props.source || source;
const sourceForAttachmentView = source || props.source;

const threeDotsMenuItems = useMemo(() => {
if (!props.isReceiptAttachment || !props.parentReport || !props.parentReportActions) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function Button(
<View style={[styles.mr1, iconStyles]}>
<Icon
src={icon}
fill={iconFill ?? theme.textLight}
fill={iconFill ?? (success || danger ? theme.textLight : theme.icon)}
small={small}
/>
</View>
Expand All @@ -232,7 +232,7 @@ function Button(
<View style={[styles.justifyContentCenter, styles.ml1, iconRightStyles]}>
<Icon
src={iconRight}
fill={iconFill ?? theme.textLight}
fill={iconFill ?? (success || danger ? theme.textLight : theme.icon)}
small={small}
/>
</View>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React from 'react';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
Expand All @@ -7,15 +6,15 @@ import PressableWithoutFeedback from './Pressable/PressableWithoutFeedback';
import Text from './Text';
import Tooltip from './Tooltip';

const propTypes = {
type CurrencySymbolButtonProps = {
/** Currency symbol of selected currency */
currencySymbol: PropTypes.string.isRequired,
currencySymbol: string;

/** Function to call when currency button is pressed */
onCurrencyButtonPress: PropTypes.func.isRequired,
onCurrencyButtonPress: () => void;
};

function CurrencySymbolButton({onCurrencyButtonPress, currencySymbol}) {
function CurrencySymbolButton({onCurrencyButtonPress, currencySymbol}: CurrencySymbolButtonProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
return (
Expand All @@ -31,7 +30,6 @@ function CurrencySymbolButton({onCurrencyButtonPress, currencySymbol}) {
);
}

CurrencySymbolButton.propTypes = propTypes;
CurrencySymbolButton.displayName = 'CurrencySymbolButton';

export default CurrencySymbolButton;
6 changes: 3 additions & 3 deletions src/components/DotIndicatorMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ function DotIndicatorMessage({messages = {}, style, type, textStyles}: DotIndica
key={i}
style={styles.offlineFeedback.text}
>
<Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{Localize.translateLocal('iou.error.receiptFailureMessage')}</Text>
<Text style={[styles.optionAlternateText, styles.textLabelSupporting, styles.link]}>{Localize.translateLocal('iou.error.saveFileMessage')}</Text>
<Text style={[styles.optionAlternateText, styles.textLabelSupporting]}>{Localize.translateLocal('iou.error.loseFileMessage')}</Text>
<Text style={[StyleUtils.getDotIndicatorTextStyles(isErrorMessage)]}>{Localize.translateLocal('iou.error.receiptFailureMessage')}</Text>
<Text style={[StyleUtils.getDotIndicatorTextStyles(isErrorMessage), styles.link]}>{Localize.translateLocal('iou.error.saveFileMessage')}</Text>
<Text style={[StyleUtils.getDotIndicatorTextStyles(isErrorMessage)]}>{Localize.translateLocal('iou.error.loseFileMessage')}</Text>
</Text>
</PressableWithoutFeedback>
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import Icon from '@components/Icon';
Expand All @@ -7,29 +6,25 @@ import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeed
import Text from '@components/Text';
import TextLink from '@components/TextLink';
import Tooltip from '@components/Tooltip';
import withLocalize, {withLocalizePropTypes} from '@components/withLocalize';
import useLocalize from '@hooks/useLocalize';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import colors from '@styles/theme/colors';
import CONST from '@src/CONST';
import * as locationErrorMessagePropTypes from './locationErrorMessagePropTypes';
import LocationErrorMessageProps from './types';

const propTypes = {
type BaseLocationErrorMessageProps = LocationErrorMessageProps & {
/** A callback that runs when 'allow location permission' link is pressed */
onAllowLocationLinkPress: PropTypes.func.isRequired,

// eslint-disable-next-line react/forbid-foreign-prop-types
...locationErrorMessagePropTypes.propTypes,

/* Onyx Props */
...withLocalizePropTypes,
onAllowLocationLinkPress: () => void;
};

function BaseLocationErrorMessage({onClose, onAllowLocationLinkPress, locationErrorCode, translate}) {
function BaseLocationErrorMessage({onClose, onAllowLocationLinkPress, locationErrorCode}: BaseLocationErrorMessageProps) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();

if (!locationErrorCode) {
return null;
}
Expand Down Expand Up @@ -81,6 +76,5 @@ function BaseLocationErrorMessage({onClose, onAllowLocationLinkPress, locationEr
}

BaseLocationErrorMessage.displayName = 'BaseLocationErrorMessage';
BaseLocationErrorMessage.propTypes = propTypes;
BaseLocationErrorMessage.defaultProps = locationErrorMessagePropTypes.defaultProps;
export default withLocalize(BaseLocationErrorMessage);

export default BaseLocationErrorMessage;
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React from 'react';
import {Linking} from 'react-native';
import BaseLocationErrorMessage from './BaseLocationErrorMessage';
import * as locationErrorMessagePropTypes from './locationErrorMessagePropTypes';
import LocationErrorMessageProps from './types';

/** Opens app level settings from the native system settings */
const openAppSettings = () => {
Linking.openSettings();
};

function LocationErrorMessage(props) {
function LocationErrorMessage(props: LocationErrorMessageProps) {
return (
<BaseLocationErrorMessage
// eslint-disable-next-line react/jsx-props-no-spreading
Expand All @@ -19,6 +19,5 @@ function LocationErrorMessage(props) {
}

LocationErrorMessage.displayName = 'LocationErrorMessage';
LocationErrorMessage.propTypes = locationErrorMessagePropTypes.propTypes;
LocationErrorMessage.defaultProps = locationErrorMessagePropTypes.defaultProps;

export default LocationErrorMessage;
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React from 'react';
import {Linking} from 'react-native';
import CONST from '@src/CONST';
import BaseLocationErrorMessage from './BaseLocationErrorMessage';
import * as locationErrorMessagePropTypes from './locationErrorMessagePropTypes';
import LocationErrorMessageProps from './types';

/** Opens expensify help site in a new browser tab */
const navigateToExpensifyHelpSite = () => {
Linking.openURL(CONST.NEWHELP_URL);
};

function LocationErrorMessage(props) {
function LocationErrorMessage(props: LocationErrorMessageProps) {
return (
<BaseLocationErrorMessage
// eslint-disable-next-line react/jsx-props-no-spreading
Expand All @@ -20,6 +20,5 @@ function LocationErrorMessage(props) {
}

LocationErrorMessage.displayName = 'LocationErrorMessage';
LocationErrorMessage.propTypes = locationErrorMessagePropTypes.propTypes;
LocationErrorMessage.defaultProps = locationErrorMessagePropTypes.defaultProps;

export default LocationErrorMessage;
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import PropTypes from 'prop-types';

const propTypes = {
type LocationErrorMessageProps = {
/** A callback that runs when close icon is pressed */
onClose: PropTypes.func.isRequired,
onClose: () => void;

/**
* The location error code from onyx
Expand All @@ -11,11 +9,7 @@ const propTypes = {
* - code 2 = location is unavailable or there is some connection issue
* - code 3 = location fetch timeout
*/
locationErrorCode: PropTypes.oneOf([-1, 1, 2, 3]),
};

const defaultProps = {
locationErrorCode: null,
locationErrorCode?: -1 | 1 | 2 | 3;
};

export {propTypes, defaultProps};
export default LocationErrorMessageProps;
12 changes: 6 additions & 6 deletions src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ type UnresponsiveProps = {

type IconProps = {
/** Flag to choose between avatar image or an icon */
iconType: typeof CONST.ICON_TYPE_ICON;
iconType?: typeof CONST.ICON_TYPE_ICON;

/** Icon to display on the left side of component */
icon: IconAsset;
};

type AvatarProps = {
iconType: typeof CONST.ICON_TYPE_AVATAR | typeof CONST.ICON_TYPE_WORKSPACE;
iconType?: typeof CONST.ICON_TYPE_AVATAR | typeof CONST.ICON_TYPE_WORKSPACE;

icon: AvatarSource;
};
Expand Down Expand Up @@ -85,7 +85,7 @@ type MenuItemProps = (ResponsiveProps | UnresponsiveProps) &
titleStyle?: ViewStyle;

/** Any adjustments to style when menu item is hovered or pressed */
hoverAndPressStyle: StyleProp<AnimatedStyle<ViewStyle>>;
hoverAndPressStyle?: StyleProp<AnimatedStyle<ViewStyle>>;

/** Additional styles to style the description text below the title */
descriptionTextStyle?: StyleProp<TextStyle>;
Expand Down Expand Up @@ -175,7 +175,7 @@ type MenuItemProps = (ResponsiveProps | UnresponsiveProps) &
isSelected?: boolean;

/** Prop to identify if we should load avatars vertically instead of diagonally */
shouldStackHorizontally: boolean;
shouldStackHorizontally?: boolean;

/** Prop to represent the size of the avatar images to be shown */
avatarSize?: (typeof CONST.AVATAR_SIZE)[keyof typeof CONST.AVATAR_SIZE];
Expand Down Expand Up @@ -220,10 +220,10 @@ type MenuItemProps = (ResponsiveProps | UnresponsiveProps) &
furtherDetails?: string;

/** The function that should be called when this component is LongPressed or right-clicked. */
onSecondaryInteraction: () => void;
onSecondaryInteraction?: () => void;

/** Array of objects that map display names to their corresponding tooltip */
titleWithTooltips: DisplayNameWithTooltip[];
titleWithTooltips?: DisplayNameWithTooltip[];

/** Icon should be displayed in its own color */
displayInDefaultIconColor?: boolean;
Expand Down
3 changes: 3 additions & 0 deletions src/components/Popover/popoverPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ const propTypes = {

/** The ref of the popover */
withoutOverlayRef: refPropTypes,

/** Whether we want to show the popover on the right side of the screen */
fromSidebarMediumScreen: PropTypes.bool,
};

const defaultProps = {
Expand Down
12 changes: 10 additions & 2 deletions src/components/Popover/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import type {ValueOf} from 'type-fest';
import BaseModalProps, {PopoverAnchorPosition} from '@components/Modal/types';
import {WindowDimensionsProps} from '@components/withWindowDimensions/types';
import CONST from '@src/CONST';

type AnchorAlignment = {horizontal: string; vertical: string};
type AnchorAlignment = {
/** The horizontal anchor alignment of the popover */
horizontal: ValueOf<typeof CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL>;

/** The vertical anchor alignment of the popover */
vertical: ValueOf<typeof CONST.MODAL.ANCHOR_ORIGIN_VERTICAL>;
};

type PopoverDimensions = {
width: number;
Expand Down Expand Up @@ -39,4 +47,4 @@ type PopoverProps = BaseModalProps & {

type PopoverWithWindowDimensionsProps = PopoverProps & WindowDimensionsProps;

export type {PopoverProps, PopoverWithWindowDimensionsProps};
export type {PopoverProps, PopoverWithWindowDimensionsProps, AnchorAlignment};
Loading

0 comments on commit 1a20d7f

Please sign in to comment.