@nativescript-community/systemui
Version:
Provides API for changing the styles of SystemUI (StatusBar, NavigationBar...) on iOS.
148 lines • 5.49 kB
JavaScript
import { Color, CssProperty, Style, booleanConverter } from '@nativescript/core';
export function applyMixins(derivedCtor, baseCtors, options) {
const omits = options && options.omit ? options.omit : [];
baseCtors.forEach((baseCtor) => {
Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
if (omits.indexOf(name) !== -1) {
return;
}
const descriptor = Object.getOwnPropertyDescriptor(baseCtor.prototype, name);
if (name === 'constructor')
return;
if (descriptor && (descriptor.get || descriptor.set)) {
Object.defineProperty(derivedCtor.prototype, name, descriptor);
}
else {
const oldImpl = derivedCtor.prototype[name];
if (!oldImpl) {
derivedCtor.prototype[name] = baseCtor.prototype[name];
}
else {
derivedCtor.prototype[name] = function (...args) {
if (options) {
if (!!options.override) {
return baseCtor.prototype[name].apply(this, args);
}
else if (!!options.after) {
oldImpl.apply(this, args);
return baseCtor.prototype[name].apply(this, args);
}
else {
baseCtor.prototype[name].apply(this, args);
return oldImpl.apply(this, args);
}
}
else {
baseCtor.prototype[name].apply(this, args);
return oldImpl.apply(this, args);
}
};
}
}
});
Object.getOwnPropertySymbols(baseCtor.prototype).forEach((symbol) => {
if (omits.indexOf(symbol) !== -1) {
return;
}
const oldImpl = derivedCtor.prototype[symbol];
if (!oldImpl) {
derivedCtor.prototype[symbol] = baseCtor.prototype[symbol];
}
else {
derivedCtor.prototype[symbol] = function (...args) {
if (options) {
if (!!options.override) {
return baseCtor.prototype[symbol].apply(this, args);
}
else if (!!options.after) {
oldImpl.apply(this, args);
return baseCtor.prototype[symbol].apply(this, args);
}
else {
baseCtor.prototype[symbol].apply(this, args);
return oldImpl.apply(this, args);
}
}
else {
baseCtor.prototype[symbol].apply(this, args);
return oldImpl.apply(this, args);
}
};
}
});
});
}
function createGetter(key) {
return function () {
return this.style[key];
};
}
function createSetter(key) {
return function (newVal) {
this.style[key] = newVal;
};
}
export const cssProperty = (target, key) => {
Object.defineProperty(target, key, {
get: createGetter(key),
set: createSetter(key),
enumerable: true,
configurable: true
});
};
export const cssNavigationBarColorProperty = new CssProperty({
name: 'navigationBarColor',
cssName: 'navigation-bar-color',
equalityComparer: Color.equals,
valueConverter: (v) => new Color(v)
});
cssNavigationBarColorProperty.register(Style);
export const cssNavigationBarStyleProperty = new CssProperty({
name: 'navigationBarStyle',
cssName: 'navigation-bar-style'
});
cssNavigationBarStyleProperty.register(Style);
export const cssStatusBarColorProperty = new CssProperty({
name: 'statusBarColor',
cssName: 'status-bar-color',
equalityComparer: Color.equals,
valueConverter: (v) => new Color(v)
});
cssStatusBarColorProperty.register(Style);
export const statusBarHiddenProperty = new CssProperty({
name: 'statusBarHidden',
cssName: 'status-bar-hidden',
valueConverter: booleanConverter
});
statusBarHiddenProperty.register(Style);
export const cssWindowBgColorProperty = new CssProperty({
name: 'windowBgColor',
cssName: 'window-bg-color',
equalityComparer: Color.equals,
valueConverter: (v) => new Color(v)
});
cssWindowBgColorProperty.register(Style);
export const keepScreenAwakeProperty = new CssProperty({
name: 'keepScreenAwake',
cssName: 'keep-screen-awake',
valueConverter: booleanConverter
});
keepScreenAwakeProperty.register(Style);
export const screenBrightnessProperty = new CssProperty({
name: 'screenBrightness',
cssName: 'screen-brightness',
valueConverter: parseFloat
});
screenBrightnessProperty.register(Style);
export const screenOrientationProperty = new CssProperty({
name: 'screenOrientation',
cssName: 'screen-orientation'
});
screenOrientationProperty.register(Style);
export function findTopView(view) {
while (view.parent) {
view = view.parent;
}
return view;
}
//# sourceMappingURL=index-common.js.map