Allow updates to application CSS rules.

Expose an `application.addCss` method and hide `application.cssSelectors`
from end-user typings. Update StyleScope's with new application selectors
on style application.

NOT updating existing controls/views unless reloaded, or forced (via a
change to className, etc).
This commit is contained in:
Hristo Deshev
2016-03-24 14:44:49 +02:00
parent 04cb12f86b
commit 9daa948887
8 changed files with 184 additions and 40 deletions

View File

@@ -322,7 +322,20 @@ function onConfigurationChanged(context: android.content.Context, intent: androi
}
function loadCss() {
typedExports.cssSelectorsCache = typedExports.loadCss(typedExports.cssFile);
//HACK: identical to application.ios.ts
typedExports.appSelectors = typedExports.loadCss(typedExports.cssFile) || [];
if (typedExports.appSelectors.length > 0) {
typedExports.mergeCssSelectors(typedExports);
}
}
export function addCss(cssText: string) {
//HACK: identical to application.ios.ts
const parsed = typedExports.parseCss(cssText);
if (parsed) {
typedExports.additionalSelectors.push.apply(typedExports.additionalSelectors, parsed);
typedExports.mergeCssSelectors(typedExports);
}
}
global.__onLiveSync = function () {
@@ -351,4 +364,4 @@ global.__onUncaughtError = function (error: definition.NativeScriptError) {
}
typedExports.notify({ eventName: typedExports.uncaughtErrorEvent, object: appModule.android, android: error });
}
}