@material-native-ui/theme-provider
Version:
React Native Theme a abstraction over StyleSheet.
29 lines (20 loc) • 903 B
JavaScript
;
exports.__esModule = true;
exports.default = void 0;
var _reactNative = require("react-native");
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const StyleSheet = { ..._reactNative.StyleSheet,
create: styleInput => typeof styleInput === 'function' ? new ThemeFactory(styleInput) : _reactNative.StyleSheet.create(styleInput)
};
class ThemeFactory {
constructor(fn) {
_defineProperty(this, "getStyles", theme => {
return _reactNative.StyleSheet.create(this.parseStyles(theme));
});
_defineProperty(this, "parseStyles", context => this.isObject ? this.fn : this.fn(context));
this.fn = fn;
this.isObject = typeof fn === "object";
}
}
var _default = StyleSheet;
exports.default = _default;