/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/Libraries/StyleSheet/processColor.js
59 строк
2 KB
Tim Yung
RN: Sort Pragmas in Headers (#51554)
23 май 2025, 07:18
23 май 2025, 07:18
1977dd6
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow strict-local * @format */ 'use strict'; import type {ColorValue, NativeColorValue} from './StyleSheet'; const Platform = require('../Utilities/Platform').default; const normalizeColor = require('./normalizeColor').default; export type ProcessedColorValue = number | NativeColorValue; /* eslint no-bitwise: 0 */ function processColor(color?: ?(number | ColorValue)): ?ProcessedColorValue { if (color === undefined || color === null) { return color; } let normalizedColor = normalizeColor(color); if (normalizedColor === null || normalizedColor === undefined) { return undefined; } if (typeof normalizedColor === 'object') { const processColorObject = require('./PlatformColorValueTypes').processColorObject; const processedColorObj = processColorObject(normalizedColor); if (processedColorObj != null) { return processedColorObj; } } if (typeof normalizedColor !== 'number') { return null; } // Converts 0xrrggbbaa into 0xaarrggbb normalizedColor = ((normalizedColor << 24) | (normalizedColor >>> 8)) >>> 0; 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 // *unsigned* to *signed* 32bit int that way. normalizedColor = normalizedColor | 0x0; } return normalizedColor; } export default processColor;