mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Static type check for int params + migrate colorInt to just int.
Differential Revision: D2475618 committer: Service User <svcscm@fb.com>
This commit is contained in:
committed by
facebook-github-bot-9
parent
944fa4d635
commit
6c3fb77f30
@@ -11,6 +11,7 @@
|
||||
'use strict';
|
||||
|
||||
var tinycolor = require('tinycolor2');
|
||||
var Platform = require('Platform');
|
||||
|
||||
function processColor(color) {
|
||||
if (!color || typeof color === 'number') {
|
||||
@@ -19,7 +20,15 @@ function processColor(color) {
|
||||
return color.map(processColor);
|
||||
} else {
|
||||
var hexString = tinycolor(color).toHex8();
|
||||
return parseInt(hexString, 16);
|
||||
var colorInt = parseInt(hexString, 16);
|
||||
if (Platform.OS === 'android') {
|
||||
// Android use 32 bit *signed* integer to represent the color
|
||||
// We utilize the fact that bitwise operations in JS also operates on
|
||||
// signed 32 bit integers, so that we can use those to convert from
|
||||
// *unsiged* to *signed* 32bit int that way.
|
||||
colorInt = colorInt | 0x0;
|
||||
}
|
||||
return colorInt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user