App.tsx 1.59 KB
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React, { useLayoutEffect, useEffect } from 'react'
import { StatusBar, Platform, Text, TextInput } from 'react-native'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { RouterView } from './src/router'
import { Provider } from 'react-redux'
import { PrivacyAlert } from './src/components'
import { PortalHot, Update } from 'react-native-mb-ui'
import { getVersionCode } from './src/libs/utils'
import { APP } from './src/config'
import SplashScreen from 'react-native-splash-screen'
import store from './src/store'

// 阻止系统缩放
TextInput['defaultProps'] = Object.assign({}, TextInput['defaultProps'], { allowFontScaling: false })
Text['defaultProps'] = Object.assign({}, Text['defaultProps'], { allowFontScaling: false })

const Page: React.FC = () => {
    useLayoutEffect(() => {
        SplashScreen.hide()
    }, [])

    useEffect(() => {
        const get = async (): Promise<void> => {
            Update(`${APP.appAdminUrl}/api/app/version/${APP.APP_CODE}`, await getVersionCode())
            return
        }
        get()
    }, [])

    return (

        <Provider store={store}>
            {Platform.OS === 'ios' && <StatusBar translucent={true} backgroundColor="rgba(255,255,255,0)" barStyle="dark-content" />}
            <PortalHot>
                <SafeAreaProvider>
                    <RouterView />
                    <PrivacyAlert />
                </SafeAreaProvider>
            </PortalHot>
        </Provider>
    )
}

export default Page