-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
29 lines (28 loc) · 919 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from "react"
import { Text, TextInput } from 'react-native'
import wrap from 'lodash.wrap'
let _applyed = false
export default class GlobalFont {
static applyGlobal(fontFamily) {
if (_applyed) { return }
Text.render = wrap(Text.render, function (func, ...args) {
let originText = func.apply(this, args)
return React.cloneElement(originText, {
style: [
{fontFamily: fontFamily},
originText.props.style
]
})
})
TextInput.render = wrap(TextInput.render, function (func, ...args) {
let originTextInput = func.apply(this, args)
return React.cloneElement(originTextInput, {
style: [
{ fontFamily: fontFamily },
originTextInput.props.style
]
})
})
_applyed = true
}
}