Skip to content

Commit

Permalink
support message attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyann committed Sep 28, 2017
1 parent bb7a233 commit 4fcdf65
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ class ExampleB extends React.Component {
<td>PropTypes.string or PropTypes.element</td>
<td></td>
</tr>
<tr>
<td>message</td>
<td></td>
<td>PropTypes.string or PropTypes.element</td>
<td></td>
</tr>
<tr>
<td>options</td>
<td></td>
Expand Down
5 changes: 4 additions & 1 deletion lib/ActionSheetCustom.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import {
import styles, { btnStyle, sheetStyle, hairlineWidth } from './styles'


const TITLE_H = 40
const TITLE_H = 40
const MESSAGE_H = 40
const CANCEL_MARGIN = 6
const BUTTON_H = 50 + hairlineWidth
const WARN_COLOR = '#ff3b30'
Expand Down Expand Up @@ -70,6 +71,7 @@ class ActionSheet extends Component {
let count = props.options.length
let height = BUTTON_H * count + CANCEL_MARGIN
if (props.title) height += TITLE_H
if (props.message) height += MESSAGE_H
if (height > MAX_HEIGHT) {
this.scrollEnabled = true;
return MAX_HEIGHT
Expand Down Expand Up @@ -201,6 +203,7 @@ ActionSheet.propTypes = {
PropTypes.string,
PropTypes.element
]),
message: PropTypes.string,
options: PropTypes.arrayOf((propVal, key, componentName, location, propFullName) => {
if (typeof propVal[key] !== 'string' && !React.isValidElement(propVal[key])) {
return new Error(
Expand Down
7 changes: 4 additions & 3 deletions lib/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default StyleSheet.create({

export const sheetStyle = StyleSheet.create({
wrapper: {
flex: 1,
flex: 1,
flexDirection: 'row'
},
bd: {
Expand All @@ -31,10 +31,11 @@ export const sheetStyle = StyleSheet.create({
backgroundColor: '#fff'
},
message: {
height: 20,
height: 40,
paddingBottom: 10,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#fff'
backgroundColor: '#fff'
},
titleText: {
color: '#8f8f8f',
Expand Down

0 comments on commit 4fcdf65

Please sign in to comment.