Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Big number pad button size is not justified on small screens #25656

3 changes: 3 additions & 0 deletions src/components/BigNumberPad.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styles from '../styles/styles';
import Button from './Button';
import ControlSelection from '../libs/ControlSelection';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import useWindowDimensions from '../hooks/useWindowDimensions';

const propTypes = {
/** Callback to inform parent modal with key pressed */
Expand Down Expand Up @@ -34,6 +35,7 @@ const padNumbers = [

function BigNumberPad(props) {
const [timer, setTimer] = useState(null);
const {isExtraSmallScreenHeight} = useWindowDimensions();

/**
* Handle long press key on number pad.
Expand Down Expand Up @@ -71,6 +73,7 @@ function BigNumberPad(props) {
return (
<Button
key={column}
medium={isExtraSmallScreenHeight}
shouldEnableHapticFeedback
style={[styles.flex1, marginLeft]}
text={column === '<' ? column : props.toLocaleDigit(column)}
Expand Down
2 changes: 2 additions & 0 deletions src/hooks/useWindowDimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import variables from '../styles/variables';
*/
export default function () {
const {width: windowWidth, height: windowHeight} = useWindowDimensions();
const isExtraSmallScreenHeight = windowHeight <= variables.extraSmallMobileResponsiveHeightBreakpoint;
const isSmallScreenWidth = windowWidth <= variables.mobileResponsiveWidthBreakpoint;
const isMediumScreenWidth = windowWidth > variables.mobileResponsiveWidthBreakpoint && windowWidth <= variables.tabletResponsiveWidthBreakpoint;
const isLargeScreenWidth = windowWidth > variables.tabletResponsiveWidthBreakpoint;
return {
windowWidth,
windowHeight,
isExtraSmallScreenHeight,
isSmallScreenWidth,
isMediumScreenWidth,
isLargeScreenWidth,
Expand Down
3 changes: 3 additions & 0 deletions src/pages/iou/steps/MoneyRequestAmountForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import TextInputWithCurrencySymbol from '../../../components/TextInputWithCurren
import useLocalize from '../../../hooks/useLocalize';
import CONST from '../../../CONST';
import refPropTypes from '../../../components/refPropTypes';
import useWindowDimensions from '../../../hooks/useWindowDimensions';

const propTypes = {
/** IOU amount saved in Onyx */
Expand Down Expand Up @@ -59,6 +60,7 @@ const NUM_PAD_CONTAINER_VIEW_ID = 'numPadContainerView';
const NUM_PAD_VIEW_ID = 'numPadView';

function MoneyRequestAmountForm({amount, currency, isEditing, forwardedRef, onCurrencyButtonPress, onSubmitButtonPress}) {
const {isExtraSmallScreenHeight} = useWindowDimensions();
const {translate, toLocaleDigit, numberFormat} = useLocalize();

const textInput = useRef(null);
Expand Down Expand Up @@ -221,6 +223,7 @@ function MoneyRequestAmountForm({amount, currency, isEditing, forwardedRef, onCu
) : null}
<Button
success
medium={isExtraSmallScreenHeight}
style={[styles.w100, styles.mt5]}
onPress={submitAndNavigateToNextPage}
pressOnEnter
Expand Down
1 change: 1 addition & 0 deletions src/styles/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default {
emojiLineHeight: 28,
iouAmountTextSize: 40,
extraSmallMobileResponsiveWidthBreakpoint: 320,
extraSmallMobileResponsiveHeightBreakpoint: 550,
mobileResponsiveWidthBreakpoint: 800,
modalFullscreenBackdropOpacity: 0.5,
tabletResponsiveWidthBreakpoint: 1024,
Expand Down
Loading