@huaapp001/m-play 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,213 @@
1
+ import AsyncStorage from '@react-native-async-storage/async-storage';
2
+ import Clipboard from '@react-native-clipboard/clipboard';
3
+ import {
4
+ isFirstInitAfSuccessAtom,
5
+ schemeDeepLinkParamsAtom,
6
+ } from '../atoms/global';
7
+ import { useAtomValue, useSetAtom } from 'jotai';
8
+ import { useEffect } from 'react';
9
+ import { Linking } from 'react-native';
10
+ import appsFlyer from 'react-native-appsflyer';
11
+ import { APP_FIRST_INIT_ADJUST_KEY } from '../const/storage';
12
+ import useGetNetwork from './useGetNetwork';
13
+ import { isAllowAttAccessAtom } from '../atoms/global';
14
+ import { extractQueryParams } from '../utils/extractQueryParams';
15
+ import { getUrlFromDevice } from '../utils/getUrlFromDevice';
16
+ import { getConfig } from '../../config';
17
+
18
+ interface Data {
19
+ deeplink: string;
20
+ isAJ?: boolean;
21
+ isLoadTwo?: boolean;
22
+ }
23
+
24
+
25
+ const useInitAfInfo = () => {
26
+ const systemConfig = getConfig();
27
+ const setSchemeDeepLinkParamsAtom = useSetAtom(schemeDeepLinkParamsAtom);
28
+ const [isConnected] = useGetNetwork();
29
+ const isAllowAttAccess = useAtomValue(isAllowAttAccessAtom);
30
+ const setIsFirstInitAfSuccessAtom = useSetAtom(isFirstInitAfSuccessAtom);
31
+
32
+ /** 处理深链信息 */
33
+ const processDeepLink = (data: Data) => {
34
+ const { deeplink, isAJ = false, isLoadTwo = false } = data;
35
+ // TODO 可删除
36
+ console.log('deeplinkdeeplink------->>>>>', deeplink);
37
+ if (!isLoadTwo && isAJ) {
38
+ global.IS_FIRST_LOAD_DEEP_LINK = true;
39
+ global.AF_END_LOAD_TIME = new Date().getTime();
40
+ }
41
+ let params: Record<string, string> = {};
42
+ if (deeplink.includes(systemConfig.adjustConfig.ONELINK_SHARE_VALUE)) {
43
+ const url = deeplink.split(systemConfig.adjustConfig.ONELINK_SHARE_VALUE)[1];
44
+ params = extractQueryParams(url) ?? {};
45
+ if (params.deep_link_value) {
46
+ processDeepLink({
47
+ deeplink:
48
+ systemConfig.adjustConfig.ONELINK_NO_HTTP_VALUE + decodeURIComponent(params.deep_link_value),
49
+ isAJ,
50
+ isLoadTwo: true,
51
+ });
52
+ return;
53
+ }
54
+ }
55
+ if (deeplink.includes(systemConfig.adjustConfig.ONELINK_NO_HTTP_VALUE)) {
56
+ const url = deeplink.split(systemConfig.adjustConfig.ONELINK_NO_HTTP_VALUE)[1];
57
+ params = extractQueryParams(url) ?? {};
58
+ // 做一个兜底处理 目前安卓模拟器会出现右边的情况 ONELINK_NO_HTTP_VALUE?deep_link_value=ONELINK_NO_HTTP_VALUE
59
+ if (params.deep_link_value) {
60
+ processDeepLink({
61
+ deeplink: systemConfig.adjustConfig.ONELINK_NO_HTTP_VALUE + decodeURIComponent(params.deep_link_value),
62
+ isAJ,
63
+ isLoadTwo: true,
64
+ });
65
+ return;
66
+ }
67
+ }
68
+ console.log('params',params)
69
+ setSchemeDeepLinkParamsAtom(params);
70
+ setIsFirstInitAfSuccessAtom(true);
71
+ };
72
+
73
+ /** 剪切板信息 */
74
+ const handlePasteboardInfo = async () => {
75
+ // TODO 可删除
76
+ console.log('deeplinkdeeplink------->>>>>handlePasteboardInfo');
77
+ // 若是之前执行过,该值是true,但是之前若是没给它赋值是不会相等的
78
+ const isNotFirstInit =
79
+ (await AsyncStorage.getItem(APP_FIRST_INIT_ADJUST_KEY)) === 'true';
80
+ // TODO 可删除
81
+ console.log(
82
+ 'deeplinkdeeplink------->>>>>handlePasteboardInfo---isNotFirstInit',
83
+ await AsyncStorage.getItem(APP_FIRST_INIT_ADJUST_KEY),
84
+ isNotFirstInit
85
+ );
86
+ if (isNotFirstInit) {
87
+ return;
88
+ }
89
+ // 剪切板内容
90
+ let pasteboardValue = await Clipboard.getString();
91
+ // TODO 可删除
92
+ console.log(
93
+ 'deeplinkdeeplink------->>>>>handlePasteboardInfo---pasteboardValue',
94
+ pasteboardValue
95
+ );
96
+ if (
97
+ pasteboardValue &&
98
+ pasteboardValue.includes(systemConfig.adjustConfig.completePrefixUrl)
99
+ ) {
100
+ global.wakeUpDeepLinkType = 'clipboard';
101
+ }
102
+ if (
103
+ !pasteboardValue ||
104
+ !pasteboardValue.includes(systemConfig.adjustConfig.completePrefixUrl)
105
+ ) {
106
+ // 走设备是否匹配 请求接口返回信息
107
+ pasteboardValue = await getUrlFromDevice();
108
+ if (pasteboardValue) {
109
+ global.wakeUpDeepLinkType = 'ip';
110
+ }
111
+ }
112
+ if (pasteboardValue) {
113
+ processDeepLink({ deeplink: pasteboardValue, isAJ: !isNotFirstInit });
114
+ }
115
+
116
+ await AsyncStorage.setItem(APP_FIRST_INIT_ADJUST_KEY, 'true');
117
+ };
118
+
119
+ useEffect(() => {
120
+ // TODO 可删除
121
+ console.log(
122
+ 'deeplinkdeeplink------->>>>>isAllowAttAccess',
123
+ isAllowAttAccess
124
+ );
125
+ if (!isAllowAttAccess) {
126
+ return;
127
+ }
128
+ // TODO 可删除
129
+ console.log(
130
+ 'isAllowAttAccessisAllowAttAccess111---->>>.',
131
+ isAllowAttAccess
132
+ );
133
+ // 记录下af初始化加载时的时间
134
+ global.AF_START_LOAD_TIME = new Date().getTime();
135
+ appsFlyer.onDeepLink((res) => {
136
+ // TODO 可删除
137
+ console.log('deeplinkdeeplink------->>>>>deepLinkStatus', res);
138
+ // 若是对应这个状态直接走兜底逻辑
139
+ if (res?.deepLinkStatus === 'NOT_FOUND') {
140
+ handlePasteboardInfo();
141
+ return;
142
+ }
143
+ const linkValue = decodeURIComponent(res?.data?.deep_link_value);
144
+ // 若是值不存在走兜底逻辑
145
+ if (!linkValue || linkValue === 'undefined') {
146
+ handlePasteboardInfo();
147
+ return;
148
+ }
149
+ global.wakeUpDeepLinkType = 'af';
150
+ processDeepLink({
151
+ deeplink: `${systemConfig.adjustConfig.ONELINK_NO_HTTP_VALUE}?${linkValue}`,
152
+ isAJ: res?.isDeferred,
153
+ });
154
+ AsyncStorage.setItem(APP_FIRST_INIT_ADJUST_KEY, 'true');
155
+ });
156
+ // TODO 可删除
157
+ console.log('appsFlyerappsFlyer---->>>', appsFlyer);
158
+ appsFlyer.initSdk(
159
+ {
160
+ devKey: systemConfig.adjustConfig.devKey,
161
+ isDebug: __DEV__,
162
+ appId: systemConfig.adjustConfig.appId,
163
+ onInstallConversionDataListener: true,
164
+ onDeepLinkListener: true,
165
+ //for iOS 14.5
166
+ timeToWaitForATTUserAuthorization: 10,
167
+ },
168
+ (result) => {
169
+ console.log(result, 'isAllowAttAccessisAllowAttAccessresult');
170
+ },
171
+ (error) => {
172
+ console.error(error, 'isAllowAttAccessisAllowAttAccesserror');
173
+ }
174
+ );
175
+ // 或者9秒之后设置为true
176
+ setTimeout(
177
+ () => {
178
+ AsyncStorage.setItem(APP_FIRST_INIT_ADJUST_KEY, 'true');
179
+ },
180
+ Number(systemConfig.adjustConfig.ADJUST_MAX_DELAY_TIME) + 1000
181
+ );
182
+ // 监听 已经启动,但是被h5换起来了会触发这个方法
183
+ Linking.addEventListener('url', ({ url }) => {
184
+ processDeepLink({ deeplink: url });
185
+ });
186
+ Linking.getInitialURL().then((url) => {
187
+ // 冷启动的时候,会触发这个
188
+ if (url) {
189
+ processDeepLink({ deeplink: url });
190
+ }
191
+ });
192
+ }, [
193
+ setSchemeDeepLinkParamsAtom,
194
+ setIsFirstInitAfSuccessAtom,
195
+ isAllowAttAccess,
196
+ ]);
197
+
198
+ useEffect(() => {
199
+ if (!isConnected) {
200
+ return;
201
+ }
202
+ const timeout = setTimeout(async () => {
203
+ if ((await AsyncStorage.getItem(APP_FIRST_INIT_ADJUST_KEY)) !== 'true') {
204
+ await handlePasteboardInfo();
205
+ }
206
+ setIsFirstInitAfSuccessAtom(true);
207
+ }, Number(systemConfig.adjustConfig.ADJUST_MAX_DELAY_TIME));
208
+ return () => {
209
+ clearTimeout(timeout);
210
+ };
211
+ }, [isConnected]);
212
+ };
213
+ export default useInitAfInfo;
@@ -0,0 +1,12 @@
1
+ export const REQUEST_METHODS = {
2
+ GET: 'GET',
3
+ POST: 'POST',
4
+ PUT: 'PUT',
5
+ DELETE: 'DELETE',
6
+ };
7
+
8
+ export const CONTENT_TYPE = {
9
+ JSON: 'application/json;charset=UTF-8',
10
+ FORM_URLENCODED: 'application/x-www-form-urlencoded;charset=UTF-8',
11
+ FORM_DATA: 'multipart/form-data;charset=UTF-8',
12
+ };
@@ -0,0 +1,99 @@
1
+ import { Platform } from 'react-native';
2
+
3
+ import axios, {
4
+ AxiosInstance,
5
+ AxiosRequestConfig,
6
+ AxiosResponse,
7
+ InternalAxiosRequestConfig,
8
+ } from 'axios';
9
+
10
+ import { CONTENT_TYPE } from './constants';
11
+ import { CustomRequestConfig } from './type';
12
+ import { getConfig } from '../../config';
13
+
14
+
15
+ const createAxiosInstance = (): AxiosInstance => {
16
+ const systemConfig = getConfig();
17
+ const instance = axios.create({
18
+ baseURL: systemConfig.header.apiUrl,
19
+ timeout: 10000,
20
+ headers: {
21
+ 'Content-Type': CONTENT_TYPE.JSON,
22
+ },
23
+ }) as AxiosInstance;
24
+
25
+ instance.interceptors.request.use(
26
+ (config: InternalAxiosRequestConfig<CustomRequestConfig>) => {
27
+ const mergedConfig = { ...config };
28
+ mergedConfig.headers = mergedConfig.headers || {};
29
+
30
+ if (global.userToken) {
31
+ mergedConfig.headers.Authorization = global.userToken;
32
+ }
33
+
34
+ mergedConfig.headers.TYPE = Platform.OS;
35
+ mergedConfig.headers.NID = systemConfig.header.appId;
36
+ mergedConfig.headers.PACKAGENAME = systemConfig.header.PACKAGENAME;
37
+
38
+ if (!global.userToken && global.userId) {
39
+ mergedConfig.headers.UID = global.userId;
40
+ }
41
+
42
+ return mergedConfig;
43
+ }
44
+ );
45
+
46
+ instance.interceptors.response.use(
47
+ (response: AxiosResponse<any>) => {
48
+ if (response.data.code === 200) {
49
+ return response.data;
50
+ }
51
+
52
+ // FIXME: Fix me the types
53
+ return response.data as Promise<AxiosResponse<any>>;
54
+ },
55
+ (error) => {
56
+ if (error.response) {
57
+ return Promise.reject(
58
+ error.response.data || { message: 'Unknown server error' }
59
+ );
60
+ } else if (error.request) {
61
+ return Promise.reject({ message: 'No response received from server' });
62
+ } else {
63
+ return Promise.reject({
64
+ message: error.message || 'Unknown error occurred',
65
+ });
66
+ }
67
+ }
68
+ );
69
+
70
+ return instance;
71
+ };
72
+
73
+ const axiosInstance = createAxiosInstance();
74
+
75
+ export const axiosGet = <T = any>(
76
+ url: string,
77
+ params?: unknown,
78
+ config?: AxiosRequestConfig
79
+ ) => {
80
+ return axiosInstance.get<T>(url, { params, ...config });
81
+ };
82
+
83
+ export const axiosPost = <T = any>(
84
+ url: string,
85
+ data?: unknown,
86
+ config?: AxiosRequestConfig
87
+ ) => {
88
+ return axiosInstance.post<T>(url, data, config);
89
+ };
90
+
91
+ export const axiosPostFormData = <T = any>(
92
+ url: string,
93
+ data?: unknown | FormData,
94
+ config?: AxiosRequestConfig
95
+ ) => {
96
+ return axiosInstance.post<T>(url, data, config);
97
+ };
98
+
99
+ export default axiosInstance;
@@ -0,0 +1,24 @@
1
+ import { type AxiosRequestConfig } from 'axios';
2
+
3
+ export type ApiResponse<T = unknown> = {
4
+ code: number;
5
+ data: T;
6
+ message: string;
7
+ msg: string;
8
+ };
9
+
10
+ export type ApiError = Error & {
11
+ code?: number;
12
+ config: AxiosRequestConfig;
13
+ isAxiosError: boolean;
14
+ };
15
+
16
+ export type CustomRequestConfig = AxiosRequestConfig & {
17
+ headers: {
18
+ TYPE?: string;
19
+ NID?: number;
20
+ PACKAGENAME?: string;
21
+ UID?: string;
22
+ Authorization?: string;
23
+ };
24
+ };
@@ -0,0 +1,100 @@
1
+ import React, { PropsWithChildren, useEffect, useMemo, useRef } from 'react';
2
+ import { Platform, View } from 'react-native';
3
+ import { createJsbridge } from '@tianzhitong/js-bridge';
4
+ import WebView from '../../components/webview';
5
+ import useGetUserToken from '../../hooks/useGetUserToken';
6
+ import { useAtom, useAtomValue } from 'jotai';
7
+ import {
8
+ bPackageWebviewLoadingFinishAtom,
9
+ MiddleScreenLoadingFinishAtom,
10
+ schemeDeepLinkParamsAtom,
11
+ } from '../../atoms/global';
12
+ import MiddleScreen from '../middle';
13
+ import useAppGetUID from '../../hooks/useAppGetUID';
14
+ import useInitAfInfo from '../../hooks/useInitAfInfo';
15
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
16
+ import { getConfig } from '../../../config';
17
+
18
+
19
+ const Home = () => {
20
+ const safeAreaInsets = useSafeAreaInsets();
21
+ const systemConfig = getConfig();
22
+ const { top, bottom } = safeAreaInsets;
23
+ const webRef = useRef<any>(null);
24
+ const middleScreenLoadingFinish = useAtomValue(MiddleScreenLoadingFinishAtom);
25
+ const [bPackageWebviewLoadingFinish, setBPackageWebviewLoadingFinish] =
26
+ useAtom(bPackageWebviewLoadingFinishAtom);
27
+
28
+ const schemeDeepLinkParams = useAtomValue(schemeDeepLinkParamsAtom);
29
+
30
+ const jsbridge = useMemo(() => {
31
+ return createJsbridge({ getWebViewRef: () => webRef });
32
+ }, []);
33
+
34
+ useEffect(() => {
35
+ if (!(bPackageWebviewLoadingFinish && middleScreenLoadingFinish)) {
36
+ return;
37
+ }
38
+ if (schemeDeepLinkParams.pageName) {
39
+ jsbridge.postMessage({
40
+ type: 'SEND_H5_PARAMS',
41
+ payload: schemeDeepLinkParams,
42
+ });
43
+ }
44
+ }, [schemeDeepLinkParams, bPackageWebviewLoadingFinish,middleScreenLoadingFinish, jsbridge]);
45
+
46
+ useGetUserToken(jsbridge);
47
+
48
+ return (
49
+ <View
50
+ style={{
51
+ flex: 1,
52
+ opacity:
53
+ bPackageWebviewLoadingFinish && middleScreenLoadingFinish ? 1 : 0,
54
+ }}
55
+ >
56
+ <WebView
57
+ ref={webRef}
58
+ source={{
59
+ uri: `${systemConfig.webviewUrl}?platform=${Platform.OS
60
+ }&app_version=${'1.1.1'}&user_id=${global.GLOBAL_USER_UID
61
+ }&top=${top}&bottom=${bottom}`,
62
+ }}
63
+ onInvokeMessage={() => { }}
64
+ onLoadEnd={() => {
65
+ console.log('onLoadEnd');
66
+ setBPackageWebviewLoadingFinish(true);
67
+ }}
68
+ />
69
+ </View>
70
+ );
71
+ };
72
+
73
+
74
+ const ProviderBPackageIndex = (props: PropsWithChildren) => {
75
+ const {
76
+ children,
77
+ } = props;
78
+ const { isLoading,isAPackage, } = useAppGetUID();
79
+ const middleScreenLoadingFinish = useAtomValue(MiddleScreenLoadingFinishAtom);
80
+ const schemeDeepLinkParams = useAtomValue(schemeDeepLinkParamsAtom);
81
+ console.log('schemeDeepLinkParams',schemeDeepLinkParams)
82
+ useInitAfInfo();
83
+
84
+ if (!isLoading) {
85
+ return null;
86
+ }
87
+ console.log('isAPackage',isAPackage)
88
+ if (isAPackage) {
89
+ return children;
90
+ }
91
+ console.log('middleScreenLoadingFinish',middleScreenLoadingFinish)
92
+ return (
93
+ <View style={{ flex: 1 }}>
94
+ {!middleScreenLoadingFinish && <MiddleScreen />}
95
+ <Home />
96
+ </View>
97
+ );
98
+ };
99
+
100
+ export default ProviderBPackageIndex;
@@ -0,0 +1,152 @@
1
+ import React, { useState, useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
2
+ import { View, Text, StyleSheet, Animated, Easing } from 'react-native';
3
+ import { rwd } from '../../../utils/rwd';
4
+
5
+ const CustomProgressBar = forwardRef<any, any>(
6
+ (
7
+ {
8
+ duration = 5000,
9
+ height = rwd(10),
10
+ backgroundColor = '#e0e0e0',
11
+ fillColor = '#4CAF50',
12
+ showPercentage = true,
13
+ borderRadius = 10,
14
+ textStyle = {},
15
+ containerStyle = {},
16
+ onComplete = () => {},
17
+ },
18
+ ref,
19
+ ) => {
20
+ const progress = useState(new Animated.Value(0))[0];
21
+ const [currentProgress, setCurrentProgress] = useState(0);
22
+ const animationRef = useRef<Animated.CompositeAnimation | null>(null);
23
+
24
+ let listenerId = useRef<string>('');
25
+
26
+ const animateTo = (value: number, callback?: () => void) => {
27
+ // Stop any ongoing animation
28
+ if (animationRef.current) {
29
+ animationRef.current.stop();
30
+ }
31
+
32
+ // Calculate remaining duration proportionally
33
+ const remainingDuration = duration * ((100 - currentProgress) / 100);
34
+
35
+ animationRef.current = Animated.timing(progress, {
36
+ toValue: value,
37
+ duration: remainingDuration,
38
+ easing: Easing.linear,
39
+ useNativeDriver: false,
40
+ });
41
+
42
+ animationRef.current.start(() => {
43
+ if (value === 100 && callback) {
44
+ callback();
45
+ }
46
+ });
47
+ };
48
+
49
+ useEffect(() => {
50
+ // Add listener to animation value
51
+ listenerId.current = progress.addListener(({ value }) => {
52
+ setCurrentProgress(Math.floor(value));
53
+ });
54
+
55
+ // Start initial animation
56
+ animateTo(100, onComplete);
57
+
58
+ // Clean up listener
59
+ return () => {
60
+ progress.removeListener(listenerId.current);
61
+ if (animationRef.current) {
62
+ animationRef.current.stop();
63
+ }
64
+ };
65
+ }, [duration]);
66
+
67
+ useImperativeHandle(
68
+ ref,
69
+ () => ({
70
+ completeProgress: () => {
71
+ // Stop current animation and jump to 100%
72
+ if (animationRef.current) {
73
+ animationRef.current.stop();
74
+ }
75
+ progress.setValue(100);
76
+ setCurrentProgress(100);
77
+ onComplete();
78
+ },
79
+ setProgress: (value: number) => {
80
+ // Set to specific value (0-100)
81
+ const clampedValue = Math.min(100, Math.max(0, value));
82
+ if (animationRef.current) {
83
+ animationRef.current.stop();
84
+ }
85
+ progress.setValue(clampedValue);
86
+ setCurrentProgress(clampedValue);
87
+ if (clampedValue === 100) {
88
+ onComplete();
89
+ }
90
+ },
91
+ startAnimation: () => {
92
+ // Restart animation from current position
93
+ animateTo(100, onComplete);
94
+ },
95
+ }),
96
+ [progress, currentProgress, onComplete],
97
+ );
98
+
99
+ const widthInterpolation = progress.interpolate({
100
+ inputRange: [0, 100],
101
+ outputRange: ['0%', '100%'],
102
+ });
103
+
104
+ return (
105
+ <View style={[styles.container, containerStyle]}>
106
+ <View
107
+ style={[
108
+ styles.progressBar,
109
+ {
110
+ height,
111
+ backgroundColor,
112
+ borderRadius,
113
+ },
114
+ ]}
115
+ >
116
+ <Animated.View
117
+ style={[
118
+ styles.progressFill,
119
+ {
120
+ width: widthInterpolation,
121
+ backgroundColor: fillColor,
122
+ borderRadius,
123
+ },
124
+ ]}
125
+ />
126
+ </View>
127
+
128
+ {showPercentage && <Text style={[styles.progressText, textStyle]}>{currentProgress}%</Text>}
129
+ </View>
130
+ );
131
+ },
132
+ );
133
+
134
+ const styles = StyleSheet.create({
135
+ container: {
136
+ width: '100%',
137
+ padding: rwd(20),
138
+ },
139
+ progressBar: {
140
+ overflow: 'hidden',
141
+ },
142
+ progressFill: {
143
+ height: '100%',
144
+ },
145
+ progressText: {
146
+ marginTop: rwd(8),
147
+ textAlign: 'center',
148
+ fontSize: rwd(16),
149
+ },
150
+ });
151
+
152
+ export default CustomProgressBar;
@@ -0,0 +1,94 @@
1
+ import { useAtomValue, useSetAtom } from 'jotai';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import { Image, StatusBar, Text, View } from 'react-native';
4
+ import CustomProgressBar from './components/CustomProgressBar';
5
+ import {
6
+ bPackageWebviewLoadingFinishAtom,
7
+ isFirstInitAfSuccessAtom,
8
+ MiddleScreenLoadingFinishAtom,
9
+ schemeDeepLinkParamsAtom,
10
+ } from '../../atoms/global';
11
+ import { rwd } from '../../utils/rwd';
12
+ import { getConfig } from '../../../config';
13
+
14
+
15
+ const MiddleScreen = () => {
16
+ const systemConfig = getConfig();
17
+ const progressRef = useRef<any>(null);
18
+ /** 深度链接是否成功 */
19
+ const isFirstInitAfSuccess = useAtomValue(isFirstInitAfSuccessAtom);
20
+ /** b包webview是否加载完成 */
21
+ const bPackageWebviewLoadingFinish = useAtomValue(
22
+ bPackageWebviewLoadingFinishAtom
23
+ );
24
+ /** 100%动画是否执行完毕 */
25
+ const setIsAnimationSuccess = useSetAtom(MiddleScreenLoadingFinishAtom);
26
+
27
+ const [isLoading, setIsLoading] = useState(false);
28
+
29
+ useEffect(() => {
30
+ // 深度链接成功,等于成功一半,无需走进度条
31
+ if (isFirstInitAfSuccess) {
32
+ setIsLoading(true);
33
+ }
34
+ }, [isFirstInitAfSuccess]);
35
+
36
+ useEffect(() => {
37
+ if (bPackageWebviewLoadingFinish && isLoading) {
38
+ progressRef.current?.completeProgress();
39
+ setIsAnimationSuccess(true);
40
+ }
41
+ }, [isLoading, bPackageWebviewLoadingFinish, setIsAnimationSuccess]);
42
+
43
+ return (
44
+ <View style={{ width: '100%', height: '100%' }}>
45
+ <StatusBar
46
+ translucent={true}
47
+ barStyle="light-content"
48
+ backgroundColor="transparent"
49
+ />
50
+ <View style={{ flex: 1, backgroundColor: '#12141D', paddingTop: '50%' }}>
51
+ <View style={{ justifyContent: 'center', alignItems: 'center' }}>
52
+ <Image
53
+ source={{ uri: systemConfig.adjustConfig.bgImage }}
54
+ style={{ width: rwd(170), height: rwd(170) }}
55
+ />
56
+ <Text
57
+ style={{
58
+ color: '#fff',
59
+ fontSize: rwd(34),
60
+ fontWeight: 600,
61
+ marginTop: rwd(50),
62
+ }}
63
+ >
64
+ {systemConfig.adjustConfig.appName}
65
+ </Text>
66
+ </View>
67
+ <View style={{ position: 'absolute', bottom: '20%', width: '100%' }}>
68
+ <CustomProgressBar
69
+ ref={progressRef}
70
+ duration={8000}
71
+ fillColor="#3498db" // 蓝色进度条
72
+ textStyle={{ color: '#3498db', fontWeight: 'bold' }} // 蓝色文字
73
+ onComplete={() => {
74
+ setIsLoading(true);
75
+ console.log('进度完成!');
76
+ }}
77
+ />
78
+ <Text
79
+ style={{
80
+ color: '#fff',
81
+ fontSize: rwd(24),
82
+ fontWeight: 600,
83
+ marginTop: rwd(30),
84
+ textAlign: 'center',
85
+ }}
86
+ >
87
+ {systemConfig.adjustConfig.loadingText}
88
+ </Text>
89
+ </View>
90
+ </View>
91
+ </View>
92
+ );
93
+ };
94
+ export default MiddleScreen;