Skip to content

Commit 4ea1c46

Browse files
committed
update Text component to use ThemeProps to enable defining global behaviour for Text component
1 parent 1606b74 commit 4ea1c46

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

demo/src/demoApp.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Navigation} from 'react-native-navigation';
2-
import {Typography, Colors, Assets, Button, Badge, ThemeManager} from 'react-native-ui-lib'; //eslint-disable-line
2+
import {Typography, Colors, Assets, Button, Badge, ThemeManager, Text} from 'react-native-ui-lib'; //eslint-disable-line
33
import * as Animatable from 'react-native-animatable';
44
import './screens';
55

@@ -23,21 +23,25 @@ import './screens';
2323
// subtitleColor: Colors.blue40,
2424
// });
2525

26+
// ThemeManager.setComponentTheme('Text', {
27+
// dark10: true,
28+
// });
29+
2630
Assets.loadAssetsGroup('icons.general', {
2731
camera: require('./assets/icons/cameraSelected.png'),
2832
});
2933

3034
Animatable.initializeRegistryWithDefinitions({
3135
gridListEntrance: {
32-
from: {opacity: 0, ['translateY']: 15},
33-
to: {opacity: 1, ['translateY']: 0},
36+
from: {opacity: 0, translateY: 15},
37+
to: {opacity: 1, translateY: 0},
3438
},
3539
});
3640

3741
Animatable.initializeRegistryWithDefinitions({
3842
basicListEntrance: {
39-
from: {opacity: 0, ['translateY']: 20},
40-
to: {opacity: 1, ['translateY']: 0},
43+
from: {opacity: 0, translateY: 20},
44+
to: {opacity: 1, translateY: 0},
4145
},
4246
});
4347

@@ -51,4 +55,3 @@ export function startApp() {
5155
},
5256
});
5357
}
54-

src/commons/BaseComponent.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ export default class BaseComponent extends Component {
100100

101101
extractColorValue() {
102102
let color;
103+
const props = this.getThemeProps();
103104
_.forEach(Colors, (value, key) => {
104-
if (this.props[key] === true) {
105+
if (props[key] === true) {
105106
color = value;
106107
}
107108
});

src/components/text/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class Text extends BaseComponent {
4040
render() {
4141
const color = this.props.color || this.extractColorValue();
4242
const typography = this.extractTypographyValue();
43-
const {style, center, ...others} = this.props;
43+
const {style, center, ...others} = this.getThemeProps();
4444
const {margins} = this.state;
4545
const textStyle = [
4646
this.styles.container,

0 commit comments

Comments
 (0)