ipanel-rnapp-ajb-base 1.0.15 → 1.0.16

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.
package/app/App.js CHANGED
@@ -35,6 +35,7 @@ import Loading from './components/common/Loading';
35
35
  import Toast from './components/common/Toast';
36
36
  import Dialog from './components/common/Dialog';
37
37
  import Notify from './components/common/Notify';
38
+ import SheetManage from './components/common/SheetManage';
38
39
  import storage from './storage';
39
40
 
40
41
  import {navigationRef} from './utils/RootNavigation';
@@ -439,6 +440,7 @@ const App = () => {
439
440
  <Toast onRef={ref => (global.toast = ref)} />
440
441
  <Notify onRef={ref => (global.notify = ref)} />
441
442
  <Dialog onRef={ref => (global.dialog = ref)} />
443
+ <SheetManage onRef={ref => (global.sheetManager = ref)} />
442
444
  {versionUpdateConfirmVisible && (
443
445
  <VersionUpdateConfirm
444
446
  onVisibleChange={setVersionUpdateConfirmVisible}
@@ -1,11 +1,15 @@
1
- import React,{useState} from 'react';
1
+ import React,{useEffect, useState} from 'react';
2
2
  import {View, Text, StyleSheet} from 'react-native';
3
3
  import Picker from '../PickerV2Base/picker';
4
4
  import px from '../../../utils/scaleSize';
5
+ import {
6
+ useAnimatedStyle,
7
+ withSpring,
8
+ } from 'react-native-reanimated';
5
9
  const pickerStyles = {
6
- okView:{borderLeftColor:'#F0F0F0',borderLeftWidth:1},
10
+ okView:{borderLeftColor:'#F0F0F0',borderLeftWidth:1},
7
11
  okText: {color: '#E86003',width:px(500)},
8
- dismissText: {color: '#666666',width:px(500),},
12
+ dismissText: {color: '#666',width:px(500),},
9
13
  container:{borderTopLeftRadius:px(20),borderTopRightRadius:px(20)},
10
14
  wrappper:{borderTopLeftRadius:px(20),borderTopRightRadius:px(20)},
11
15
  headerItem:{flex:0},
@@ -16,9 +20,23 @@ header:{
16
20
  backgroundColor: '#fff'
17
21
  },
18
22
  maskMiddle:{borderColor:'transparent'},
23
+ titleBox:{
24
+ width:'100%',
25
+ height:px(205),
26
+ backgroundColor:'#fff',
27
+ top:px(15)
28
+ },
29
+ titleContent:{
30
+ width:'100%',height:px(190),borderBottomColor:'#f0f0f0',borderBottomWidth:1,
31
+ borderTopRightRadius:px(20),borderTopLeftRadius:px(20)
32
+ },
33
+ titleText:{
34
+ fontSize:px(48),color:'#333',textAlign:'center',lineHeight:px(190)
35
+ }
19
36
  }
20
37
  const pickerStyle = {height:px(700)}
21
38
 
39
+
22
40
  const PickerV2 = ({
23
41
  renderMaskTop=()=>{return <View></View>},
24
42
  renderMaskBottom=()=>{return <View></View>},
@@ -32,8 +50,27 @@ const PickerV2 = ({
32
50
  renderItem,
33
51
  defaultValue = [],
34
52
  pickedIndex=0,
35
- changePickedIndex=()=>{}
53
+ changePickedIndex=()=>{},
54
+ animatedStartValue,
55
+ animationEffects = {},
56
+ title
36
57
  }) => {
58
+
59
+ // console.log(title)
60
+ const customSpringStyles = useAnimatedStyle(() => {
61
+ return {
62
+ transform: [
63
+ {
64
+ translateY: withSpring(animatedStartValue, {...{
65
+ damping: 20,
66
+ stiffness: 100,
67
+ mass:0.5
68
+ },...animationEffects}),
69
+ },
70
+ ],
71
+ };
72
+ });
73
+
37
74
  // console.log(defaultValue)
38
75
  const handlePickerChange=(item)=>{
39
76
  // console.log(item)
@@ -44,12 +81,14 @@ const PickerV2 = ({
44
81
  changePickedIndex(index)
45
82
  }
46
83
  const handlePikerCommit = (item) => {
84
+ // console.log(item)
47
85
  dealPickerCommit(item)
48
86
  }
49
87
  const handlePickerCancel = () => {
50
88
  dealPickerCancel()
51
89
  }
52
90
  const renderLabel = (item, index) => {
91
+ // console.log(item)
53
92
  return (
54
93
  <Text
55
94
  key={index}
@@ -58,7 +97,7 @@ const PickerV2 = ({
58
97
  {fontSize: px(50),color:Math.abs(index-pickedIndex)===1?'#999':'#eee'},
59
98
  ]}
60
99
  >
61
- {item.value}
100
+ {item.label}
62
101
  </Text>
63
102
  );
64
103
  };
@@ -67,6 +106,7 @@ const PickerV2 = ({
67
106
  <Picker
68
107
  data={pickerData}
69
108
  visible={visible}
109
+ title={title}
70
110
  renderMaskTop={renderMaskTop}
71
111
  renderMaskBottom={renderMaskBottom}
72
112
  styles={{...pickerStyles,...styles}}
@@ -78,6 +118,7 @@ const PickerV2 = ({
78
118
  onOk={handlePikerCommit}
79
119
  onDismiss={handlePickerCancel}
80
120
  onClose={handlePickerCancel}
121
+ customSpringStyles={typeof animatedStartValue !== 'undefined'?customSpringStyles:{}}
81
122
  >
82
123
  </Picker>
83
124
  </View>
@@ -10,7 +10,7 @@ import React, {
10
10
  } from 'react'
11
11
  import { Omit } from 'utility-types'
12
12
 
13
- import { Keyboard } from 'react-native'
13
+ import { Keyboard,View,Text } from 'react-native'
14
14
  import { getComponentLocale } from '../_util/getLocale'
15
15
  import DisabledContext from '../config-provider/DisabledContext'
16
16
  import { LocaleContext } from '../locale-provider'
@@ -35,6 +35,7 @@ export interface RMCPickerProps
35
35
  innerValue: PickerValue[]
36
36
  columns: PickerColumn[]
37
37
  handleSelect: (value: PickerValue, index: number) => void
38
+ customSpringStyles?:any
38
39
  }
39
40
 
40
41
  const RMCPicker = forwardRef<PickerRef, RMCPickerProps>((props, ref) => {
@@ -59,6 +60,7 @@ const RMCPicker = forwardRef<PickerRef, RMCPickerProps>((props, ref) => {
59
60
  innerValue,
60
61
  columns,
61
62
  handleSelect,
63
+ customSpringStyles,
62
64
  ...restProps
63
65
  } = props
64
66
 
@@ -177,22 +179,29 @@ const RMCPicker = forwardRef<PickerRef, RMCPickerProps>((props, ref) => {
177
179
  styles: props.styles,
178
180
  themeStyles: PickerStyles,
179
181
  })
182
+ // console.log(props.styles)
180
183
 
181
184
  return (
182
185
  <>
183
186
  <PopupPicker
184
187
  styles={styles}
185
188
  visible={innerVisible}
186
- title={title}
187
189
  okText={okText || _locale.okText}
188
190
  onOk={handleOk}
189
191
  dismissText={dismissText || _locale.dismissText}
190
192
  onDismiss={handleDismiss}
191
193
  onClose={actions.close}
192
194
  okButtonProps={okButtonProps}
193
- dismissButtonProps={dismissButtonProps}>
195
+ dismissButtonProps={dismissButtonProps}
196
+ customSpringStyles={customSpringStyles}
197
+ >
194
198
  {/* TODO: 组件卸载是在visible更新fasle之后,需要前置 */}
195
199
  {/* 否则会无效执行onPickerChange */}
200
+ {typeof title !== 'undefined'&&<View style={props.styles.titleBox}>
201
+ <View style={props.styles.titleContent}>
202
+ <Text style={props.styles.titleText}>{title}</Text>
203
+ </View>
204
+ </View>}
196
205
  {innerVisible && (
197
206
  <RMCPickerView
198
207
  {...restProps}
@@ -2,6 +2,7 @@ import React, { memo } from 'react'
2
2
  import { Text, TouchableHighlight, View,Modal,TouchableOpacity } from 'react-native'
3
3
  // import Modal from '../modal/ModalView'
4
4
  import { PopupPickerProps } from './PopupPickerTypes'
5
+ import Animated from 'react-native-reanimated';
5
6
 
6
7
  const PopupPicker = memo((props: PopupPickerProps) => {
7
8
  const {
@@ -14,6 +15,7 @@ const PopupPicker = memo((props: PopupPickerProps) => {
14
15
  onOk,
15
16
  onClose,
16
17
  children,
18
+ customSpringStyles={},
17
19
  } = props
18
20
 
19
21
  const titleEl =
@@ -49,7 +51,7 @@ const PopupPicker = memo((props: PopupPickerProps) => {
49
51
  style={[{position:'absolute',top:0,left:0,right:0,bottom:0,zIndex:999},styles.maskColor]}
50
52
  onPress={onClose}
51
53
  ></TouchableOpacity>
52
- <View style={{position:'absolute',left:0,right:0,bottom:0,zIndex:1000}}>
54
+ <Animated.View style={[{position:'absolute',left:0,right:0,bottom:0,zIndex:1000},customSpringStyles]}>
53
55
  {children}
54
56
  <View style={[styles.header]}>
55
57
  <TouchableHighlight
@@ -70,7 +72,7 @@ const PopupPicker = memo((props: PopupPickerProps) => {
70
72
  {okEl}
71
73
  </TouchableHighlight>
72
74
  </View>
73
- </View>
75
+ </Animated.View>
74
76
  </Modal>
75
77
  )
76
78
  })
@@ -13,4 +13,5 @@ export type PopupPickerProps = {
13
13
  dismissButtonProps?: TouchableHighlightProps
14
14
  children?: ReactNode
15
15
  styles: any
16
+ customSpringStyles?:any
16
17
  }
@@ -12,6 +12,9 @@ export interface PickerStyle {
12
12
  maskColor:ViewStyle
13
13
  okView:ViewStyle
14
14
  dismissView:ViewStyle
15
+ titleBox:ViewStyle
16
+ titleContent:ViewStyle
17
+ titleText:TextStyle
15
18
  }
16
19
 
17
20
  export default () =>
@@ -53,5 +56,8 @@ export default () =>
53
56
  },
54
57
  maskColor:{
55
58
  backgroundColor: 'rgba(0,0,0,.6)'
56
- }
59
+ },
60
+ titleBox:{},
61
+ titleContent:{},
62
+ titleText:{}
57
63
  })
@@ -0,0 +1,72 @@
1
+ import React,{useState,useImperativeHandle,useRef} from 'react';
2
+ import {View, Text, StyleSheet} from 'react-native';
3
+ import PickerV2 from '../PickerV2';
4
+ import {useSharedValue} from 'react-native-reanimated';
5
+
6
+ const Home = ({steps, active, onRef}) => {
7
+ let backResult = useRef()
8
+ const animatedStartValue = useSharedValue(700);
9
+ const [visible, setPickerVisible] = useState(false);
10
+ const [pickerData, setPickerData] = useState([]);
11
+ const [pickerTitle,setPickerTitle] = useState()
12
+ const [defaultIndex,setDefaultIndex] = useState(0)
13
+ const [pickedIndex, setPickedIndex] = useState(() => {
14
+ return defaultIndex;
15
+ });
16
+ useImperativeHandle(onRef, () => {
17
+ return {
18
+ show: (str,data) => {
19
+ if(data?.payload?.columns.length){
20
+ setPickerTitle(data?.payload?.title)
21
+ setPickerData(data?.payload?.columns.map(item=>{
22
+ item.label = item[data?.payload?.nameProp]
23
+ item.value = item?.label;
24
+ return item})||[]);
25
+ // console.log(data)
26
+ setPickerVisible(true);
27
+ animatedStartValue.value = 0;
28
+ return new Promise((resolve,reject)=>{
29
+ backResult.current = (res)=>{
30
+ resolve(res)
31
+ }
32
+ })
33
+ }
34
+ },
35
+ };
36
+ });
37
+ const changePickedIndex = index => {
38
+ setPickedIndex(index);
39
+ };
40
+ const dealPickerCommit = (value) =>{
41
+ animatedStartValue.value = 700;
42
+ setPickerTitle()
43
+ setPickerVisible(false);
44
+ setPickedIndex(0);
45
+ // console.log(value);
46
+ const data = pickerData.find(item => {
47
+ return value[0] === item.value;
48
+ });
49
+ const index = pickerData.findIndex(item => {
50
+ return value[0] === item.value;
51
+ })
52
+ backResult.current({data,index})
53
+ }
54
+ return <PickerV2
55
+ pickerData={pickerData}
56
+ visible={visible}
57
+ // defaultValue={[pickerData[defaultIndex]?.value]}
58
+ title={pickerTitle}
59
+ pickedIndex={pickedIndex}
60
+ changePickedIndex={index => changePickedIndex(index)}
61
+ dealPickerCommit={item => dealPickerCommit(item)}
62
+ dealPickerCancel={() => {
63
+ animatedStartValue.value = 700;
64
+ setPickerTitle()
65
+ setPickerVisible(false);
66
+ setPickedIndex(0);
67
+ }}
68
+ animatedStartValue={animatedStartValue.value}
69
+ />
70
+ };
71
+ const styles = StyleSheet.create({});
72
+ export default Home;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ipanel-rnapp-ajb-base",
3
- "version": "1.0.15",
4
- "ipanelVersion": "1.0.309",
3
+ "version": "1.0.16",
4
+ "ipanelVersion": "1.0.310",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "bin": {