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
4 changes: 3 additions & 1 deletion src/components/AmountTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type AmountTextInputProps = {

/** Hide the focus styles on TextInput */
hideFocusedState?: boolean;
} & Pick<BaseTextInputProps, 'autoFocus' | 'autoGrowExtraSpace' | 'submitBehavior' | 'ref' | 'onFocus' | 'onBlur'>;
} & Pick<BaseTextInputProps, 'autoFocus' | 'autoGrowExtraSpace' | 'submitBehavior' | 'ref' | 'onFocus' | 'onBlur' | 'disabled'>;

function AmountTextInput({
formattedAmount,
Expand All @@ -57,6 +57,7 @@ function AmountTextInput({
hideFocusedState = true,
shouldApplyPaddingToContainer = false,
ref,
disabled,
...rest
}: AmountTextInputProps) {
return (
Expand All @@ -69,6 +70,7 @@ function AmountTextInput({
textInputContainerStyles={containerStyle}
onChangeText={onChangeAmount}
ref={ref}
disabled={disabled}
value={formattedAmount}
placeholder={placeholder}
inputMode={CONST.INPUT_MODE.DECIMAL}
Expand Down
5 changes: 5 additions & 0 deletions src/components/MoneyRequestAmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ type MoneyRequestAmountInputProps = {
*/
shouldWrapInputInContainer?: boolean;

/** Whether the input is disabled or not */
disabled?: boolean;

/** Reference to the outer element */
ref?: ForwardedRef<BaseTextInputRef>;
} & Pick<TextInputWithSymbolProps, 'autoGrowExtraSpace' | 'submitBehavior' | 'shouldUseDefaultLineHeightForPrefix' | 'onFocus' | 'onBlur'>;
Expand Down Expand Up @@ -160,6 +163,7 @@ function MoneyRequestAmountInput({
toggleNegative,
clearNegative,
ref,
disabled,
...props
}: MoneyRequestAmountInputProps) {
const textInput = useRef<BaseTextInputRef | null>(null);
Expand Down Expand Up @@ -214,6 +218,7 @@ function MoneyRequestAmountInput({
// eslint-disable-next-line react-compiler/react-compiler
textInput.current = newRef;
}}
disabled={disabled}
numberFormRef={(newRef) => {
if (typeof moneyRequestAmountInputRef === 'function') {
moneyRequestAmountInputRef(newRef);
Expand Down
6 changes: 6 additions & 0 deletions src/components/NumberWithSymbolForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import BigNumberPad from './BigNumberPad';
import Button from './Button';
import FormHelpMessage from './FormHelpMessage';
import * as Expensicons from './Icon/Expensicons';

Check warning on line 28 in src/components/NumberWithSymbolForm.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'./Icon/Expensicons' import is restricted from being used by a pattern. Direct imports from Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details
import ScrollView from './ScrollView';
import TextInput from './TextInput';
import isTextInputFocused from './TextInput/BaseTextInput/isTextInputFocused';
Expand Down Expand Up @@ -79,6 +79,9 @@
/** Whether to allow flipping amount */
allowFlippingAmount?: boolean;

/** Whether the input is disabled or not */
disabled?: boolean;

/** Reference to the outer element */
ref?: ForwardedRef<BaseTextInputRef>;
} & Omit<TextInputWithSymbolProps, 'formattedAmount' | 'onAmountChange' | 'placeholder' | 'onSelectionChange' | 'onKeyPress' | 'onMouseDown' | 'onMouseUp'>;
Expand Down Expand Up @@ -141,6 +144,7 @@
toggleNegative,
clearNegative,
ref,
disabled,
...props
}: NumberWithSymbolFormProps) {
const styles = useThemeStyles();
Expand Down Expand Up @@ -369,6 +373,7 @@
ref.current = newRef;
}
}}
disabled={disabled}
prefixCharacter={symbol}
prefixStyle={styles.colorMuted}
keyboardType={CONST.KEYBOARD_TYPE.DECIMAL_PAD}
Expand Down Expand Up @@ -400,6 +405,7 @@
}
textInput.current = newRef;
}}
disabled={disabled}
symbol={symbol}
hideSymbol={hideSymbol}
symbolPosition={symbolPosition}
Expand Down
79 changes: 28 additions & 51 deletions src/components/SelectionListWithSections/SplitListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback, useLayoutEffect, useRef, useState} from 'react';
import React, {useCallback, useLayoutEffect, useRef} from 'react';
import {View} from 'react-native';
import Icon from '@components/Icon';
// eslint-disable-next-line no-restricted-imports
Expand Down Expand Up @@ -59,8 +59,6 @@ function SplitListItem<TItem extends ListItem>({

const isBottomVisible = !!splitItem.category || !!splitItem.tags?.at(0);

const [prefixCharacterMargin, setPrefixCharacterMargin] = useState<number>(CONST.CHARACTER_WIDTH);
const inputMarginLeft = prefixCharacterMargin + styles.pl1.paddingLeft;
const contentWidth = (formattedOriginalAmount.length + 1) * CONST.CHARACTER_WIDTH;
const focusHandler = useCallback(() => {
if (!onInputFocus) {
Expand Down Expand Up @@ -166,54 +164,33 @@ function SplitListItem<TItem extends ListItem>({
</View>
<View style={[styles.flexRow]}>
<View style={[styles.justifyContentCenter]}>
{!splitItem.isEditable ? (
<View style={styles.cannotBeEditedSplitInputContainer}>
<Text
style={[styles.optionRowAmountInput, styles.pAbsolute]}
onLayout={(event) => {
if (event.nativeEvent.layout.width === 0 && event.nativeEvent.layout.height === 0) {
return;
}
setPrefixCharacterMargin(event?.nativeEvent?.layout.width);
}}
>
{splitItem.currencySymbol}
</Text>
<Text
style={[styles.optionRowAmountInput, styles.pl3, styles.getSplitListItemAmountStyle(inputMarginLeft, contentWidth)]}
numberOfLines={1}
>
{convertToDisplayStringWithoutCurrency(splitItem.amount, splitItem.currency)}
</Text>
</View>
) : (
<MoneyRequestAmountInput
ref={inputCallbackRef}
autoGrow={false}
amount={splitItem.amount}
currency={splitItem.currency}
prefixCharacter={splitItem.currencySymbol}
disableKeyboard={false}
isCurrencyPressable={false}
hideFocusedState={false}
hideCurrencySymbol
submitBehavior="blurAndSubmit"
formatAmountOnBlur
onAmountChange={onSplitExpenseAmountChange}
prefixContainerStyle={[styles.pv0, styles.h100]}
prefixStyle={styles.lineHeightUndefined}
inputStyle={[styles.optionRowAmountInput, styles.lineHeightUndefined]}
containerStyle={[styles.textInputContainer, styles.pl2, styles.pr1]}
touchableInputWrapperStyle={[styles.ml3]}
maxLength={formattedOriginalAmount.length + 1}
contentWidth={contentWidth}
shouldApplyPaddingToContainer
shouldUseDefaultLineHeightForPrefix={false}
shouldWrapInputInContainer={false}
onFocus={focusHandler}
onBlur={onInputBlur}
/>
)}
<MoneyRequestAmountInput
ref={inputCallbackRef}
disabled={!splitItem.isEditable}
autoGrow={false}
amount={splitItem.amount}
currency={splitItem.currency}
prefixCharacter={splitItem.currencySymbol}
disableKeyboard={false}
isCurrencyPressable={false}
hideFocusedState={false}
hideCurrencySymbol
submitBehavior="blurAndSubmit"
formatAmountOnBlur
onAmountChange={onSplitExpenseAmountChange}
prefixContainerStyle={[styles.pv0, styles.h100]}
prefixStyle={styles.lineHeightUndefined}
inputStyle={[styles.optionRowAmountInput, styles.lineHeightUndefined]}
containerStyle={[styles.textInputContainer, styles.pl2, styles.pr1]}
touchableInputWrapperStyle={[styles.ml3]}
maxLength={formattedOriginalAmount.length + 1}
contentWidth={contentWidth}
shouldApplyPaddingToContainer
shouldUseDefaultLineHeightForPrefix={false}
shouldWrapInputInContainer={false}
onFocus={focusHandler}
onBlur={onInputBlur}
/>
</View>
<View style={[styles.popoverMenuIcon]}>
{!splitItem.isEditable ? null : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Checkbox from '@components/Checkbox';
import FormHelpMessage from '@components/FormHelpMessage';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';

Check warning on line 11 in src/components/TextInput/BaseTextInput/implementation/index.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used by a pattern. Direct imports from Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details

Check warning on line 11 in src/components/TextInput/BaseTextInput/implementation/index.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

'@components/Icon/Expensicons' import is restricted from being used. Direct imports from @components/Icon/Expensicons are deprecated. Please use lazy loading hooks instead. Use `useMemoizedLazyExpensifyIcons` from @hooks/useLazyAsset. See docs/LAZY_ICONS_AND_ILLUSTRATIONS.md for details
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
import type {AnimatedMarkdownTextInputRef} from '@components/RNMarkdownTextInput';
import type {AnimatedTextInputRef} from '@components/RNTextInput';
Expand Down Expand Up @@ -373,7 +373,13 @@
setIsPrefixCharacterPaddingCalculated(true);
}}
tabIndex={-1}
style={[styles.textInputPrefix, !hasLabel && styles.pv0, styles.pointerEventsNone, prefixStyle]}
style={[
styles.textInputPrefix,
!hasLabel && styles.pv0,
styles.pointerEventsNone,
inputProps.disabled && shouldUseDisabledStyles && styles.textSupporting,
prefixStyle,
]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
shouldUseDefaultLineHeight={shouldUseDefaultLineHeightForPrefix}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function BaseTextInputWithSymbol({
symbolTextStyle,
isNegative = false,
ref,
disabled,
...rest
}: BaseTextInputWithSymbolProps) {
const {fromLocaleDigit} = useLocalize();
Expand Down Expand Up @@ -58,6 +59,7 @@ function BaseTextInputWithSymbol({
onChangeAmount={setFormattedAmount}
placeholder={placeholder}
ref={ref}
disabled={disabled}
selection={selection}
onSelectionChange={(event: TextInputSelectionChangeEvent) => {
onSelectionChange(event);
Expand Down
1 change: 1 addition & 0 deletions src/components/TextInputWithSymbol/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type BaseTextInputWithSymbolProps = {
| 'shouldUseDefaultLineHeightForPrefix'
| 'onFocus'
| 'onBlur'
| 'disabled'
| 'ref'
>;

Expand Down
Loading