@react-native-pure/ibuild-modal
v1.10.4
Published
层级选择组件
Downloads
10
Readme
ibuild-modal
Modal | 属性 | 说明 ---- | ---|--- PageModal | PageModalProps| 页码切换modal TreeModal | TreeModalProps| 层级选择modal TreeSelector | TreeSelectorProps | 层级选择组件 PopModal | PopModalProps| 底部弹出modal组件 ActionSheetModal | ActionSheetModalProps ListViewModel | ListViewModelProps |
Install
$ npm i @react-native-pure/ibuild-modal --save
Documentaion
Quite easy to use TreeModal:
import React from 'react'
import {View,TouchableOpacity,Text,Alert} from 'react-native'
import {TreeModal,TreeSelectorModel} from '@react-native-pure/ibuild-modal'
import update from "immutability-helper";
constructor(props){
super(props)
this.state = {
show:false,
data:{
"sysNo": 1,
"organizationCode": "1",
"organizationFullName": "组织机构1",
children:[{
"sysNo": 11,
"organizationCode": "11",
"organizationFullName": "组织机构11",
}]
},
{
"sysNo": 2,
"organizationCode": "2",
"organizationFullName": "组织机构2",
}],
selectedData:[],
model:TreeSelectorModel.singleSelectAny
}
}
updateState = (state: ImmutableHelperObject, callback: Function) => {
if (this.state) {
this.setState(
update(this.state, state),
callback
);
}
}
render(){
return(<View style={{flex:1}}>
<TouchableOpacity style={{justifyContent: 'center',alignItems: 'center',flex:1}}
onPress={()=>{
this.setState({
show:true
})
}}>
<Text>show</Text>
</TouchableOpacity>
<TreeModal visible={this.state.show}
dataSource={this.state.data}
storageKey={"Key1"}
selectedDataSouce = {this.state.selectedData}
keyExtractor={(data)=>data.sysNo}
labelExtractor={(data)=>data.organizationFullName}
model={this.state.model}
onRequestClose={(info)=>{
this.setState({
show:false
})
}}
onChange={(currentItem,path)=>{
Alert.alert("change")
}}
onSelected={(currentItem,path)=>{
Alert.alert("选中")
this.updateState({
selectedData: {$push:[currentItem]}
})
}}
onUnSelected={(currentItem,path)=>{
Alert.alert(" 取消选中")
let index = this.state.selectedData.findIndex(x=>x.sysNo === currentItem.sysNo)
this.updateState({
selectedData: {$splice: [[index, 1]]}
})
}}
/>
</View>)
}
}
TreeModal
TreeModalProps
dataSource
ArrayselectedDataSouce
ArrayloadDataFuc?
(selectedItem:Object)=>Object 点击网络数据keyExtractor?
(item: object) => string 数据唯一标识,默认为sysNo
labelExtractor?
(item: object) => string 显示文字的key,默认为name
model?
()=>$Values<typeof TreeSelectorModel> 选择模式,默认singleSelectToEnd
onChange?
()=>(currentItem: Object,path:Array) => void 选择改变时触发onSelected?
(currentItem: Object,path:Array) => void 选中时触发onUnSelected?
(currentItem: Object,path:Array) => void 取消选择时触发lastSelectedPath?
Array 最后选择的全路径,如果提供将自动跳到上次选择的位置maxLevel?
number 页最多显示多少列,默认为10
initLevel?
number 初始化显示列,默认为2
storageKey?
string 提供一个字符串key用以保存历史选择数据以实现数据分离,如果不传的将使用默认key对历史选择数据进行保存style?
ObjectonError?
(message:string)=>voidhiddenHomeIcon?
boolean 是否隐藏header上home IconhomeTitle?
string 初始化header 第一个位置的内容showFullValue?
boolean Item内容是否显示全路径navbarStyle?
NavigationBarStyletitle?
stringonPressLeft?
()=>voidonPressRight?
()=>voidhiddenLeft?
booleanhiddenRight?
booleanrenderLeft?
React.ReactElement < any >renderRight?
React.ReactElement < any >renderEmpty?
React.ReactElement < any >
TreeSelectorProps
dataSource
ArrayselectedDataSouce
ArrayloadDataFuc?
(selectedItem:Object)=>Object 点击网络数据keyExtractor?
(item: object) => string 数据唯一标识,默认为sysNo
labelExtractor?
(item: object) => string 显示文字的key,默认为name
model?
()=>$Values<typeof TreeSelectorModel> 选择模式,默认singleSelectToEnd
onChange?
()=>(currentItem: Object,path:Array) => void 选择改变时触发onSelected?
(currentItem: Object,path:Array) => void 选中时触发onUnSelected?
(currentItem: Object,path:Array) => void 取消选择时触发lastSelectedPath?
Array 最后选择的全路径,如果提供将自动跳到上次选择的位置maxLevel?
number 页最多显示多少列,默认为10
initLevel?
number 初始化显示列,默认为2
storageKey?
string 提供一个字符串key用以保存历史选择数据以实现数据分离,如果不传的将使用默认key对历史选择数据进行保存style?
ObjectonError?
(message:string)=>voidhiddenHomeIcon?
boolean 是否隐藏header上home IconhomeTitle?
string 初始化header 第一个位置的内容showFullValue?
boolean Item内容是否显示全路径
PageModalProps
navbarStyle?
NavigationBarStyletitle?
stringonPressLeft?
()=>voidonPressRight?
()=>voidhiddenLeft?
booleanhiddenRight?
booleanrenderLeft?
React.ReactElement < any >renderRight?
React.ReactElement < any >transition?
$Values<typeof TransitionType>
NavigationBarStyle
####导航栏样式
title
Object title样式leftButton
Object 左边按钮样式rightButton
Object 右边按钮样式contaner
Object 导航栏外层view样式
TreeSelectorModel
####层级选择组件模式
multiSelectToEnd
:"multiSelectToEnd" 多选,只有到最后一级multiSelectAny
:"multiSelectAny" 每一级都可以多选singleSelectToEnd
:"singleSelectToEnd" 单选,只有到最后一级singleSelectAny
:"singleSelectAny" 每一级都可以单选
TransitionType
####页面切换动画
none
:"none" 没有动画horizontal
:"horizontal" 从右往左推出页面vertical
:"vertical" 从下往上推出页面
PopModalProps
visible
booleanonRequestClose
()=>voidonShown?
()=>voidonHidden?
()=>voidchildren?
*any
ActionSheetModalProps
visible
booleanonRequestClose
()=>voidonShown?
()=>voidonHidden?
()=>voidchildren?
*anytitle?
stringbuttons?
Array< ActionSheetModalButton>style?
anycancelType?
$Values< typeof ActionSheetCancelButtonEnum>
ActionSheetModalButton
text
booleanonPress
(index:number)=>void
ActionSheetCancelButtonEnum
cancel
: "cancel"delete
: "delete"`
CameraProps
visible
booleanonRequestClose
(ImagePickerResult)=>voidonShown?
()=>voidonHidden?
()=>voidchildren?
*anyonError?
(err: Object) => voidtype
$Values<typeof ImagePickerMediaEnum> 视频/拍照/视频和拍照transition?
$Values<typeof TransitionType>
ListViewModelProps
visible
booleanonRequestClose
(data:any)=>voidonShown?
()=>voidonHidden?
()=>voiddata
()=>ArrayrenderItem
() => React.ReactElementtotal
numberpageIndex
numberstartPageNum?
numberonPageChange?
(pageIndex:number)=>void