Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- isPortrait,
- isLandscape,
- } from './scalign';
- class ScalingSize {
- constructor(width, height, factor, setState, Dimensions){
- this.width = width;
- this.height = height;
- this.factor = factor;
- this.Dimensions = Dimensions;
- this.setState = setState;
- }
- calculaDesconto() {
- this.Dimensions.addEventListener('change', () => {
- this.setState({
- orientation: isPortrait() ? 'portrait' : 'landscape',
- devicetype: DeviceInfo.isTablet() ? 'tablet' : 'phone',
- width: Dimensions.get('window').width,
- });
- if(isPortrait()){
- this.setState({
- scale: DeviceInfo.isTablet() ? 315: 279,
- textScale: DeviceInfo.isTablet() ? 18: 16,
- })
- }else{
- this.setState({
- scale: DeviceInfo.isTablet() ? 323 : 306,
- textScale: DeviceInfo.isTablet() ? 18: 16,
- })
- }
- });
- if(isPortrait()){
- this.setState({
- scale: DeviceInfo.isTablet() ? 315: 279,
- textScale: DeviceInfo.isTablet() ? 18: 16,
- })
- }else{
- this.setState({
- scale: DeviceInfo.isTablet() ? 323 : 306,
- textScale: DeviceInfo.isTablet() ? 18: 16,
- })
- }
- }
- scale(size) {
- return this.Dimensions.get('window').width / this.guidelineBaseWidth * size;
- }
- verticalScale (size) {
- return this.Dimensions.get('window').height / this.guidelineBaseHeight * size
- }
- moderateScale (size, factor = 0.5) {
- return size + ( this.scale(size) - size ) * factor;
- }
- }
- export default ScalingSize;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement