Skip to content

Commit 4a0f63b

Browse files
author
yongqian
committed
新增了RRCActionSheet模块
1 parent 34533b8 commit 4a0f63b

File tree

19 files changed

+317
-5
lines changed

19 files changed

+317
-5
lines changed

App.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121
Dimensions,
2222
ScrollView
2323
} from 'react-native';
24-
import { RRCAlert, RRCLoading, RRCToast } from './src';
24+
import { RRCAlert, RRCLoading, RRCToast, RRCActionSheet } from './src';
2525
import LoadingImage from './src/img/car_list_loading.gif';
2626
import AlertImage from './src/img/alert.png';
2727
import SuccessImage from './src/img/success.png';
@@ -70,12 +70,42 @@ export default class App extends Component {
7070
</TouchableOpacity>
7171
<TouchableOpacity onPress={() => {
7272
RRCAlert.alert('normal');
73+
setTimeout(() => {
74+
RRCActionSheet.action([1,2,3], (index)=>{
75+
RRCToast.show(index)
76+
})
77+
}, 1000);
7378
}}>
7479
<Text style={styles.welcome}>
7580
Alert normal
7681
</Text>
7782
</TouchableOpacity>
7883

84+
<TouchableOpacity onPress={() => {
85+
RRCActionSheet.action( [1,{text: 2, style:{color: 'red'}},3,4,5,6], (index)=>{
86+
RRCToast.show('selected index ' + index)
87+
}, {text: 'ok', style:{color: 'red'}});
88+
89+
}}>
90+
<Text style={styles.welcome}>
91+
action sheet normal
92+
</Text>
93+
</TouchableOpacity>
94+
95+
<TouchableOpacity onPress={() => {
96+
RRCActionSheet.action( [1,2,3,4,5,6], (index)=>{
97+
RRCToast.show('selected index ' + index)
98+
});
99+
RRCToast.show('toast 与 ActionSheet、Alert不冲突')
100+
setTimeout(()=>{
101+
RRCAlert.alert('ActionSheet、Alert先入栈的最后展示')
102+
}, 2000)
103+
}}>
104+
<Text style={styles.welcome}>
105+
action sheet normal default
106+
</Text>
107+
</TouchableOpacity>
108+
79109

80110
<TouchableOpacity onPress={() => {
81111
RRCAlert.alert('loading and alert')

README.md

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ react-native项目中通用的浮层组件
66
* **通用RRCAlert组件**
77
* **通用RRCLoading组件**
88
* **通用RRCToast组件**
9+
* **通用RRCActionSheet组件**
910

1011
# install
1112

@@ -48,6 +49,58 @@ react-native项目中通用的浮层组件
4849

4950
* 当 buttons.length > 2 时,弹窗中的按钮按纵向排列
5051

52+
## RRCActionSheet
53+
* 引用
54+
55+
import { RRCActionSheet } from 'react-native-overlayer';
56+
...
57+
RRCActionSheet.setActionSheetOptions({
58+
backgroundColor: defaultBackgroundColor, // 遮罩颜色
59+
fontSize: 19, // 文字字号
60+
itemHeight: 57, // 单个item的高度
61+
buttonTitleColor: 'rgba(0, 0, 14, 0.8)', // 备选按钮字体颜色
62+
cancelButtonTitleColor: 'rgba(0, 0, 14, 0.8)', // 取消按钮字体颜色
63+
buttonItemBackgroundColor: '#eee', // 备选按钮背景颜色
64+
cancelButtonBackgroundColor: '#feffff', // 取消按钮背景颜色
65+
})
66+
...
67+
68+
const buttons = [1,'2','3',4,5,6]; // 字符串或数字型数组
69+
const buttons_2 = [ // 对象型数组 key 为 text和style
70+
{text: 1, style:{color: 'red', fontSize: 16}},
71+
{text: 2, style:{color: 'red'}},
72+
{text: 2, style:{color: 'red'}},
73+
{text: 3, style:{color: 'red'}}
74+
]
75+
const buttons_3 = [ // 数字、字符串、对象 组合型数组
76+
{text: 1, style:{color: 'red'}},
77+
2,
78+
{text: 3, style:{color: 'red'}},
79+
{text: 4, style:{color: 'red'}},
80+
'5'
81+
]
82+
83+
const callback = (index)=>{
84+
console.log(`you click button with index ${index}`);
85+
}
86+
const cancelButton = {text: '确定', style:{color: 'red'}} // 默认【取消】 样式可以通过option统一设置
87+
88+
RRCActionSheet.action(buttons, callback, cancelButton);
89+
90+
91+
* **`setAlertOptions` options**
92+
93+
|key|type|default value | desc |
94+
|:--:|:--:|:--:|:--:|
95+
| backgroundColor |string|rgba(0,0,0,0.3)|弹框蒙层背景色 |
96+
| fontSize | number| 19 | 文字字号
97+
| itemHeight | number| 57 | 单个item的高度
98+
| buttonTitleColor | string | rgba(0, 0, 14, 0.8) | 备选按钮字体颜色
99+
| cancelButtonTitleColor | string| #eee | 备选按钮背景颜色
100+
| buttonItemBackgroundColor | string| 19 | 文字字号
101+
| cancelButtonBackgroundColor | string | #feffff | 取消按钮背景颜色
102+
103+
51104

52105
## RRCLoading
53106
* 引用
@@ -83,7 +136,7 @@ react-native项目中通用的浮层组件
83136
// 如果你需要支持GIF动图
84137
compile 'com.facebook.fresco:animated-gif:1.3.0'
85138
}
86-
139+
87140
## RRCToast
88141
* 引用
89142

@@ -157,4 +210,15 @@ react-native项目中通用的浮层组件
157210
- 各个组件统一使用`set***Options`的方式设置属性、样式
158211

159212
### 0.1.1
160-
- `RRCToast`出现时可以进行toast之外的交互,如点击事件、侧滑返回等
213+
- `RRCToast`出现时可以进行toast之外的交互,如点击事件、侧滑返回等
214+
215+
### 0.2.0
216+
- 新增`RRCActionSheet`,用法与RRCAlert类似
217+
218+
# 效果图
219+
![alert](./assets/alertnormal.png)
220+
![alert](./assets/alert3.png)
221+
![loading](./assets/loading.png)
222+
![actionsheet](./assets/actionsheet2.png)
223+
![toast](./assets/toast.png)
224+
![toast](./assets/toast2.png)

assets/actionSheet.gif

207 KB
Loading

assets/actionsheet1@2x.png

25.5 KB
Loading

assets/actionsheet2.png

27.3 KB
Loading

assets/alert3.png

29.1 KB
Loading

assets/alertnormal.png

26.3 KB
Loading

assets/loading.png

43.1 KB
Loading

assets/overlayer.gif

530 KB
Loading

assets/overlayer2.gif

303 KB
Loading

0 commit comments

Comments
 (0)