Fix scaling
This commit is contained in:
parent
cd583bb503
commit
e01c31dbf3
|
@ -2,13 +2,12 @@ import { Dimensions } from 'react-native';
|
||||||
|
|
||||||
import { isTablet } from './deviceInfo';
|
import { isTablet } from './deviceInfo';
|
||||||
|
|
||||||
const { width, height } = Dimensions.get('window');
|
|
||||||
|
|
||||||
const guidelineBaseWidth = isTablet ? 600 : 375;
|
const guidelineBaseWidth = isTablet ? 600 : 375;
|
||||||
const guidelineBaseHeight = isTablet ? 800 : 667;
|
const guidelineBaseHeight = isTablet ? 800 : 667;
|
||||||
|
|
||||||
const scale = size => (width / guidelineBaseWidth) * size;
|
// TODO: we need to refactor this
|
||||||
const verticalScale = size => (height / guidelineBaseHeight) * size;
|
const scale = (size, width) => (width / guidelineBaseWidth) * size;
|
||||||
const moderateScale = (size, factor = 0.5) => size + (scale(size) - size) * factor;
|
const verticalScale = (size, height) => (height / guidelineBaseHeight) * size;
|
||||||
|
const moderateScale = (size, factor = 0.5, width) => size + (scale(size, width) - size) * factor;
|
||||||
|
|
||||||
export { scale, verticalScale, moderateScale };
|
export { scale, verticalScale, moderateScale };
|
||||||
|
|
|
@ -31,6 +31,7 @@ import SSLPinning from '../../utils/sslPinning';
|
||||||
import RocketChat from '../../lib/rocketchat';
|
import RocketChat from '../../lib/rocketchat';
|
||||||
import { isTablet } from '../../utils/deviceInfo';
|
import { isTablet } from '../../utils/deviceInfo';
|
||||||
import { verticalScale, moderateScale } from '../../utils/scaling';
|
import { verticalScale, moderateScale } from '../../utils/scaling';
|
||||||
|
import { withDimensions } from '../../dimensions';
|
||||||
import ServerInput from './ServerInput';
|
import ServerInput from './ServerInput';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
@ -287,22 +288,26 @@ class NewServerView extends React.Component {
|
||||||
|
|
||||||
renderCertificatePicker = () => {
|
renderCertificatePicker = () => {
|
||||||
const { certificate } = this.state;
|
const { certificate } = this.state;
|
||||||
const { theme } = this.props;
|
const { theme, width, height } = this.props;
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
styles.certificatePicker,
|
styles.certificatePicker,
|
||||||
{
|
{
|
||||||
marginBottom: verticalScale(32)
|
marginBottom: verticalScale(32, height)
|
||||||
}
|
}
|
||||||
]}>
|
]}>
|
||||||
<Text style={[styles.chooseCertificateTitle, { color: themes[theme].auxiliaryText, fontSize: moderateScale(13) }]}>
|
<Text
|
||||||
|
style={[
|
||||||
|
styles.chooseCertificateTitle,
|
||||||
|
{ color: themes[theme].auxiliaryText, fontSize: moderateScale(13, null, width) }
|
||||||
|
]}>
|
||||||
{certificate ? I18n.t('Your_certificate') : I18n.t('Do_you_have_a_certificate')}
|
{certificate ? I18n.t('Your_certificate') : I18n.t('Do_you_have_a_certificate')}
|
||||||
</Text>
|
</Text>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={certificate ? this.handleRemove : this.chooseCertificate}
|
onPress={certificate ? this.handleRemove : this.chooseCertificate}
|
||||||
testID='new-server-choose-certificate'>
|
testID='new-server-choose-certificate'>
|
||||||
<Text style={[styles.chooseCertificate, { color: themes[theme].tintColor, fontSize: moderateScale(13) }]}>
|
<Text style={[styles.chooseCertificate, { color: themes[theme].tintColor, fontSize: moderateScale(13, null, width) }]}>
|
||||||
{certificate ?? I18n.t('Apply_Your_Certificate')}
|
{certificate ?? I18n.t('Apply_Your_Certificate')}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
@ -311,7 +316,7 @@ class NewServerView extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { connecting, theme, adding, root } = this.props;
|
const { connecting, theme, adding, root, width, height } = this.props;
|
||||||
const { text, connectingOpen, serversHistory } = this.state;
|
const { text, connectingOpen, serversHistory } = this.state;
|
||||||
const marginTopHeader = adding && root === ROOT_NEW_SERVER ? 25 : 70;
|
const marginTopHeader = adding && root === ROOT_NEW_SERVER ? 25 : 70;
|
||||||
|
|
||||||
|
@ -322,9 +327,9 @@ class NewServerView extends React.Component {
|
||||||
style={[
|
style={[
|
||||||
styles.onboardingImage,
|
styles.onboardingImage,
|
||||||
{
|
{
|
||||||
marginTop: isTablet ? 0 : verticalScale(marginTopHeader),
|
marginTop: isTablet ? 0 : verticalScale(marginTopHeader, height),
|
||||||
marginBottom: verticalScale(25),
|
marginBottom: verticalScale(25, height),
|
||||||
maxHeight: verticalScale(150)
|
maxHeight: verticalScale(150, height)
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
source={require('../../static/images/logo.png')}
|
source={require('../../static/images/logo.png')}
|
||||||
|
@ -334,14 +339,18 @@ class NewServerView extends React.Component {
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
styles.title,
|
styles.title,
|
||||||
{ color: themes[theme].titleText, fontSize: moderateScale(22), marginBottom: verticalScale(8) }
|
{ color: themes[theme].titleText, fontSize: moderateScale(22, null, width), marginBottom: verticalScale(8, height) }
|
||||||
]}>
|
]}>
|
||||||
Rocket.Chat
|
Rocket.Chat
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
styles.subtitle,
|
styles.subtitle,
|
||||||
{ color: themes[theme].controlText, fontSize: moderateScale(16), marginBottom: verticalScale(41) }
|
{
|
||||||
|
color: themes[theme].controlText,
|
||||||
|
fontSize: moderateScale(16, null, width),
|
||||||
|
marginBottom: verticalScale(41, height)
|
||||||
|
}
|
||||||
]}>
|
]}>
|
||||||
{I18n.t('Onboarding_subtitle')}
|
{I18n.t('Onboarding_subtitle')}
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -368,7 +377,11 @@ class NewServerView extends React.Component {
|
||||||
<Text
|
<Text
|
||||||
style={[
|
style={[
|
||||||
styles.description,
|
styles.description,
|
||||||
{ color: themes[theme].auxiliaryText, fontSize: moderateScale(14), marginBottom: verticalScale(24) }
|
{
|
||||||
|
color: themes[theme].auxiliaryText,
|
||||||
|
fontSize: moderateScale(14, null, width),
|
||||||
|
marginBottom: verticalScale(24, height)
|
||||||
|
}
|
||||||
]}>
|
]}>
|
||||||
{I18n.t('Onboarding_join_open_description')}
|
{I18n.t('Onboarding_join_open_description')}
|
||||||
</Text>
|
</Text>
|
||||||
|
@ -402,4 +415,4 @@ const mapDispatchToProps = dispatch => ({
|
||||||
inviteLinksClear: () => dispatch(inviteLinksClearAction())
|
inviteLinksClear: () => dispatch(inviteLinksClearAction())
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(NewServerView));
|
export default connect(mapStateToProps, mapDispatchToProps)(withDimensions(withTheme(NewServerView)));
|
||||||
|
|
Loading…
Reference in New Issue