ipanel-rnapp-ajb-base 1.0.0

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.
Files changed (155) hide show
  1. package/app/.local_dev/DemoPage.js +46 -0
  2. package/app/.local_dev/env.js +1 -0
  3. package/app/.local_dev/polyfill.js +83 -0
  4. package/app/App.js +485 -0
  5. package/app/api/homedApi.js +42 -0
  6. package/app/api/index.js +2 -0
  7. package/app/api/ipanelCloudApi.js +796 -0
  8. package/app/assets/img/add.png +0 -0
  9. package/app/assets/img/add_img.png +0 -0
  10. package/app/assets/img/album.png +0 -0
  11. package/app/assets/img/album2.png +0 -0
  12. package/app/assets/img/album3.png +0 -0
  13. package/app/assets/img/album@2x.png +0 -0
  14. package/app/assets/img/album@3x.png +0 -0
  15. package/app/assets/img/audioRecordBar.png +0 -0
  16. package/app/assets/img/bootom_bar_bg.png +0 -0
  17. package/app/assets/img/close.png +0 -0
  18. package/app/assets/img/computer.png +0 -0
  19. package/app/assets/img/confirm.png +0 -0
  20. package/app/assets/img/delete_pic.png +0 -0
  21. package/app/assets/img/disabled.png +0 -0
  22. package/app/assets/img/goBack.png +0 -0
  23. package/app/assets/img/goBack2.png +0 -0
  24. package/app/assets/img/ischeck.png +0 -0
  25. package/app/assets/img/launch_bg.png +0 -0
  26. package/app/assets/img/launch_bg_panyu.png +0 -0
  27. package/app/assets/img/launch_logo.png +0 -0
  28. package/app/assets/img/launch_logo_panyu.png +0 -0
  29. package/app/assets/img/launch_text.png +0 -0
  30. package/app/assets/img/launch_text_panyu.png +0 -0
  31. package/app/assets/img/link.png +0 -0
  32. package/app/assets/img/login_bg.png +0 -0
  33. package/app/assets/img/login_bg_new.png +0 -0
  34. package/app/assets/img/login_left.png +0 -0
  35. package/app/assets/img/login_right.png +0 -0
  36. package/app/assets/img/nocheck.png +0 -0
  37. package/app/assets/img/personal.png +0 -0
  38. package/app/assets/img/photo.png +0 -0
  39. package/app/assets/img/photo@2x.png +0 -0
  40. package/app/assets/img/photo@3x.png +0 -0
  41. package/app/assets/img/protocol_checked.png +0 -0
  42. package/app/assets/img/qiehuan.png +0 -0
  43. package/app/assets/img/scan_border_bottom_left.png +0 -0
  44. package/app/assets/img/scan_border_bottom_right.png +0 -0
  45. package/app/assets/img/scan_border_top_left.png +0 -0
  46. package/app/assets/img/scan_border_top_right.png +0 -0
  47. package/app/assets/img/scan_move.png +0 -0
  48. package/app/assets/img/szjt.png +0 -0
  49. package/app/assets/img/tab.png +0 -0
  50. package/app/assets/img/tykz.png +0 -0
  51. package/app/assets/img/update_bg.png +0 -0
  52. package/app/assets/img/video.png +0 -0
  53. package/app/assets/img/video@2x.png +0 -0
  54. package/app/assets/img/video@3x.png +0 -0
  55. package/app/assets/img/worker.png +0 -0
  56. package/app/assets/img/wx.png +0 -0
  57. package/app/assets/img/ykq.png +0 -0
  58. package/app/assets/img/zfb.png +0 -0
  59. package/app/base.js +342 -0
  60. package/app/components/VersionUpdateConfirm.js +117 -0
  61. package/app/components/common/AccordionCell/index.js +67 -0
  62. package/app/components/common/ActionPicker/BasicPicker.js +136 -0
  63. package/app/components/common/ActionPicker/index.js +106 -0
  64. package/app/components/common/AddressPicker/index.js +211 -0
  65. package/app/components/common/Card/index.js +19 -0
  66. package/app/components/common/Cell/index.js +381 -0
  67. package/app/components/common/CustomDialog/index.js +120 -0
  68. package/app/components/common/CustomTabBar/index.js +157 -0
  69. package/app/components/common/CustomTabBar_bak/TabBarInput.js +210 -0
  70. package/app/components/common/CustomTabBar_bak/index.js +832 -0
  71. package/app/components/common/DateTimingPicker/index.js +254 -0
  72. package/app/components/common/Dialog/Notify.js +36 -0
  73. package/app/components/common/Dialog/baseDialog.js +146 -0
  74. package/app/components/common/Dialog/index.js +113 -0
  75. package/app/components/common/Dialog/prompt.js +145 -0
  76. package/app/components/common/Dialog/quickSelect.js +54 -0
  77. package/app/components/common/Dialog/select.js +125 -0
  78. package/app/components/common/Dialog/styles.js +167 -0
  79. package/app/components/common/Loading/index.js +71 -0
  80. package/app/components/common/LoginType/index.js +171 -0
  81. package/app/components/common/LoginType/protocol.js +160 -0
  82. package/app/components/common/Notify/index.js +68 -0
  83. package/app/components/common/OnceTouchable/index.js +33 -0
  84. package/app/components/common/PaymentPicker/index.js +264 -0
  85. package/app/components/common/ProductOrderPicker/index.js +524 -0
  86. package/app/components/common/ScreenBackHeader/index.js +144 -0
  87. package/app/components/common/ScrollPicker/index.js +232 -0
  88. package/app/components/common/SelectPicker/index.js +171 -0
  89. package/app/components/common/SmsCodeInput/index.js +93 -0
  90. package/app/components/common/SmsCodeInput/indexNew.js +101 -0
  91. package/app/components/common/Steps/index.js +126 -0
  92. package/app/components/common/Tag/index.js +17 -0
  93. package/app/components/common/Toast/index.js +103 -0
  94. package/app/components/common/WeekDaysPicker/index.js +196 -0
  95. package/app/components/index.js +8 -0
  96. package/app/components/iot/AddDeviceActionSheet/index.js +934 -0
  97. package/app/components/iot/AddressActionSheet/index.js +91 -0
  98. package/app/components/iot/RoomActionSheet/index.js +205 -0
  99. package/app/components/iot/ViewDeviceActionSheet/index.js +834 -0
  100. package/app/components/sheets.js +30 -0
  101. package/app/eventBus/index.js +54 -0
  102. package/app/hooks/checkLogin.js +30 -0
  103. package/app/hooks/shopMessageManager.js +308 -0
  104. package/app/hooks/useAddress.js +179 -0
  105. package/app/hooks/useAddress2.js +587 -0
  106. package/app/hooks/useDebounceFn.js +6 -0
  107. package/app/hooks/useDynamicPackages.js +22 -0
  108. package/app/hooks/useKeyboard.js +25 -0
  109. package/app/hooks/useLatest.js +10 -0
  110. package/app/hooks/useMessageManager.js +368 -0
  111. package/app/hooks/useNavigationFocus.js +19 -0
  112. package/app/hooks/useUser.js +56 -0
  113. package/app/screens/BaseScreen.js +389 -0
  114. package/app/screens/CommonScreens/BindPhoneScreen/index.js +179 -0
  115. package/app/screens/CommonScreens/BossScreen/index.js +138 -0
  116. package/app/screens/CommonScreens/DeviceAnswerDetailScreen/index.js +50 -0
  117. package/app/screens/CommonScreens/DeviceFeedbackScreen/index.js +365 -0
  118. package/app/screens/CommonScreens/EditInvoiceTitleScreen/index.js +279 -0
  119. package/app/screens/CommonScreens/FamilyDetailScreen/index.js +421 -0
  120. package/app/screens/CommonScreens/InvoiceTitleListScreen/index.js +118 -0
  121. package/app/screens/CommonScreens/OperatorSelectScreen/index.js +315 -0
  122. package/app/screens/CommonScreens/PersonalScreen/index.js +348 -0
  123. package/app/screens/CommonScreens/ScanQRCodeScreen/index.js +407 -0
  124. package/app/screens/CommonScreens/TvAlbumScreen/index.js +407 -0
  125. package/app/screens/LoginScreen/OpenLogSheet.js +241 -0
  126. package/app/screens/LoginScreen/index.js +920 -0
  127. package/app/screens/LoginScreen/indexNew.js +1354 -0
  128. package/app/screens/ResePassword/index.js +364 -0
  129. package/app/screens/SbkScreen.js +19 -0
  130. package/app/screens/WebviewScreen.js +41 -0
  131. package/app/storage/index.js +166 -0
  132. package/app/utils/EventEmitter.js +43 -0
  133. package/app/utils/RootNavigation.js +32 -0
  134. package/app/utils/SBK_plugin/convert.js +90 -0
  135. package/app/utils/SBK_plugin/convertStatus.js +250 -0
  136. package/app/utils/SBK_plugin/eventProcess.js +339 -0
  137. package/app/utils/SBK_plugin/index.js +32 -0
  138. package/app/utils/SBK_plugin/ipanelDeviceToSbkDevice.js +68 -0
  139. package/app/utils/SBK_plugin/sbk_defs.js +191 -0
  140. package/app/utils/StyleComposite.js +37 -0
  141. package/app/utils/applyPermissions.js +251 -0
  142. package/app/utils/bundleUpdater.js +46 -0
  143. package/app/utils/common.js +380 -0
  144. package/app/utils/config.js +47 -0
  145. package/app/utils/errCodes.js +3 -0
  146. package/app/utils/homedData.js +57 -0
  147. package/app/utils/http.js +178 -0
  148. package/app/utils/notice.js +15 -0
  149. package/app/utils/priceConversion.js +30 -0
  150. package/app/utils/registerDialog.js +90 -0
  151. package/app/utils/scaleSize.js +12 -0
  152. package/app/utils/soundPlayer.js +85 -0
  153. package/bin/local-dev.js +7 -0
  154. package/index.js +8 -0
  155. package/package.json +18 -0
@@ -0,0 +1,254 @@
1
+ import React, {useState} from 'react';
2
+ import {View, Text, StyleSheet, TouchableOpacity} from 'react-native';
3
+ import ActionSheet, {SheetManager} from 'react-native-actions-sheet';
4
+ import {Cell} from '../../index';
5
+
6
+ const minuteSelections = [
7
+ {name: '00'},
8
+ {name: '01'},
9
+ {name: '02'},
10
+ {name: '03'},
11
+ {name: '04'},
12
+ {name: '05'},
13
+ {name: '06'},
14
+ {name: '07'},
15
+ {name: '08'},
16
+ {name: '09'},
17
+ {name: '10'},
18
+ {name: '11'},
19
+ {name: '12'},
20
+ {name: '13'},
21
+ {name: '14'},
22
+ {name: '15'},
23
+ {name: '16'},
24
+ {name: '17'},
25
+ {name: '18'},
26
+ {name: '19'},
27
+ {name: '20'},
28
+ {name: '21'},
29
+ {name: '22'},
30
+ {name: '23'},
31
+ {name: '24'},
32
+ {name: '25'},
33
+ {name: '26'},
34
+ {name: '27'},
35
+ {name: '28'},
36
+ {name: '29'},
37
+ {name: '30'},
38
+ {name: '31'},
39
+ {name: '32'},
40
+ {name: '33'},
41
+ {name: '34'},
42
+ {name: '35'},
43
+ {name: '36'},
44
+ {name: '37'},
45
+ {name: '38'},
46
+ {name: '39'},
47
+ {name: '40'},
48
+ {name: '41'},
49
+ {name: '42'},
50
+ {name: '43'},
51
+ {name: '44'},
52
+ {name: '45'},
53
+ {name: '46'},
54
+ {name: '47'},
55
+ {name: '48'},
56
+ {name: '49'},
57
+ {name: '50'},
58
+ {name: '51'},
59
+ {name: '52'},
60
+ {name: '53'},
61
+ {name: '54'},
62
+ {name: '55'},
63
+ {name: '56'},
64
+ {name: '57'},
65
+ {name: '58'},
66
+ {name: '59'},
67
+ ];
68
+ const hourSelections = [
69
+ {name: '00'},
70
+ {name: '01'},
71
+ {name: '02'},
72
+ {name: '03'},
73
+ {name: '04'},
74
+ {name: '05'},
75
+ {name: '06'},
76
+ {name: '07'},
77
+ {name: '08'},
78
+ {name: '09'},
79
+ {name: '10'},
80
+ {name: '11'},
81
+ {name: '12'},
82
+ {name: '13'},
83
+ {name: '14'},
84
+ {name: '15'},
85
+ {name: '16'},
86
+ {name: '17'},
87
+ {name: '18'},
88
+ {name: '19'},
89
+ {name: '20'},
90
+ {name: '21'},
91
+ {name: '22'},
92
+ {name: '23'},
93
+ ];
94
+ hourSelections.forEach(hour => {
95
+ hour.children = minuteSelections;
96
+ });
97
+
98
+ function clockStr2Stamp(clockStr) {
99
+ const [hours, minutes] = clockStr.split(':').map(str => parseInt(str));
100
+ return hours * 3600 + minutes * 60;
101
+ }
102
+
103
+ const Index = ({sheetId, payload = {}}) => {
104
+ const {title} = payload;
105
+
106
+ const [start, setStart] = useState('00:00');
107
+ const [end, setEnd] = useState('00:00');
108
+ const [dates, setDates] = useState([]);
109
+
110
+ const handleShowStartSelection = async () => {
111
+ const result = await SheetManager.show('action-picker', {
112
+ context: 'global',
113
+ payload: {
114
+ title: '开始时间',
115
+ defaultIndex: [0, 0],
116
+ columns: hourSelections,
117
+ depth: 2,
118
+ },
119
+ });
120
+ if (result) {
121
+ setStart(`${result.data[0].name}:${result.data[1].name}`);
122
+ }
123
+ };
124
+ const handleShowEndSelection = async () => {
125
+ const result = await SheetManager.show('action-picker', {
126
+ context: 'global',
127
+ payload: {
128
+ title: '结束时间',
129
+ defaultIndex: [0, 0],
130
+ columns: hourSelections,
131
+ depth: 2,
132
+ },
133
+ });
134
+ if (result) {
135
+ setEnd(`${result.data[0].name}:${result.data[1].name}`);
136
+ }
137
+ };
138
+ const handleShowDatesSelection = async () => {
139
+ const result = await SheetManager.show('week-days-picker', {
140
+ context: 'global',
141
+ payload: {
142
+ title: '选择周期',
143
+ },
144
+ });
145
+ if (result) {
146
+ setDates(result.dates);
147
+ }
148
+ };
149
+
150
+ const handleCancel = () => {
151
+ SheetManager.hide(sheetId);
152
+ };
153
+
154
+ const handleConfirm = () => {
155
+ if (clockStr2Stamp(end) <= clockStr2Stamp(start)) {
156
+ global.toast.showToast('结束时间必须大于开始时间');
157
+ return;
158
+ }
159
+ if (dates.length === 0) {
160
+ global.toast.showToast('必须选择周期');
161
+ return;
162
+ }
163
+
164
+ SheetManager.hide(sheetId, {
165
+ payload: {
166
+ start,
167
+ end,
168
+ dates,
169
+ },
170
+ });
171
+ };
172
+
173
+ return (
174
+ <>
175
+ <ActionSheet id={sheetId} isModal={false} useBottomSafeAreaPadding>
176
+ <View style={styles.title}>
177
+ <TouchableOpacity
178
+ style={styles.cancelBtnBox}
179
+ activeOpacity={0.3}
180
+ onPress={handleCancel}>
181
+ <Text style={styles.cancnelBtnText}>取消</Text>
182
+ </TouchableOpacity>
183
+ <Text style={styles.titleText}>{title || '设置周期'}</Text>
184
+ <TouchableOpacity
185
+ style={styles.confirmBtnBox}
186
+ activeOpacity={0.3}
187
+ onPress={handleConfirm}>
188
+ <Text style={styles.confirmBtnText}>确定</Text>
189
+ </TouchableOpacity>
190
+ </View>
191
+
192
+ <Cell
193
+ type="link"
194
+ label="开始时间"
195
+ value={start}
196
+ onRightPress={handleShowStartSelection}
197
+ />
198
+ <Cell
199
+ type="link"
200
+ label="结束时间"
201
+ value={end}
202
+ onRightPress={handleShowEndSelection}
203
+ />
204
+ <Cell
205
+ type="link"
206
+ label="周期"
207
+ value={dates.map(item => item.name).join('、')}
208
+ onRightPress={handleShowDatesSelection}
209
+ />
210
+ </ActionSheet>
211
+ </>
212
+ );
213
+ };
214
+
215
+ const styles = StyleSheet.create({
216
+ title: {
217
+ position: 'relative',
218
+ height: 50,
219
+ paddingHorizontal: 60,
220
+ alignItems: 'center',
221
+ justifyContent: 'center',
222
+ },
223
+ titleText: {
224
+ fontSize: 18,
225
+ color: '#333',
226
+ },
227
+ cancelBtnBox: {
228
+ position: 'absolute',
229
+ height: '100%',
230
+ top: 0,
231
+ left: 0,
232
+ width: 60,
233
+ alignItems: 'center',
234
+ justifyContent: 'center',
235
+ },
236
+ confirmBtnBox: {
237
+ position: 'absolute',
238
+ height: '100%',
239
+ top: 0,
240
+ right: 0,
241
+ width: 60,
242
+ alignItems: 'center',
243
+ justifyContent: 'center',
244
+ },
245
+ cancnelBtnText: {
246
+ fontSize: 18,
247
+ },
248
+ confirmBtnText: {
249
+ fontSize: 18,
250
+ color: '#2089dc',
251
+ },
252
+ });
253
+
254
+ export default Index;
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import {View, StyleSheet, Text} from 'react-native';
3
+ import px from '../../../utils/scaleSize';
4
+
5
+ export default ({options}) => {
6
+ return (
7
+ <View style={styles.notifyContainer}>
8
+ <Text style={styles.title}>{options?.title}</Text>
9
+ <Text style={styles.content}>{options?.content}</Text>
10
+ </View>
11
+ );
12
+ };
13
+
14
+ const styles = StyleSheet.create({
15
+ notifyContainer: {
16
+ position: 'absolute',
17
+ top: px(29),
18
+ left: px(40),
19
+ right: px(40),
20
+ borderRadius: px(17),
21
+ backgroundColor: '#fff',
22
+ paddingHorizontal: px(40),
23
+ paddingVertical: px(69),
24
+ },
25
+ title: {
26
+ fontWeight: '600',
27
+ color: '#333',
28
+ fontSize: px(46),
29
+ marginBottom: px(29),
30
+ },
31
+ content: {
32
+ fontSize: px(40),
33
+ color: '#333',
34
+ fontWeight: '400',
35
+ },
36
+ });
@@ -0,0 +1,146 @@
1
+ import React, {useEffect, useRef, useState} from 'react';
2
+ import {Text, View, TouchableHighlight} from 'react-native';
3
+ import styles from './styles';
4
+ import useLatest from '../../../hooks/useLatest';
5
+
6
+ import {Divider} from '@rneui/themed';
7
+
8
+ let timer = null;
9
+
10
+ const BaseDialog = ({modelRef, setModalVisible, type}) => {
11
+ // confirm组件和custom组件
12
+
13
+ // confirm组件component传string
14
+ /*
15
+ component: Template | string (主要内容区)必选
16
+ confirmButtonText: string, (右边按钮文字)必选
17
+ confirmCallback: (value) => { (右边触发事件)必选
18
+ console.log(111, value)
19
+ },
20
+ confirmButtonStyle: {}, (右边按钮样式)可选
21
+ cancelButtonText: string, (左边按钮文字)可选
22
+ cancelCallback: () => {}, (左边触发事件)可选
23
+ title: string, (标题)可选
24
+ titleStyle: { (标题样式)可选
25
+ textAlign: 'left',
26
+ borderBottomColor: '#eee',
27
+ borderBottomWidth: 1,
28
+ },
29
+ */
30
+
31
+ const [timeCount, setTimeCount] = useState(modelRef?.timeout || 0);
32
+ const latestTimeCount = useLatest(timeCount);
33
+
34
+ useEffect(() => {
35
+ if (modelRef?.timeout) {
36
+ timer = setInterval(() => {
37
+ if (latestTimeCount.current === 0) {
38
+ onConfirm();
39
+ } else {
40
+ setTimeCount(latestTimeCount.current - 1);
41
+ }
42
+ }, 1000);
43
+ }
44
+
45
+ return () => {
46
+ clearInterval(timer);
47
+ };
48
+ }, []);
49
+
50
+ const autoClose =
51
+ typeof modelRef?.autoClose === 'undefined' ? true : modelRef?.autoClose;
52
+
53
+ // modelRef?.content;
54
+ const component = useRef(modelRef?.component);
55
+ const onCannel = () => {
56
+ modelRef?.cancelCallback();
57
+ setModalVisible(false);
58
+ };
59
+ const onConfirm = async () => {
60
+ clearInterval(timer);
61
+ if (autoClose) {
62
+ modelRef?.confirmCallback();
63
+ setModalVisible(false);
64
+ } else if (await modelRef?.confirmCallback()) {
65
+ setModalVisible(false);
66
+ }
67
+ };
68
+ return (
69
+ <View
70
+ style={{
71
+ ...styles.contentView,
72
+ paddingHorizontal: 0,
73
+ alignItems: component.current ? 'stretch' : 'center',
74
+ ...(modelRef.containerStyle || {}),
75
+ }}>
76
+ {!!modelRef?.title && (
77
+ <View style={[styles.title, modelRef?.titleBoxStyle]}>
78
+ <Text style={[styles.titleText, modelRef?.titleStyle]}>
79
+ {modelRef?.title}
80
+ </Text>
81
+ </View>
82
+ )}
83
+ {/* 内容区 */}
84
+ {typeof modelRef?.component === 'string' ? (
85
+ <View style={[modelRef?.contentStyle]}>
86
+ <Text style={[{textAlign: 'center'}, modelRef?.contentTextStyle]}>
87
+ {modelRef?.component}
88
+ </Text>
89
+ </View>
90
+ ) : (
91
+ modelRef?.component
92
+ )}
93
+ <Divider color="#f0f0f0" />
94
+ {/* 底部按钮 */}
95
+ <View style={styles.bottomContent}>
96
+ {modelRef?.cancelButtonText && (
97
+ <TouchableHighlight
98
+ activeOpacity={0.6}
99
+ underlayColor="#DDDDDD"
100
+ style={[styles.cancelStyle, styles.buttonStyle]}
101
+ onPress={() => {
102
+ onCannel();
103
+ }}>
104
+ <Text style={styles.cancelTextStyle}>
105
+ {modelRef?.cancelButtonText}
106
+ </Text>
107
+ </TouchableHighlight>
108
+ )}
109
+ <TouchableHighlight
110
+ activeOpacity={0.6}
111
+ underlayColor="#DDDDDD"
112
+ style={[
113
+ styles.confirmStyle,
114
+ styles.buttonStyle,
115
+ !modelRef.cancelButtonText && styles.confirmOneStyle,
116
+ ]}
117
+ onPress={() => {
118
+ onConfirm();
119
+ }}>
120
+ <Text style={[styles.confirmTextStyle, modelRef?.confirmButtonStyle]}>
121
+ {modelRef?.confirmButtonText}
122
+ {modelRef?.timeout ? `(${timeCount}s)` : ''}
123
+ </Text>
124
+ </TouchableHighlight>
125
+ </View>
126
+ </View>
127
+ );
128
+ };
129
+
130
+ const Confirm = ({content}) => {
131
+ return (
132
+ <View style={styles.modalContent}>
133
+ <Text style={styles.confirmText}>{content}</Text>
134
+ </View>
135
+ );
136
+ };
137
+
138
+ const CustomComponent = ({component, modelRef}) => {
139
+ return (
140
+ <View style={[styles.modalContent, modelRef?.contentStyle]}>
141
+ {typeof component === 'string' ? <Text>{component}</Text> : component}
142
+ </View>
143
+ );
144
+ };
145
+
146
+ export default BaseDialog;
@@ -0,0 +1,113 @@
1
+ import React, {useImperativeHandle, useState, useRef} from 'react';
2
+ import {View, Modal, TouchableOpacity} from 'react-native';
3
+
4
+ import Prompt from './prompt';
5
+ import SelectDialog from './select';
6
+ import BaseDialog from './baseDialog';
7
+ import QuickSelect from './quickSelect';
8
+ import Notify from './Notify';
9
+
10
+ import styles from './styles';
11
+ const Index = ({steps, active, onRef}) => {
12
+ const [modalVisible, setModalVisible] = useState(false);
13
+ const modelRef = useRef(null);
14
+ const [type, setType] = useState('confirm');
15
+ useImperativeHandle(onRef, () => {
16
+ return {
17
+ hideDialog: () => {
18
+ setModalVisible(false);
19
+ },
20
+ /**
21
+ * 基础弹框参数
22
+ * @param args Object
23
+ *
24
+ */
25
+ // 基本弹框
26
+ confirm: args => {
27
+ modelRef.current = args;
28
+ setModalVisible(true);
29
+ setType('confirm');
30
+ },
31
+ // 输入框
32
+ prompt: args => {
33
+ modelRef.current = args;
34
+ setType('prompt');
35
+ setModalVisible(true);
36
+ },
37
+ // 可选择
38
+ select: args => {
39
+ modelRef.current = args;
40
+ setModalVisible(true);
41
+ setType('select');
42
+ },
43
+ quickSelect: args => {
44
+ modelRef.current = args;
45
+ setModalVisible(true);
46
+ setType('quickSelect');
47
+ },
48
+ custom: args => {
49
+ modelRef.current = args;
50
+ setModalVisible(true);
51
+ setType('custom');
52
+ },
53
+ notify: args => {
54
+ modelRef.current = args;
55
+ setModalVisible(true);
56
+ setType('notify');
57
+ },
58
+ };
59
+ });
60
+
61
+ return (
62
+ modalVisible && (
63
+ <View style={styles.backgroundView}>
64
+ <Modal
65
+ animationType="fade"
66
+ transparent={true}
67
+ visible={modalVisible}
68
+ onRequestClose={() => {
69
+ setModalVisible(!modalVisible);
70
+ }}>
71
+ <TouchableOpacity
72
+ style={styles.centeredView}
73
+ activeOpacity={1}
74
+ onPress={() => {
75
+ if (type === 'quickSelect') {
76
+ setModalVisible(!modalVisible);
77
+ }
78
+ }}>
79
+ {type === 'prompt' ? (
80
+ <Prompt
81
+ modelRef={modelRef.current}
82
+ setModalVisible={setModalVisible}
83
+ />
84
+ ) : type === 'select' ? (
85
+ <SelectDialog
86
+ modelRef={modelRef.current}
87
+ setModalVisible={setModalVisible}
88
+ />
89
+ ) : type === 'quickSelect' ? (
90
+ <QuickSelect
91
+ modelRef={modelRef.current}
92
+ setModalVisible={setModalVisible}
93
+ />
94
+ ) : type === 'notify' ? (
95
+ <Notify
96
+ options={modelRef.current}
97
+ setModalVisible={setModalVisible}
98
+ />
99
+ ) : (
100
+ <BaseDialog
101
+ modelRef={modelRef.current}
102
+ setModalVisible={setModalVisible}
103
+ type={type}
104
+ />
105
+ )}
106
+ </TouchableOpacity>
107
+ </Modal>
108
+ </View>
109
+ )
110
+ );
111
+ };
112
+
113
+ export default Index;
@@ -0,0 +1,145 @@
1
+ import React, {useState, useRef, useEffect} from 'react';
2
+ import {Text, View, TouchableHighlight, TextInput} from 'react-native';
3
+ import {Input} from '@rneui/themed';
4
+ import styles from './styles';
5
+ const px = global.base.scaleSize;
6
+ const Prompt = ({modelRef, setModalVisible}) => {
7
+ /*
8
+ input: String (input内容)可选
9
+ confirmButtonText: string, (右边按钮文字)必选
10
+ confirmCallback: (value) => { (右边触发事件)必选
11
+ console.log(111, value)
12
+ },
13
+ cancelButtonText: string, (左边按钮文字)必选
14
+ cancelCallback: () => {}, (左边触发事件)可选
15
+ confirmButtonStyle: {}, (右边按钮样式)可选
16
+ title: string, (标题)可选
17
+ titleStyle: { (标题样式)可选
18
+ textAlign: 'left',
19
+ borderBottomColor: '#eee',
20
+ borderBottomWidth: 1,
21
+ },
22
+ */
23
+ const [input, setInput] = useState(modelRef.input || '');
24
+ const inputRef = useRef();
25
+ const autoClose =
26
+ typeof modelRef?.autoClose === 'undefined' ? true : modelRef?.autoClose;
27
+
28
+ const onCannel = () => {
29
+ if (modelRef?.cancelCallback) {
30
+ modelRef?.cancelCallback(input);
31
+ }
32
+ setModalVisible(false);
33
+ };
34
+ const onConfirm = async () => {
35
+ if (autoClose) {
36
+ modelRef?.confirmCallback(input);
37
+ setModalVisible(false);
38
+ } else if (await modelRef?.confirmCallback(input)) {
39
+ setModalVisible(false);
40
+ }
41
+ };
42
+ useEffect(() => {
43
+ if (modelRef?.autoFocus && inputRef.current) {
44
+ setTimeout(() => {
45
+ inputRef.current.focus();
46
+ // inputRef.current.setNativeProps({selection: {start: 9999, end: 9999}});
47
+ }, 100);
48
+ // input.current.setNativeProps({value: input});
49
+ }
50
+ }, []);
51
+
52
+ return (
53
+ <View style={[styles.contentView, modelRef?.containerStyle]}>
54
+ {/* 标题 */}
55
+ <View
56
+ style={[
57
+ {
58
+ paddingBottom: px(40),
59
+ },
60
+ modelRef?.titleBoxStyle,
61
+ ]}>
62
+ {typeof modelRef?.title === 'string' ? (
63
+ <Text style={[styles.titleText, modelRef?.titleStyle]}>
64
+ {modelRef?.title}
65
+ </Text>
66
+ ) : (
67
+ modelRef?.title
68
+ )}
69
+ </View>
70
+ {/* 内容区 */}
71
+ <View style={[styles.confirmModalContent, modelRef?.modalContentStyle]}>
72
+ {/*<TextInput*/}
73
+ {/* style={{*/}
74
+ {/* height: px(80),*/}
75
+ {/* }}*/}
76
+ {/* keyboardType={modelRef?.keyboardType}*/}
77
+ {/* onChangeText={text => setInput(text)}*/}
78
+ {/* value={input}*/}
79
+ {/*/>*/}
80
+ <Input
81
+ ref={inputRef}
82
+ value={input}
83
+ autoFocus={!!modelRef?.autoFocus}
84
+ onChangeText={setInput}
85
+ keyboardType={modelRef?.keyboardType}
86
+ leftIcon={modelRef?.leftIcon}
87
+ containerStyle={{
88
+ height: 31,
89
+ padding: 0,
90
+ borderWidth: 0,
91
+ borderRadius: 17,
92
+ backgroundColor: '#fff',
93
+ paddingHorizontal: px(92),
94
+ }}
95
+ inputContainerStyle={{
96
+ height: '100%',
97
+ width: '100%',
98
+ padding: 0,
99
+ margin: 0,
100
+ borderBottomWidth: 1,
101
+ borderColor: '#E86003',
102
+ }}
103
+ inputStyle={[
104
+ {
105
+ fontSize: px(46),
106
+ color: '#666',
107
+ textAlign: 'center',
108
+ },
109
+ modelRef?.inputStyle,
110
+ ]}
111
+ />
112
+ <Text style={[styles.tip, modelRef?.tipStyle]}>
113
+ {modelRef?.tip || ''}
114
+ </Text>
115
+ </View>
116
+ {/* 底部按钮 */}
117
+ <View style={styles.bottomContent}>
118
+ <TouchableHighlight
119
+ activeOpacity={0.6}
120
+ underlayColor="#DDDDDD"
121
+ style={[styles.cancelStyle, styles.buttonStyle]}
122
+ onPress={() => {
123
+ onCannel();
124
+ }}>
125
+ <Text style={styles.cancelTextStyle}>
126
+ {modelRef?.cancelButtonText}
127
+ </Text>
128
+ </TouchableHighlight>
129
+ <TouchableHighlight
130
+ activeOpacity={0.6}
131
+ underlayColor="#DDDDDD"
132
+ style={[styles.confirmStyle, styles.buttonStyle]}
133
+ onPress={() => {
134
+ onConfirm();
135
+ }}>
136
+ <Text style={[styles.confirmTextStyle, modelRef?.confirmButtonStyle]}>
137
+ {modelRef?.confirmButtonText}
138
+ </Text>
139
+ </TouchableHighlight>
140
+ </View>
141
+ </View>
142
+ );
143
+ };
144
+
145
+ export default Prompt;