diff --git a/app/utils/scaling.js b/app/utils/scaling.js index f154a50a9..7cf33f1fc 100644 --- a/app/utils/scaling.js +++ b/app/utils/scaling.js @@ -1,14 +1,11 @@ -import { Dimensions } from 'react-native'; - import { isTablet } from './deviceInfo'; -const { width, height } = Dimensions.get('window'); - const guidelineBaseWidth = isTablet ? 600 : 375; const guidelineBaseHeight = isTablet ? 800 : 667; -const scale = size => (width / guidelineBaseWidth) * size; -const verticalScale = size => (height / guidelineBaseHeight) * size; -const moderateScale = (size, factor = 0.5) => size + (scale(size) - size) * factor; +// TODO: we need to refactor this +const scale = (size, width) => (width / guidelineBaseWidth) * size; +const verticalScale = (size, height) => (height / guidelineBaseHeight) * size; +const moderateScale = (size, factor = 0.5, width) => size + (scale(size, width) - size) * factor; export { scale, verticalScale, moderateScale }; diff --git a/app/views/NewServerView/index.js b/app/views/NewServerView/index.js index e444f6c08..e2dd6b25f 100644 --- a/app/views/NewServerView/index.js +++ b/app/views/NewServerView/index.js @@ -30,6 +30,7 @@ import SSLPinning from '../../utils/sslPinning'; import RocketChat from '../../lib/rocketchat'; import { isTablet } from '../../utils/deviceInfo'; import { verticalScale, moderateScale } from '../../utils/scaling'; +import { withDimensions } from '../../dimensions'; import ServerInput from './ServerInput'; const styles = StyleSheet.create({ @@ -285,22 +286,26 @@ class NewServerView extends React.Component { renderCertificatePicker = () => { const { certificate } = this.state; - const { theme } = this.props; + const { theme, width, height } = this.props; return ( - + {certificate ? I18n.t('Your_certificate') : I18n.t('Do_you_have_a_certificate')} - + {certificate ?? I18n.t('Apply_Your_Certificate')} @@ -309,7 +314,7 @@ class NewServerView extends React.Component { }; render() { - const { connecting, theme, adding } = this.props; + const { connecting, theme, adding, width, height } = this.props; const { text, connectingOpen, serversHistory } = this.state; const marginTopHeader = adding ? 25 : 70; @@ -320,9 +325,9 @@ class NewServerView extends React.Component { style={[ styles.onboardingImage, { - marginTop: isTablet ? 0 : verticalScale(marginTopHeader), - marginBottom: verticalScale(25), - maxHeight: verticalScale(150) + marginTop: isTablet ? 0 : verticalScale(marginTopHeader, height), + marginBottom: verticalScale(25, height), + maxHeight: verticalScale(150, height) } ]} source={require('../../static/images/logo.png')} @@ -332,14 +337,18 @@ class NewServerView extends React.Component { Rocket.Chat {I18n.t('Onboarding_subtitle')} @@ -366,7 +375,11 @@ class NewServerView extends React.Component { {I18n.t('Onboarding_join_open_description')} @@ -399,4 +412,4 @@ const mapDispatchToProps = dispatch => ({ inviteLinksClear: () => dispatch(inviteLinksClearAction()) }); -export default connect(mapStateToProps, mapDispatchToProps)(withTheme(NewServerView)); +export default connect(mapStateToProps, mapDispatchToProps)(withDimensions(withTheme(NewServerView)));