forked from NativeScript/NativeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication-common.ts
More file actions
65 lines (46 loc) · 1.96 KB
/
application-common.ts
File metadata and controls
65 lines (46 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require("globals");
import definition = require("application");
import observable = require("data/observable");
import frame = require("ui/frame");
import cssSelector = require("ui/styling/css-selector");
import * as fileSystemModule from "file-system";
import * as styleScopeModule from "ui/styling/style-scope";
var events = new observable.Observable();
global.moduleMerge(events, exports);
export var launchEvent = "launch";
export var suspendEvent = "suspend";
export var resumeEvent = "resume";
export var exitEvent = "exit";
export var lowMemoryEvent = "lowMemory";
export var uncaughtErrorEvent = "uncaughtError";
export var orientationChangedEvent = "orientationChanged";
export var mainModule: string;
export var mainEntry: frame.NavigationEntry;
export var cssFile: string = "app.css"
export var cssSelectorsCache: Array<cssSelector.CssSelector> = undefined;
export var resources: any = {};
export var onUncaughtError: (error: definition.NativeScriptError) => void = undefined;
export var onLaunch: (context: any) => any = undefined;
export var onSuspend: () => any = undefined;
export var onResume: () => any = undefined;
export var onExit: () => any = undefined;
export var onLowMemory: () => any = undefined;
export var android = undefined;
export var ios = undefined;
export function loadCss(cssFile?: string): Array<cssSelector.CssSelector> {
if (!cssFile) {
return undefined;
}
var result: Array<cssSelector.CssSelector>;
var fs: typeof fileSystemModule = require("file-system");
var styleScope: typeof styleScopeModule = require("ui/styling/style-scope");
var cssFileName = fs.path.join(fs.knownFolders.currentApp().path, cssFile);
if (fs.File.exists(cssFileName)) {
var file = fs.File.fromPath(cssFileName);
var applicationCss = file.readTextSync();
if (applicationCss) {
result = styleScope.StyleScope.createSelectorsFromCss(applicationCss, cssFileName);
}
}
return result;
}