UNPKG

react-native-windows

Version:
90 lines 3.71 kB
/** * Copyright (c) Microsoft Corporation. * Licensed under the MIT License. * @format */ 'use strict'; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.AppTheme = void 0; var react_native_1 = require("react-native"); var invariant = require('invariant'); var NativeAppTheme = react_native_1.NativeModules.RTCAppTheme; var AppThemeModule = /** @class */ (function (_super) { __extends(AppThemeModule, _super); function AppThemeModule() { var _this = _super.call(this, NativeAppTheme) || this; _this.isAvailable = true; _this._highContrastColors = NativeAppTheme.initialHighContrastColors; _this._isHighContrast = NativeAppTheme.initialHighContrast; _this.addListener('highContrastChanged', function (nativeEvent) { _this._isHighContrast = nativeEvent.isHighContrast; _this._highContrastColors = nativeEvent.highContrastColors; }); return _this; } Object.defineProperty(AppThemeModule.prototype, "isHighContrast", { get: function () { return this._isHighContrast; }, enumerable: false, configurable: true }); Object.defineProperty(AppThemeModule.prototype, "currentHighContrastColors", { get: function () { return this._highContrastColors; }, enumerable: false, configurable: true }); return AppThemeModule; }(react_native_1.NativeEventEmitter)); function throwMissingNativeModule() { invariant(false, 'Cannot use AppTheme module when native RTCAppTheme is not included in the build.\n' + 'Either include it, or check AppTheme.isAvailable before calling any methods.'); } // This module depends on the native `RCTAppTheme` module. If you don't include it, // `AppTheme.isAvailable` will return `false`, and any method calls will throw. var MissingNativeAppThemeShim = /** @class */ (function () { function MissingNativeAppThemeShim() { this.isAvailable = false; this.isHighContrast = false; this.currentHighContrastColors = {}; } MissingNativeAppThemeShim.prototype.addEventListener = function () { throwMissingNativeModule(); }; MissingNativeAppThemeShim.prototype.removeEventListener = function () { throwMissingNativeModule(); }; // EventEmitter MissingNativeAppThemeShim.prototype.addListener = function (_eventType, _listener) { throwMissingNativeModule(); }; MissingNativeAppThemeShim.prototype.removeAllListeners = function () { throwMissingNativeModule(); }; MissingNativeAppThemeShim.prototype.removeListener = function (_eventType, _listener) { throwMissingNativeModule(); }; MissingNativeAppThemeShim.prototype.removeSubscription = function () { throwMissingNativeModule(); }; return MissingNativeAppThemeShim; }()); exports.AppTheme = NativeAppTheme ? new AppThemeModule() : new MissingNativeAppThemeShim(); //# sourceMappingURL=AppTheme.js.map