Skip to content

Commit

Permalink
fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rilyu committed May 22, 2017
1 parent 8ebb949 commit 9069a53
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion components/SegmentedBar/SegmentedItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class SegmentedItem extends Component {
textStyle = [{
color: Theme.sbBtnActiveTitleColor,
fontSize: Theme.sbBtnActiveTextFontSize,
}].concat(titleStyle).concat(activeTitleStyle);
}].concat(activeTitleStyle);
} else {
textStyle = [{
color: Theme.sbBtnTitleColor,
Expand Down
6 changes: 4 additions & 2 deletions components/SegmentedView/SegmentedSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict';

import React, {Component, PropTypes} from 'react';
import {View} from 'react-native';
import {View, Text} from 'react-native';

import Theme from 'teaset/themes/Theme';

Expand All @@ -12,11 +12,13 @@ export default class SegmentedSheet extends Component {
static propTypes = {
...View.propTypes,
title: PropTypes.oneOfType([PropTypes.element, PropTypes.string, PropTypes.number]).isRequired,
titleStyle: Text.propTypes.style,
activeTitleStyle: Text.propTypes.style,
badge: PropTypes.oneOfType([PropTypes.element, PropTypes.string, PropTypes.number]),
};

render() {
let {style, ...others} = this.props;
let {style, title, titleStyle, activeTitleStyle, badge, ...others} = this.props;
style = [{flexGrow: 1}].concat(style);
return <View style={style} {...others} />;
}
Expand Down
13 changes: 11 additions & 2 deletions components/SegmentedView/SegmentedView.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default class SegmentedView extends Component {
}

renderBar() {
let {barPosition, barStyle, justifyItem, indicatorType, indicatorPosition, animated, autoScroll, onChange, children} = this.props;
let {barPosition, barStyle, justifyItem, indicatorType, indicatorPosition, indicatorLineColor, indicatorLineWidth, indicatorPositionPadding, animated, autoScroll, onChange, children} = this.props;

if (!indicatorPosition && barPosition == 'bottom') {
indicatorPosition = 'top';
Expand All @@ -98,13 +98,22 @@ export default class SegmentedView extends Component {
justifyItem={justifyItem}
indicatorType={indicatorType}
indicatorPosition={indicatorPosition}
indicatorLineColor={indicatorLineColor}
indicatorLineWidth={indicatorLineWidth}
indicatorPositionPadding={indicatorPositionPadding}
animated={animated}
autoScroll={autoScroll}
activeIndex={this.activeIndex}
onChange={index => this.onSegmentedBarChange(index)}
>
{children.map((item, index) => (
<SegmentedBar.Item key={index} title={item.props.title} badge={item.props.badge} />
<SegmentedBar.Item
key={index}
title={item.props.title}
titleStyle={item.props.titleStyle}
activeTitleStyle={item.props.activeTitleStyle}
badge={item.props.badge}
/>
))}
</SegmentedBar>
);
Expand Down
9 changes: 0 additions & 9 deletions docs/cn/SegmentedView.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ SegmentedView 组件定义一个分段器组件, 一般用于同一页面中多
| Prop | Type | Default | Note |
|---|---|---|---|
| [Sheet](#segmentedviewsheet--props) | class | | 分段器 Sheet 组件。
| [Button](#segmentedviewbutton--props) | class | | 分段器按钮组件。<br/>此组件由 Sheet 组件自动渲染, 无须代码显式声明, 但可以修改 SegmentedView.Button 为自定义类以更改分段器按钮组件。

<!--
## Methods
Expand All @@ -45,14 +44,6 @@ None.
| title | string<br/>number<br/>element | | 标题, 可以是字符串、数字或 React Native 组件。
| badge | string<br/>number<br/>element | | 徽章, 可以是字符串、数字或 React Native 组件, 为字符串、数字时使用 `<Badge />`组件渲染。

## `<SegmentedView.Button />` Props
| Prop | Type | Default | Note |
|---|---|---|---|
| [TouchableOpacity props...](https://facebook.github.io/react-native/docs/touchableopacity.html) | | | SegmentedView.Button 组件继承 TouchableOpacity 组件的全部属性。
| title | string<br/>number<br/>element | | 标题, 可以是字符串、数字或 React Native 组件。
| badge | string<br/>number<br/>element | | 徽章, 可以是字符串、数字或 React Native 组件, 为字符串、数字时使用 `<Badge />`组件渲染。
| active | bool | false | 是否激活。

## Example
简单用法
```
Expand Down
5 changes: 4 additions & 1 deletion example/views/SegmentedViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ export default class SegmentedViewExample extends NavigationPage {
}

renderPage() {

let {custom} = this.state;
return (
<View style={{flex: 1}}>
<SegmentedView
style={{flex: 1}}
type={this.state.type}
indicatorLineColor={custom ? '#5cb85c' : undefined}
indicatorLineWidth={custom ? 1 : undefined}
indicatorPositionPadding={custom ? 3 : undefined}
onChange={index => this.setState({activeIndex: index})}
>
<SegmentedView.Sheet title={this.renderTitle(0)}>
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": "teaset",
"version": "0.2.5",
"version": "0.2.6",
"description": "A UI library for react native.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 9069a53

Please sign in to comment.