Skip to content

Commit 8c371bc

Browse files
committed
Support rn 0.56, add PureComponent container for TopView, rilyu#259, rilyu#260, rilyu#263, rilyu#264
1 parent 3796582 commit 8c371bc

8 files changed

Lines changed: 48 additions & 16 deletions

File tree

components/Label/Label.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {Text} from 'react-native';
88

99
import Theme from 'teaset/themes/Theme';
1010

11-
export default class Label extends Text {
11+
export default class Label extends Component {
1212

1313
static propTypes = {
1414
...Text.propTypes,
@@ -60,11 +60,13 @@ export default class Label extends Text {
6060

6161
if (text || text === '' || text === 0) children = text;
6262

63-
this.props = {type, size, style, text, children, ...others};
63+
return {type, size, style, text, children, ...others};
6464
}
6565

6666
render() {
67-
this.buildProps();
68-
return super.render();
67+
let props = this.buildProps();
68+
return (
69+
<Text {...props} />
70+
);
6971
}
7072
}

components/ModalIndicator/ModalIndicatorView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export default class ModalIndicatorView extends Overlay.View {
1515
...Overlay.View.propTypes,
1616
text: PropTypes.oneOfType([PropTypes.element, PropTypes.string, PropTypes.number]),
1717
position: PropTypes.oneOf(['top', 'bottom', 'center']),
18-
size: ActivityIndicator.propTypes.size,
19-
color: ActivityIndicator.propTypes.color,
18+
size: PropTypes.oneOfType([PropTypes.oneOf(['small', 'large']), PropTypes.number]),
19+
color: PropTypes.string,
2020
};
2121

2222
static defaultProps = {

components/NavigationBar/NavigationTitle.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {Text} from 'react-native';
88

99
import Theme from 'teaset/themes/Theme';
1010

11-
export default class NavigationTitle extends Text {
11+
export default class NavigationTitle extends Component {
1212

1313
static propTypes = {
1414
...Text.propTypes,
@@ -40,12 +40,14 @@ export default class NavigationTitle extends Text {
4040

4141
if (text || text === '' || text === 0) children = text;
4242

43-
this.props = {style, text, children, ...others};
43+
return {style, text, children, ...others};
4444
}
4545

4646
render() {
47-
this.buildProps();
48-
return super.render();
47+
let props = this.buildProps();
48+
return (
49+
<Text {...props} />
50+
);
4951
}
5052

5153
}

components/Overlay/TopView.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
'use strict';
44

5-
import React, {Component} from "react";
5+
import React, {Component, PureComponent} from "react";
66
import {StyleSheet, AppRegistry, DeviceEventEmitter, View, Animated} from 'react-native';
77
//import {Symbol} from 'core-js';
88

@@ -162,7 +162,9 @@ export default class TopView extends Component {
162162
return (
163163
<View style={{backgroundColor: Theme.screenColor, flex: 1}}>
164164
<Animated.View style={{flex: 1, transform: transform}}>
165-
{this.props.children}
165+
<PureView>
166+
{this.props.children}
167+
</PureView>
166168
</Animated.View>
167169
{elements.map((item, index) => {
168170
return (
@@ -188,6 +190,16 @@ var styles = StyleSheet.create({
188190
},
189191
});
190192

193+
class PureView extends PureComponent {
194+
render() {
195+
return (
196+
<View style={{flex: 1}}>
197+
{this.props.children}
198+
</View>
199+
);
200+
}
201+
}
202+
191203
if (!AppRegistry.registerComponentOld) {
192204
AppRegistry.registerComponentOld = AppRegistry.registerComponent;
193205
}

components/Toast/ToastView.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default class ToastView extends Overlay.View {
3333
buildProps() {
3434
super.buildProps();
3535

36-
let {style, contentStyle, text, icon, position, ...others} = this.props;
36+
let {style, contentStyle, text, icon, position, overlayPointerEvents, modal, ...others} = this.props;
3737

3838
style = [{
3939
paddingLeft: Theme.toastScreenPaddingLeft,
@@ -93,7 +93,9 @@ export default class ToastView extends Overlay.View {
9393
);
9494
}
9595

96-
this.props = {style, contentStyle, text, icon, position, ...others};
96+
if (modal) overlayPointerEvents = 'auto';
97+
98+
this.props = {style, contentStyle, text, icon, position, overlayPointerEvents, modal, ...others};
9799
}
98100

99101
renderContent() {

example/views/NavigationBarExample.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class NavigationBarExample extends NavigationPage {
2525
this.rightViewItems = ['None', 'Link button', 'Icon button', 'Two icon button'];
2626
this.bgColorItems = ['Default', 'Custom'];
2727
this.tintColorItems = ['Default', 'Custom'];
28-
this.statusBarStyleItems = ['Default', 'Light Content'];
28+
this.statusBarStyleItems = ['Default', 'Light Content', 'Dark Content'];
2929

3030
Object.assign(this.state, {
3131
type: 'iOS',
@@ -67,6 +67,7 @@ export default class NavigationBarExample extends NavigationPage {
6767
switch(this.state.statusBarStyle) {
6868
case 'Default': return 'default';
6969
case 'Light Content': return 'light-content';
70+
case 'Dark Content': return 'dark-content';
7071
}
7172
}
7273

example/views/ToastExample.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ export default class ToastExample extends NavigationPage {
1515
showBackButton: true,
1616
};
1717

18+
showModal() {
19+
Toast.show({
20+
text: 'Toast modal',
21+
icon: <ActivityIndicator size='large' color={Theme.toastIconTintColor} />,
22+
position: 'center',
23+
duration: 5000,
24+
overlayOpacity: 0.4,
25+
modal: true,
26+
});
27+
}
28+
1829
static customKey = null;
1930

2031
showCustom() {
@@ -46,6 +57,8 @@ export default class ToastExample extends NavigationPage {
4657
<ListRow title='Info' onPress={() => Toast.info('Toast info')} />
4758
<ListRow title='Stop' onPress={() => Toast.stop('Toast stop')} bottomSeparator='full' />
4859
<View style={{height: 20}} />
60+
<ListRow title='Modal' onPress={() => this.showModal()} topSeparator='full' bottomSeparator='full' />
61+
<View style={{height: 20}} />
4962
<ListRow title='Show custom' onPress={() => this.showCustom()} topSeparator='full' />
5063
<ListRow title='Hide custom' onPress={() => this.hideCustom()} bottomSeparator='full' />
5164
</ScrollView>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "teaset",
3-
"version": "0.5.8",
3+
"version": "0.5.9",
44
"description": "A UI library for react native.",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)