Commit 90a3a0a7 by leiyongsheng

调整RN目录结构

parent 685296e0
android @ 1b110e07
Subproject commit 1f11119dbbb5a355cac3c2a882821701f7bc7c51
Subproject commit 1b110e079ac8e510cbb513b122c95ed9c1328958
......@@ -2,8 +2,11 @@
* @format
*/
import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import { AppRegistry } from 'react-native';
import App from './src/App';
import { name as appName } from './app.json';
AppRegistry.registerComponent(appName, () => App);
AppRegistry.registerComponent(appName, (props) => {
console.log('AppRegistry.registerComponent:' + props);
return App;
});
......@@ -22,10 +22,10 @@ import {
TextInput,
DeviceEventEmitter,
} from 'react-native';
import { BMCUI } from './ui.js'
import CustomerView from './CustomerView.js'
import CustomRoundImageView from './RoundedImage.js'
import MapView from './MapView.js'
import { BMCUI } from './test/ui.js'
import CustomerView from './test/CustomerView.js'
import CustomRoundImageView from './test/RoundedImage.js'
import MapView from './test/MapView.js'
import {
Header,
......@@ -76,7 +76,7 @@ async function showConfirmVsCancelPromiseDialog(msg, leftTip, rightTip) {
// }
// }
const App = () => {
const App = (props) => {
var index = 0;
const region = {
latitude: 37.48,
......@@ -84,6 +84,7 @@ const App = () => {
latitudeDelta: 0.1,
longitudeDelta: 0.1,
};
console.log('init path:' + props.path);
return (
<>
<StatusBar barStyle="dark-content" />
......
export const IC_LAUNCHER = require('../images/ic_launcher.png')
\ No newline at end of file
import React from 'react'
import { View, Text } from 'react-native'
import styles from './index.scss'
const StatusView = ({
loading = true,
empty = false,
error = false,
// 是否填充
fill = true,
loadingText = '加载中...',
errorText = '加载失败了',
emptyText = '暂无相关数据',
emptyIcon = null,
errorIcon = null,
onClick = null,
style = {},
children = null,
}) => {
return (
<View style={[styles.statusContainer, fill ? styles.full : null]}>
{children ? children : <Text>加载中...</Text>}
</View>
)
}
export default StatusView
@import '../../styles/base.scss';
.statusContainer {
width: 100%;
height: 100%;
background: #fff;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
}
\ No newline at end of file
import React from 'react'
import { View, Text } from 'react-native'
const AppTabBar = () => {
return (
<View>
<Text></Text>
</View>
)
}
export default AppTabBar
const dev = {
API_ROOT: 'http://devbmcmapp.hikcreate.com/',
}
const test = {
API_ROOT: 'http://testbmcmapp.hikcreate.com/',
}
const prod = {
API_ROOT: 'https://bmcmapp.hikcreate.com/',
}
const configs = {
dev,
test,
prod,
}
export default configs[process.env.buildEnv || 'dev']
\ No newline at end of file
export default {
USER_INFO: 'USERINFO',
}
import React, { useState, useEffect } from 'react'
import { AsyncStorage } from 'react-native'
import StatusView from '../../components/status-view/index'
import consts from '../../consts'
import { resetNavigatePage } from '../../router'
const AppInit = ({ navigation }) => {
const [loading, setLoading] = useState(true)
useEffect(() => {
let timer = null
AsyncStorage.getItem(consts.USER_INFO).then(userInfoText => {
setLoading(false)
const targetNavigation = userInfoText ? 'Home' : 'Login'
timer = setTimeout(() => {
resetNavigatePage(navigation, targetNavigation, {})
}, 1000)
})
return () => {
clearTimeout(timer)
}
})
return <StatusView loading={loading} />
}
export default AppInit
import React from 'react'
import { View, Text } from 'react-native'
import styles from './index.scss'
import { IC_LAUNCHER } from '../../assets/images'
const Home = () => {
return (
<View style={styles.app}>
<Text style={styles.appName}>Home</Text>
</View>
)
}
export default Home
.app {
background: #f00;
height: 600px;
}
.appName {
color: #fff;
}
\ No newline at end of file
import React from 'react'
import { View, Text } from 'react-native'
const Login = () => {
return (
<View>
<Text>Login</Text>
</View>
)
}
export default Login
import React from 'react'
import { View, Text } from 'react-native'
const Mine = () => {
return (
<View>
<Text>Mine</Text>
</View>
)
}
export default Mine
import { createAppContainer, StackActions, NavigationActions } from 'react-navigation'
import { createStackNavigator } from 'react-navigation-stack'
import { createBottomTabNavigator } from 'react-navigation-tabs'
import Login from '../pages/login'
import Home from '../pages/home'
import Mine from '../pages/mine'
import AppInit from '../pages/appinit'
export function resetNavigatePage(navigation, page, params) {
const resetAction = StackActions.reset({
index: 0,
actions: [
//要跳转到的页面名字
NavigationActions.navigate({ routeName: page, params }),
],
})
navigation.dispatch(resetAction)
}
const AppTabNavigator = createBottomTabNavigator(
{
Home: {
screen: Home,
path: 'home',
},
Mine: {
screen: Mine,
path: 'mine',
},
},
{
initialRouteName: 'Home',
}
)
const AppNavigator = createStackNavigator(
{
AppInit: {
screen: AppInit,
navigationOptions: ({ navigation }) => ({
headerShown: false,
}),
},
Login: {
screen: Login,
path: 'login',
},
TabMain: AppTabNavigator,
},
{
initialRouteName: 'AppInit',
}
)
const AppRouter = createAppContainer(AppNavigator)
export default AppRouter
export default {}
export default {}
@import './variable.scss';
// ============ 布局样式 ===============
.row {
display: flex;
flex-direction: row;
align-items: center;
}
.row-center{
@extend .row;
justify-content: center;
}
.row-between {
@extend .row;
justify-content: space-between;
}
.row-around {
@extend .row;
justify-content: space-around;
}
.row-start {
@extend .row;
justify-content: flex-start;
}
.row-end {
@extend .row;
justify-content: flex-end;
}
.column {
display: flex;
display: -webkit-flex;
justify-content: center;
flex-direction: column;
}
.column-center{
@extend .column;
align-items: center;
}
.column-around{
@extend .column;
align-items: center;
justify-content: space-around;
}
.column-between{
@extend .column;
align-items: center;
justify-content: space-between;
}
.column-start{
@extend .column;
align-items: center;
justify-content: flex-start;
}
.column-end{
@extend .column;
align-items: center;
justify-content: flex-end;
}
.container{
@extend .column;
}
.pageContainer {
@extend .column;
flex: 1;
}
.full {
flex: 1;
}
$primary-color: #37A1FD;
$danger-color: #f00;
\ No newline at end of file
import appConfig from '../config'
// 服务器地址
export const API_SERVER = appConfig.API_ROOT
// 是否外部的服务器
export const isOutServer = url => url.indexOf('/') !== 0
// 全局错误码处理
const ERROR_CODE_MAP = {
// 401: {
// message: '',
// process: (resp) => {}
// },
}
const SUCCESS_CODE = 1000
const defaultStateConfig = {
loading: true,
errorToast: true,
loadingText: '加载中...',
}
// 封装get post 请求
export const $request = {
get(url, params, config) {},
post(url, params, config) {},
delete(url, params, config) {},
postForm(url, params, config) {},
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment