فهرست منبع

1.使用react-native-splash-screen插件
2.增加过渡页,移除android过渡页

zhangmengjie 5 سال پیش
والد
کامیت
59f834d90c

+ 4 - 2
App.js

@@ -23,6 +23,7 @@ import Buy from './pages/buy/buy';
 import Login from './pages/Login';
 import SearchResult from './pages/searchResult';
 import PhoneBind from './pages/PhoneBind';
+import Splash from './pages/Splash';
 
 const RootNavigator = createStackNavigator(
 	{
@@ -38,10 +39,11 @@ const RootNavigator = createStackNavigator(
 		Login: { screen: Login },
 		Buy: { screen: Buy },
 		SearchResult: { screen: SearchResult },
-		PhoneBind: { screen: PhoneBind }
+		PhoneBind: { screen: PhoneBind },
+		Splash: { screen: Splash }
 	},
 	{
-		initialRouteName: 'Login',
+		initialRouteName: 'Splash',
 		headerMode: 'null'
 	}
 );

+ 1 - 0
android/app/build.gradle

@@ -151,6 +151,7 @@ android {
 }
 
 dependencies {
+    implementation project(':react-native-splash-screen')
     implementation project(':react-native-device-info')
     implementation project(':react-native-wechat')
     implementation project(':react-native-image-picker')

+ 14 - 14
android/app/src/main/AndroidManifest.xml

@@ -16,10 +16,10 @@
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />
     <uses-permission android:name="com.xiaomi.permission.AUTH_THIRDPAY" />
     <uses-permission android:name="android.permission.CAMERA" />
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
-    <uses-permission android:name="android.permission.BLUETOOTH"/>
-    
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+
     <application
         android:name="com.edufound.MainApplication"
         android:allowBackup="false"
@@ -37,30 +37,30 @@
             android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
             android:label="@string/app_name"
             android:screenOrientation="sensorPortrait"
-            android:windowSoftInputMode="adjustResize"></activity>
+            android:windowSoftInputMode="adjustResize">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
         <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
         <activity
             android:name=".activity.WebActivity"
             android:screenOrientation="sensorPortrait" />
         <activity
             android:name=".activity.SplashActivity"
-            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
-            android:screenOrientation="sensorPortrait">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
+            android:screenOrientation="sensorPortrait"
+            android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
+
         </activity>
         <activity
             android:name=".wxapi.WXEntryActivity"
-            android:label="@string/app_name"
             android:exported="true"
-            />
+            android:label="@string/app_name" />
         <activity
             android:name=".wxapi.WXPayEntryActivity"
-            android:label="@string/app_name"
             android:exported="true"
-            />
+            android:label="@string/app_name" />
     </application>
 
 </manifest>

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 133 - 121
android/app/src/main/assets/index.android.bundle


+ 4 - 1
android/app/src/main/java/com/edufound/MainApplication.java

@@ -16,6 +16,8 @@ import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
 import com.theweflex.react.WeChatPackage;
 import com.learnium.RNDeviceInfo.RNDeviceInfo;
 
+import org.devio.rn.splashscreen.SplashScreenReactPackage;
+
 import java.util.Arrays;
 import java.util.List;
 
@@ -38,7 +40,8 @@ public class MainApplication extends Application implements ReactApplication {
                     new OrientationPackage(),
                     new ImagePickerPackage(),
                     new WeChatPackage(),
-                    new RNDeviceInfo()
+                    new RNDeviceInfo(),
+                    new SplashScreenReactPackage()
             );
         }
 

+ 16 - 16
android/app/src/main/java/com/edufound/mobile/MainActivity.java

@@ -1,13 +1,11 @@
 package com.edufound.mobile;
 
-import android.content.Intent;
 import android.os.Bundle;
-import android.text.TextUtils;
-import android.util.Log;
 
-import com.edufound.mobile.activity.WebActivity;
 import com.facebook.react.ReactActivity;
 
+import org.devio.rn.splashscreen.SplashScreen;
+
 public class MainActivity extends ReactActivity {
 
     /**
@@ -21,19 +19,21 @@ public class MainActivity extends ReactActivity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
+        SplashScreen.show(this, true);
         super.onCreate(savedInstanceState);
-        String params = getIntent().getStringExtra("params");
-        Log.e("com.edufound.mobile", "跳转参数a:" + params);
-        if (!TextUtils.isEmpty(params) && !params.equals("null")) {
-            switch (params) {
-                case "WebActivity":
-                    Intent intent = new Intent(MainActivity.this, WebActivity.class);
-                    intent.putExtra("json", "MainActivity---params--json");
-                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-                    startActivity(intent);
-                    break;
-            }
-        }
+//        String params = getIntent().getStringExtra("params");
+//        Log.e("com.edufound.mobile", "跳转参数a:" + params);
+//        if (!TextUtils.isEmpty(params) && !params.equals("null")) {
+//            switch (params) {
+//                case "WebActivity":
+//                    Intent intent = new Intent(MainActivity.this, WebActivity.class);
+//                    intent.putExtra("json", "MainActivity---params--json");
+//                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+//                    startActivity(intent);
+//                    break;
+//            }
+//        }
+
 
     }
 }

+ 7 - 0
android/app/src/main/res/layout/launch_screen.xml

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@drawable/splash">
+
+</FrameLayout>

+ 1 - 0
android/app/src/main/res/values-v19/styles.xml

@@ -5,6 +5,7 @@
         <!-- Customize your theme here. -->
 
         <item name="android:windowTranslucentNavigation">false</item>
+        <item name="android:windowIsTranslucent">true</item>
     </style>
 
 </resources>

+ 1 - 0
android/app/src/main/res/values/styles.xml

@@ -4,6 +4,7 @@
     <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
         <!-- Customize your theme here. -->
         <item name="android:windowTranslucentNavigation">false</item>
+        <item name="android:windowIsTranslucent">true</item>
     </style>
 
 

+ 2 - 0
android/settings.gradle

@@ -1,4 +1,6 @@
 rootProject.name = 'efunbox_mobile_8'
+include ':react-native-splash-screen'
+project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android')
 include ':react-native-device-info'
 project(':react-native-device-info').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-device-info/android')
 include ':react-native-wechat'

+ 19 - 0
ios/efunbox_mobile_8.xcodeproj/project.pbxproj

@@ -48,6 +48,7 @@
 		D3F60855D8FF4C4A9C5D4ACA /* RCTWeChatTests.xctest in Resources */ = {isa = PBXBuildFile; fileRef = 7411A64812B4434AAAD1DBB5 /* RCTWeChatTests.xctest */; };
 		12BDF20DBE4141F8A990F8D7 /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F9FCB46EDB7F456AB88EF68C /* libRNDeviceInfo.a */; };
 		5C6A0716F9C849D2B67AE09E /* libRNDeviceInfo-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 505D2A7DD9E64E7B82EC655D /* libRNDeviceInfo-tvOS.a */; };
+		5ABEAAADCD024F01B438B689 /* libSplashScreen.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D337E77E80D430CB4D8DF4B /* libSplashScreen.a */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
@@ -370,6 +371,8 @@
 		18F4C7BFE3EB4947A8A72EB4 /* RNDeviceInfo.xcodeproj */ = {isa = PBXFileReference; name = "RNDeviceInfo.xcodeproj"; path = "../node_modules/react-native-device-info/ios/RNDeviceInfo.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
 		F9FCB46EDB7F456AB88EF68C /* libRNDeviceInfo.a */ = {isa = PBXFileReference; name = "libRNDeviceInfo.a"; path = "libRNDeviceInfo.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
 		505D2A7DD9E64E7B82EC655D /* libRNDeviceInfo-tvOS.a */ = {isa = PBXFileReference; name = "libRNDeviceInfo-tvOS.a"; path = "libRNDeviceInfo-tvOS.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
+		2CB189F11F9C4B5B8D057FFC /* SplashScreen.xcodeproj */ = {isa = PBXFileReference; name = "SplashScreen.xcodeproj"; path = "../node_modules/react-native-splash-screen/ios/SplashScreen.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
+		1D337E77E80D430CB4D8DF4B /* libSplashScreen.a */ = {isa = PBXFileReference; name = "libSplashScreen.a"; path = "libSplashScreen.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -405,6 +408,7 @@
 				EBD8BAD03DF74C0E96E4D170 /* libRCTWeChat.a in Frameworks */,
 				D3F60855D8FF4C4A9C5D4ACA /* RCTWeChatTests.xctest in Resources */,
 				12BDF20DBE4141F8A990F8D7 /* libRNDeviceInfo.a in Frameworks */,
+				5ABEAAADCD024F01B438B689 /* libSplashScreen.a in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -602,6 +606,7 @@
 				B11B05F3205C483583EB7421 /* RNImagePicker.xcodeproj */,
 				593F0F0596BC4EB7996A9D21 /* RCTWeChat.xcodeproj */,
 				18F4C7BFE3EB4947A8A72EB4 /* RNDeviceInfo.xcodeproj */,
+				2CB189F11F9C4B5B8D057FFC /* SplashScreen.xcodeproj */,
 			);
 			name = Libraries;
 			sourceTree = "<group>";
@@ -1238,6 +1243,7 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1247,6 +1253,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
+					"$(SRCROOT)\..\node_modules\react-native-splash-screen\ios",
 				);
 			};
 			name = Debug;
@@ -1277,6 +1284,7 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1286,6 +1294,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
+					"$(SRCROOT)\..\node_modules\react-native-splash-screen\ios",
 				);
 			};
 			name = Release;
@@ -1314,6 +1323,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
+					"$(SRCROOT)\..\node_modules\react-native-splash-screen\ios",
 				);
 			};
 			name = Debug;
@@ -1341,6 +1351,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
+					"$(SRCROOT)\..\node_modules\react-native-splash-screen\ios",
 				);
 			};
 			name = Release;
@@ -1379,6 +1390,7 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1388,6 +1400,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
+					"$(SRCROOT)\..\node_modules\react-native-splash-screen\ios",
 				);
 			};
 			name = Debug;
@@ -1426,6 +1439,7 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1435,6 +1449,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
+					"$(SRCROOT)\..\node_modules\react-native-splash-screen\ios",
 				);
 			};
 			name = Release;
@@ -1472,6 +1487,7 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1481,6 +1497,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
+					"$(SRCROOT)\..\node_modules\react-native-splash-screen\ios",
 				);
 			};
 			name = Debug;
@@ -1518,6 +1535,7 @@
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 					"\"$(SRCROOT)/$(TARGET_NAME)\"",
+					"\"$(SRCROOT)/$(TARGET_NAME)\"",
 				);
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
@@ -1527,6 +1545,7 @@
 					"$(SRCROOT)\..\node_modules\react-native-image-picker\ios",
 					"$(SRCROOT)\..\node_modules\react-native-wechat\ios",
 					"$(SRCROOT)\..\node_modules\react-native-device-info\ios\RNDeviceInfo",
+					"$(SRCROOT)\..\node_modules\react-native-splash-screen\ios",
 				);
 			};
 			name = Release;

+ 9 - 4
package-lock.json

@@ -6300,7 +6300,7 @@
     },
     "opencollective": {
       "version": "1.0.3",
-      "resolved": "https://registry.npm.taobao.org/opencollective/download/opencollective-1.0.3.tgz",
+      "resolved": "https://registry.npm.taobao.org/opencollective/download/opencollective-1.0.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fopencollective%2Fdownload%2Fopencollective-1.0.3.tgz",
       "integrity": "sha1-ruY3K8KBRFg2kMPKja7PwSDdDvE=",
       "requires": {
         "babel-polyfill": "6.23.0",
@@ -6318,12 +6318,12 @@
         },
         "ansi-styles": {
           "version": "2.2.1",
-          "resolved": "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-2.2.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fansi-styles%2Fdownload%2Fansi-styles-2.2.1.tgz",
+          "resolved": "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-2.2.1.tgz",
           "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4="
         },
         "chalk": {
           "version": "1.1.3",
-          "resolved": "https://registry.npm.taobao.org/chalk/download/chalk-1.1.3.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fchalk%2Fdownload%2Fchalk-1.1.3.tgz",
+          "resolved": "https://registry.npm.taobao.org/chalk/download/chalk-1.1.3.tgz",
           "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
           "requires": {
             "ansi-styles": "^2.2.1",
@@ -6335,7 +6335,7 @@
         },
         "inquirer": {
           "version": "3.0.6",
-          "resolved": "https://registry.npm.taobao.org/inquirer/download/inquirer-3.0.6.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Finquirer%2Fdownload%2Finquirer-3.0.6.tgz",
+          "resolved": "https://registry.npm.taobao.org/inquirer/download/inquirer-3.0.6.tgz",
           "integrity": "sha1-4EqqnQW3o8ubD0B9BDdfBEcZA0c=",
           "requires": {
             "ansi-escapes": "^1.1.0",
@@ -7129,6 +7129,11 @@
       "resolved": "https://registry.npm.taobao.org/react-native-screens/download/react-native-screens-1.0.0-alpha.22.tgz",
       "integrity": "sha1-ehIDd7Uqqbu5TQuFQaAUAmvpKJs="
     },
+    "react-native-splash-screen": {
+      "version": "3.2.0",
+      "resolved": "https://registry.npm.taobao.org/react-native-splash-screen/download/react-native-splash-screen-3.2.0.tgz",
+      "integrity": "sha1-1H7IVXsbqYjuPqmNAUYwgbYP/0U="
+    },
     "react-native-storage": {
       "version": "1.0.1",
       "resolved": "https://registry.npm.taobao.org/react-native-storage/download/react-native-storage-1.0.1.tgz",

+ 1 - 0
package.json

@@ -18,6 +18,7 @@
     "react-native-gesture-handler": "^1.1.0",
     "react-native-image-picker": "^0.28.1",
     "react-native-orientation": "^3.1.3",
+    "react-native-splash-screen": "^3.2.0",
     "react-native-storage": "^1.0.1",
     "react-native-swiper": "^1.5.14",
     "react-native-video": "^4.4.1",

+ 4 - 3
pages/Login.js

@@ -17,9 +17,10 @@ export default class Login extends BasePage {
 	state = {
 		phone_num: '',
 		verification_text: '获取验证码',
-		verification_code: '9999',
-		http_verification_code: '9999',
-		deviceCode: ''
+		verification_code: '',
+		http_verification_code: '',
+		deviceCode: '',
+		sss: ''
 	};
 	render() {
 		return (

+ 20 - 0
pages/Splash.js

@@ -0,0 +1,20 @@
+import React, { PureComponent } from 'react';
+import { StyleSheet, Text, View, Image, TouchableOpacity, StatusBar, ToastAndroid, TextInput } from 'react-native';
+import BasePage from './BasePage';
+import SplashScreen from 'react-native-splash-screen';
+export default class Splash extends BasePage {
+	render() {
+		return (
+			<View style={{ flex: 1 }}>
+				<StatusBar backgroundColor={'transparent'} translucent={true} />
+			</View>
+		);
+	}
+
+	componentDidMount() {
+		setTimeout(() => {
+			SplashScreen.hide();
+			this.clearPageToNext('Login');
+		}, 3000);
+	}
+}