[FIX] Screen Lock's Password screen UI is broken on tablets (#4583)
* [FIX] Screen Lock's Password screen UI is broken on tablets * minor tweak and added comment * minor tweak * minor tweak * minor tweak
This commit is contained in:
parent
525f84885a
commit
761aef2c04
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text } from 'react-native';
|
import { Text, StyleProp, ViewStyle } from 'react-native';
|
||||||
|
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import { themes } from '../../../lib/constants';
|
import { themes } from '../../../lib/constants';
|
||||||
|
@ -12,16 +12,17 @@ interface IPasscodeButton {
|
||||||
icon?: TIconsName;
|
icon?: TIconsName;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
onPress?: Function;
|
onPress?: Function;
|
||||||
|
style?: StyleProp<ViewStyle>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Button = React.memo(({ text, disabled, onPress, icon }: IPasscodeButton) => {
|
const Button = React.memo(({ style, text, disabled, onPress, icon }: IPasscodeButton) => {
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
|
||||||
const press = () => onPress && onPress(text);
|
const press = () => onPress && onPress(text);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Touch
|
<Touch
|
||||||
style={[styles.buttonView, { backgroundColor: 'transparent' }]}
|
style={[styles.buttonView, { backgroundColor: 'transparent' }, style]}
|
||||||
underlayColor={themes[theme].passcodeButtonActive}
|
underlayColor={themes[theme].passcodeButtonActive}
|
||||||
rippleColor={themes[theme].passcodeButtonActive}
|
rippleColor={themes[theme].passcodeButtonActive}
|
||||||
enabled={!disabled}
|
enabled={!disabled}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
import React, { forwardRef, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
|
||||||
import { Col, Grid, Row } from 'react-native-easy-grid';
|
import { Col, Grid, Row } from 'react-native-easy-grid';
|
||||||
import range from 'lodash/range';
|
import range from 'lodash/range';
|
||||||
import { View } from 'react-native';
|
import { View } from 'react-native';
|
||||||
import * as Animatable from 'react-native-animatable';
|
import * as Animatable from 'react-native-animatable';
|
||||||
import * as Haptics from 'expo-haptics';
|
import * as Haptics from 'expo-haptics';
|
||||||
|
import Orientation from 'react-native-orientation-locker';
|
||||||
|
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import Button from './Button';
|
import Button from './Button';
|
||||||
|
@ -14,6 +15,8 @@ import { useTheme } from '../../../theme';
|
||||||
import LockIcon from './LockIcon';
|
import LockIcon from './LockIcon';
|
||||||
import Title from './Title';
|
import Title from './Title';
|
||||||
import Subtitle from './Subtitle';
|
import Subtitle from './Subtitle';
|
||||||
|
import { useDimensions } from '../../../dimensions';
|
||||||
|
import { isTablet } from '../../../lib/methods/helpers';
|
||||||
|
|
||||||
interface IPasscodeBase {
|
interface IPasscodeBase {
|
||||||
type: string;
|
type: string;
|
||||||
|
@ -34,7 +37,25 @@ export interface IBase {
|
||||||
|
|
||||||
const Base = forwardRef<IBase, IPasscodeBase>(
|
const Base = forwardRef<IBase, IPasscodeBase>(
|
||||||
({ type, onEndProcess, previousPasscode, title, subtitle, onError, showBiometry, onBiometryPress }, ref) => {
|
({ type, onEndProcess, previousPasscode, title, subtitle, onError, showBiometry, onBiometryPress }, ref) => {
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
if (!isTablet) {
|
||||||
|
Orientation.lockToPortrait();
|
||||||
|
}
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (!isTablet) {
|
||||||
|
Orientation.unlockAllOrientations();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const { theme } = useTheme();
|
const { theme } = useTheme();
|
||||||
|
const { height } = useDimensions();
|
||||||
|
|
||||||
|
// 206 is the height of the header calculating the margins, icon size height, title font size and subtitle height.
|
||||||
|
// 56 is a fixed number to decrease the height of button numbers.
|
||||||
|
const dinamicHeight = (height - 206 - 56) / 4;
|
||||||
|
const heightButtonRow = { height: dinamicHeight > 102 ? 102 : dinamicHeight };
|
||||||
|
|
||||||
const rootRef = useRef<Animatable.View & View>(null);
|
const rootRef = useRef<Animatable.View & View>(null);
|
||||||
const dotsRef = useRef<Animatable.View & View>(null);
|
const dotsRef = useRef<Animatable.View & View>(null);
|
||||||
|
@ -103,40 +124,40 @@ const Base = forwardRef<IBase, IPasscodeBase>(
|
||||||
<Dots passcode={passcode} length={PASSCODE_LENGTH} />
|
<Dots passcode={passcode} length={PASSCODE_LENGTH} />
|
||||||
</Animatable.View>
|
</Animatable.View>
|
||||||
</Row>
|
</Row>
|
||||||
<Row style={[styles.row, styles.buttonRow]}>
|
<Row style={[styles.row, heightButtonRow]}>
|
||||||
{range(1, 4).map(i => (
|
{range(1, 4).map(i => (
|
||||||
<Col key={i} style={styles.colButton}>
|
<Col key={i} style={[styles.colButton, heightButtonRow]}>
|
||||||
<Button text={i.toString()} onPress={onPressNumber} />
|
<Button style={heightButtonRow} text={i.toString()} onPress={onPressNumber} />
|
||||||
</Col>
|
</Col>
|
||||||
))}
|
))}
|
||||||
</Row>
|
</Row>
|
||||||
<Row style={[styles.row, styles.buttonRow]}>
|
<Row style={[styles.row, heightButtonRow]}>
|
||||||
{range(4, 7).map(i => (
|
{range(4, 7).map(i => (
|
||||||
<Col key={i} style={styles.colButton}>
|
<Col key={i} style={[styles.colButton, heightButtonRow]}>
|
||||||
<Button text={i.toString()} onPress={onPressNumber} />
|
<Button style={heightButtonRow} text={i.toString()} onPress={onPressNumber} />
|
||||||
</Col>
|
</Col>
|
||||||
))}
|
))}
|
||||||
</Row>
|
</Row>
|
||||||
<Row style={[styles.row, styles.buttonRow]}>
|
<Row style={[styles.row, heightButtonRow]}>
|
||||||
{range(7, 10).map(i => (
|
{range(7, 10).map(i => (
|
||||||
<Col key={i} style={styles.colButton}>
|
<Col key={i} style={[styles.colButton, heightButtonRow]}>
|
||||||
<Button text={i.toString()} onPress={onPressNumber} />
|
<Button style={heightButtonRow} text={i.toString()} onPress={onPressNumber} />
|
||||||
</Col>
|
</Col>
|
||||||
))}
|
))}
|
||||||
</Row>
|
</Row>
|
||||||
<Row style={[styles.row, styles.buttonRow]}>
|
<Row style={[styles.row, heightButtonRow]}>
|
||||||
{showBiometry ? (
|
{showBiometry ? (
|
||||||
<Col style={styles.colButton}>
|
<Col style={[styles.colButton, heightButtonRow]}>
|
||||||
<Button icon='fingerprint' onPress={onBiometryPress} />
|
<Button style={heightButtonRow} icon='fingerprint' onPress={onBiometryPress} />
|
||||||
</Col>
|
</Col>
|
||||||
) : (
|
) : (
|
||||||
<Col style={styles.colButton} />
|
<Col style={[styles.colButton, heightButtonRow]} />
|
||||||
)}
|
)}
|
||||||
<Col style={styles.colButton}>
|
<Col style={[styles.colButton, heightButtonRow]}>
|
||||||
<Button text='0' onPress={onPressNumber} />
|
<Button style={heightButtonRow} text='0' onPress={onPressNumber} />
|
||||||
</Col>
|
</Col>
|
||||||
<Col style={styles.colButton}>
|
<Col style={[styles.colButton, heightButtonRow]}>
|
||||||
<Button icon='backspace' onPress={onPressDelete} />
|
<Button style={heightButtonRow} icon='backspace' onPress={onPressDelete} />
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
@ -18,16 +18,12 @@ export default StyleSheet.create({
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center'
|
||||||
},
|
},
|
||||||
buttonRow: {
|
|
||||||
height: 102
|
|
||||||
},
|
|
||||||
colButton: {
|
colButton: {
|
||||||
flex: 0,
|
flex: 0,
|
||||||
marginLeft: 12,
|
marginLeft: 12,
|
||||||
marginRight: 12,
|
marginRight: 12,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
width: 78,
|
width: 78
|
||||||
height: 78
|
|
||||||
},
|
},
|
||||||
buttonText: {
|
buttonText: {
|
||||||
fontSize: 28,
|
fontSize: 28,
|
||||||
|
@ -37,7 +33,6 @@ export default StyleSheet.create({
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
width: 78,
|
width: 78,
|
||||||
height: 78,
|
|
||||||
borderRadius: 4
|
borderRadius: 4
|
||||||
},
|
},
|
||||||
textTitle: {
|
textTitle: {
|
||||||
|
|
Loading…
Reference in New Issue