import { Layer } from '../types' ; import handleClassName from '../handleClassName' ; import { picassoTrans } from '../../../picasso-trans/src' ; import { WebScale , Unit , ColorFormat , CodeType } from '../../../sketch-dsl/src' ; import { generateRNJSX } from './generateJSX' ; import { generateRNStyle } from './generateStyle' ; description param { Layer [ ] } data param { number } size export const picassoRNCode = ( data , size ) => { data = handleClassName ( data ) ; data = picassoTrans ( data , { scale : WebScale . Points , unit : Unit . ReactNative , colorFormat : ColorFormat . RGBA , codeType : CodeType . ReactNative } ) ; const jsxCode = generateRNJSX ( data ) ; const styleCode = generateRNStyle ( data ) ; return { jsx : `import React, { Component } from 'react';
        import {
            Image,
            View,
            Text,
            ImageBackground,
            ScrollView,
            Dimensions,
            StyleSheet,
            SafeAreaView,
            Platform,
            StatusBar,
            PixelRatio,
        } from 'react-native';
        ${ /LinearGradient/ . test ( jsxCode ) ? "import LinearGradient from 'react-native-linear-gradient';" : "" }
        
        const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get('window');
        
        const scaleSize = (size) => PixelRatio.roundToNearestPixel(size * (SCREEN_WIDTH / ${ size }));
        
        const isIphoneX = () => {
            return Platform.OS === 'ios' &&
                !Platform.isPad &&
                !Platform.isTVOS &&
                (SCREEN_HEIGHT === 812 || SCREEN_WIDTH === 812 || SCREEN_WIDTH === 896 || SCREEN_HEIGHT === 896);
        }
            
        const STATUSBAR_HEIGHT = Platform.select({
            ios: isIphoneX() ? 44 : 20,
            android: StatusBar.currentHeight,
        })
        
        export default class PicasoPage extends Component {
            constructor(props) {
                super(props);
            }
        
            componentDidMount() {}
        
            componentWillUnmount() {}
        
            render() {
                return (
                    <ScrollView style={{ flex: 1, width: SCREEN_WIDTH, height: SCREEN_HEIGHT }}>
                        ${ jsxCode }
                    </ScrollView>
                )
            }
        }
        
        const styles = StyleSheet.create(${ styleCode })
        ` } ; } ;