Skip to content

Commit

Permalink
v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
the-nippy committed Feb 7, 2021
1 parent e952f30 commit 983f06d
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 47 deletions.
16 changes: 5 additions & 11 deletions CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

一个 React Native 上的选择器组件,使用时间,地址以及各种分类选择的场景上。

<img src="https://pic.downk.cc/item/5fca0ebf394ac52378391b0b.gif" width=250>
<img src="https://img.imgdb.cn/item/601f481a3ffa7d37b3cb1e0e.gif" width=250>

<img src="https://pic.downk.cc/item/5fcaef1a394ac52378062486.jpg" width=200/> <img src="https://pic.downk.cc/item/5fcaef1a394ac52378062489.jpg" width=200/> <img src="https://pic.downk.cc/item/5fcaef1a394ac5237806248c.jpg" width=200/>
<img src="https://img.imgdb.cn/item/601f484d3ffa7d37b3cb2d6f.jpg" width=250/> <img src="https://img.imgdb.cn/item/601f486d3ffa7d37b3cb374e.jpg" width=250/> <img src="https://img.imgdb.cn/item/601f48903ffa7d37b3cb4370.jpg" width=250/>

特点:

- 使用 JavaScript 实现,兼容 Android 和 iOS 端。
- 自定义条目高度,背景色,文字样式,自定义选择器头部
- 支持使用级联选择和平行选择两种方式
- 自定义在显示,可在 Modal 或绝对定位中使用
- 自定义显示方式,可在 Modal 或绝对定位中使用

## 使用

Expand Down Expand Up @@ -194,7 +194,7 @@ export default class PickerTest extends Component {

本组件并不处理弹出框的逻辑,因为弹出层的方案可能每个人采用的方案本身不同,目前还难以找到一种大多数人统一认同的方案,所以这一层的逻辑交由使用者处理 , 如果有更好的方案欢迎 issue 和 PR 。

如果你需要使用在弹出层中,可以使用绝对定位及 z-Index 方式或`Modal`组件处理,
如果你需要使用在弹出层中,可以使用绝对定位及 z-Index 方式或<a href="https://github.com/react-native-modal/react-native-modal">`Modal`</a>组件处理,(Example文件夹中的示例使用`Modal`)

如:

Expand All @@ -219,13 +219,7 @@ export default class PickerTest extends Component {

### `defaultValueIndexes`

默认选中值,目前只在`ParallelPicker`中可用,`CascadePicker`待完成。

<hr id="oncechange"/>

### `onceChange : (dataArray) => { }`

(dataArray) => { } , 函数类型,非必要参数。每次数据选择都会触发,传回当前选择的实时数据。
默认选中值,目前只在`ParallelPicker`中可用,`CascadePicker`中待完善

## 其他

Expand Down
24 changes: 14 additions & 10 deletions Example/demo/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
/*
* @Author: xuwei
* @Date: 2020-11-18 09:23:11
* @LastEditTime: 2021-02-05 18:57:28
* @LastEditTime: 2021-02-07 09:47:12
* @LastEditors: xuwei
* @Description:
*/
import React, {Component, PureComponent} from 'react';
import React, {Component} from 'react';
import {TouchableOpacity, Text, View, StyleSheet, Image} from 'react-native';
import {ModalContain} from './pickercontain';

import {CascadePicker, ParallelPicker} from '../localpicker/index';
// import {CascadePicker, ParallelPicker} from 'react-native-slidepicker';

const specData = require('./testfiles/spec.json');
// const specData = require('./testfiles/spec.json');
const specData = require('./testfiles/spec_cn.json');

const oneData = require('./testfiles/one.json');
const threeData = require('./testfiles/three.json');
// const threeData = require('./testfiles/three.json');
const threeData = require('./testfiles/area.json');
const ICON_DOG = require('./testfiles/dog.png');

export default class PickerDemo extends Component {
Expand Down Expand Up @@ -44,19 +47,20 @@ export default class PickerDemo extends Component {
<TouchableOpacity
style={styles.button}
onPress={() => this.setState({showType: 'spec'})}>
<Text style={{fontSize: 20}}>Demo1(ParallelPicker)</Text>
{/* <Text style={{fontSize: 20}}>Demo1(ParallelPicker)</Text> */}
<Text style={{fontSize: 20}}>示例1 (ParallelPicker)</Text>
</TouchableOpacity>

<TouchableOpacity
style={[styles.button, {marginTop: 20}]}
onPress={() => this.setState({showType: 'one'})}>
<Text style={{fontSize: 20}}>Demo2(ParallelPicker)</Text>
<Text style={{fontSize: 20}}>示例2 (ParallelPicker)</Text>
</TouchableOpacity>

<TouchableOpacity
style={[styles.button, {marginTop: 20}]}
onPress={() => this.setState({showType: 'three'})}>
<Text style={{fontSize: 20}}>Demo3(CascadePicker)</Text>
<Text style={{fontSize: 20}}>示例3 (CascadePicker)</Text>
</TouchableOpacity>

{/* color size */}
Expand Down Expand Up @@ -106,7 +110,7 @@ export default class PickerDemo extends Component {
<Image source={ICON_DOG} style={{width: 36, height: 36}} />
<Text style={{fontSize: 18}}>Choose Animals</Text>
<TouchableOpacity onPress={this.showOneData}>
<Text style={{fontSize: 18, color: '#0aa'}}>Done</Text>
<Text style={{fontSize: 18, color: '#0aa'}}>完成</Text>
</TouchableOpacity>
</View>
}
Expand Down Expand Up @@ -136,8 +140,8 @@ export default class PickerDemo extends Component {
normalFontColor: '#333',
}}
headOptions={{
cancelText: 'Cancel',
confirmText: 'OK',
cancelText: '取消',
confirmText: '确认',
headHeight: 50,
borderTopRadius: 10,
backgroundColor: '#444',
Expand Down
48 changes: 24 additions & 24 deletions Example/demo/testfiles/area.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,94 +76,94 @@
]
},
{
"name": "湖南省",
"name": "广东省",
"id": 2,
"list": [
{
"name": "长沙",
"name": "广州",
"id": 100,
"list": [
{
"name": "岳麓区",
"name": "天河区",
"id": 2001
},
{
"name": "芙蓉区",
"name": "白云区",
"id": 2002
},
{
"name": "天心区",
"name": "海珠区",
"id": 2003
},
{
"name": "雨花区",
"name": "越秀区",
"id": 2004
}
]
},
{"name": "张家界", "id": 300, "list": [{"name": "武陵源区"}]},
{"name": "潮州", "id": 300, "list": [{"name": "潮安县"}]},
{
"name": "常德",
"name": "深圳",
"id": 200,
"list": [
{
"name": "武陵区",
"name": "福田区",
"id": 2101
},
{
"name": "鼎城区",
"name": "罗湖区",
"id": 2102
},
{
"name": "安乡县",
"name": "南山区",
"id": 2103
},
{
"name": "澧县",
"name": "宝安区",
"id": 2104
},
{
"name": "桃源县",
"name": "龙岗区",
"id": 2105
}
]
},
{"name": "Cuba", "id": 400, "list": []},
{"name": "jamaica", "id": 400, "list": []}
{"name": "东莞", "id": 400, "list": []},
{"name": "佛山", "id": 400, "list": []}
]
},
{"name": "South America"},
{"name": "贵州省"},

{
"name": "Europe",
"name": "河北省",
"id": 3,
"list": [
{
"name": "Russia",
"name": "石家庄",
"id": 300,
"list": [
{
"name": "Moscow",
"name": "长安区",
"id": 3001
},
{
"name": "Saint Petersburg",
"name": "桥东区",
"id": 3002
},
{
"name": "volgoglad",
"name": "桥西区",
"id": 3003
},
{
"name": "yekaterinburg",
"name": "新华区",
"id": 3004
},
{
"name": "kazan",
"name": "裕华区",
"id": 3005
},
{
"name": "novosibirsk",
"name": "高新区",
"id": 3006
}
]
Expand Down
20 changes: 20 additions & 0 deletions Example/demo/testfiles/spec_cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[
[
{"name": ""},
{"name": ""},
{"name": "绿"},
{"name": ""},
{"name": ""},
{"name": ""},
{"name": ""}
],
[
{"name": 37},
{"name": 38},
{"name": 39},
{"name": 40},
{"name": 41},
{"name": 42},
{"name": 43}
]
]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export default class PickerTest extends Component {

This component does not deal with the logic of pop-up boxes, because the scheme of the pop-up layer may be different from the scheme adopted by each person. At present, it is difficult to find a solution that most people agree with. Therefore, the logic of this layer is left to the user. If there is a better scheme, issue and PR are welcome.

If you need to use it in the pop-up layer, you can use `absolute position and z-Index` or `Modal component`.
If you need to use it in the pop-up layer, you can use `absolute position and z-Index` or <a href="https://github.com/react-native-modal/react-native-modal">`Modal component`</a>.

example:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-slidepicker",
"version": "1.0.8",
"version": "1.1.2",
"description": "a slide picker used in react native",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 983f06d

Please sign in to comment.