-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathmain-page.ts
More file actions
71 lines (59 loc) · 2.34 KB
/
main-page.ts
File metadata and controls
71 lines (59 loc) · 2.34 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
66
67
68
69
70
71
import { Application, EventData, Page, SceneEventData, SceneEvents, Utils } from '@nativescript/core';
import { HelloWorldModel } from './main-view-model';
let initSceneEvents = false;
export function navigatingTo(args: EventData) {
const page = <Page>args.object;
page.bindingContext = new HelloWorldModel();
// Testing setting window background color
// if (__APPLE__) {
// Utils.ios.setWindowBackgroundColor('blue');
// }
// Note: can test global scene handling by uncommenting following
// Can also view the 'multiple-scenes' demo page in isolation
// setupSceneEvents();
}
function setupSceneEvents() {
if (initSceneEvents) {
return;
}
initSceneEvents = true;
if (__APPLE__) {
if (Application.ios.supportsScenes()) {
console.log('Supports multiple scenes:', Application.ios.supportsMultipleScenes());
// Get all windows and scenes
const windows = Application.ios.getAllWindows();
const scenes = Application.ios.getWindowScenes();
const primaryWindow = Application.ios.getPrimaryWindow();
console.log(`App has ${windows.length} windows`);
console.log(`App has ${scenes.length} scenes`);
console.log('Primary window:', primaryWindow);
// Check if using scene lifecycle
if (Application.ios.isUsingSceneLifecycle()) {
console.log('App is using scene-based lifecycle');
}
// Listen to scene events
Application.on(SceneEvents.sceneWillConnect, (args: SceneEventData) => {
console.log('New scene connecting:', args.scene);
console.log('Window:', args.window);
console.log('Connection options:', args.connectionOptions);
});
Application.on(SceneEvents.sceneDidActivate, (args: SceneEventData) => {
console.log('Scene became active:', args.scene);
});
Application.on(SceneEvents.sceneWillResignActive, (args: SceneEventData) => {
console.log('Scene will resign active:', args.scene);
});
Application.on(SceneEvents.sceneDidEnterBackground, (args: SceneEventData) => {
console.log('Scene entered background:', args.scene);
});
Application.on(SceneEvents.sceneWillEnterForeground, (args: SceneEventData) => {
console.log('Scene will enter foreground:', args.scene);
});
Application.on(SceneEvents.sceneDidDisconnect, (args: SceneEventData) => {
console.log('Scene disconnected:', args.scene);
});
} else {
console.log('Traditional single-window app');
}
}
}