Skip to content

Commit 96733c2

Browse files
authored
feat(ios): multi-window support (#10786)
1 parent c8c7410 commit 96733c2

File tree

13 files changed

+1622
-70
lines changed

13 files changed

+1622
-70
lines changed

apps/toolbox/src/app.css

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,76 @@ Button {
266266
overflow: hidden;
267267
text-overflow: ellipsis;
268268
white-space: nowrap;
269-
}
269+
}
270+
271+
/* Multiple Scenes Demo Styles */
272+
273+
.card {
274+
background-color: #f8f9fa;
275+
border-radius: 12;
276+
border-width: 1;
277+
border-color: #e9ecef;
278+
margin-bottom: 15;
279+
}
280+
281+
.code-block {
282+
background-color: #2d3748;
283+
color: #e2e8f0;
284+
padding: 15;
285+
border-radius: 8;
286+
font-family: "Courier New", monospace;
287+
font-size: 12;
288+
}
289+
290+
.event-item {
291+
background-color: #f1f3f4;
292+
border-radius: 6;
293+
margin-bottom: 5;
294+
}
295+
296+
.event-item:nth-child(even) {
297+
background-color: #e8eaed;
298+
}
299+
300+
.border {
301+
border-width: 1;
302+
border-color: #dee2e6;
303+
border-radius: 8;
304+
background-color: white;
305+
}
306+
307+
.btn {
308+
border-radius: 8;
309+
font-weight: bold;
310+
}
311+
312+
.btn-outline {
313+
background-color: transparent;
314+
color: #007bff;
315+
border-width: 2;
316+
border-color: #007bff;
317+
}
318+
319+
.h3 {
320+
font-size: 18;
321+
font-weight: bold;
322+
color: #2c3e50;
323+
}
324+
325+
.body {
326+
font-size: 14;
327+
color: #495057;
328+
}
329+
330+
.caption {
331+
font-size: 12;
332+
color: #6c757d;
333+
}
334+
335+
.font-weight-bold {
336+
font-weight: bold;
337+
}
338+
339+
.text-center {
340+
text-align: center;
341+
}

apps/toolbox/src/main-page.ts

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,71 @@
1-
import { EventData, Page, Utils } from '@nativescript/core';
1+
import { Application, EventData, Page, SceneEventData, SceneEvents, Utils } from '@nativescript/core';
22
import { HelloWorldModel } from './main-view-model';
33

4+
let initSceneEvents = false;
45
export function navigatingTo(args: EventData) {
56
const page = <Page>args.object;
67
page.bindingContext = new HelloWorldModel();
78

89
// Testing setting window background color
9-
// if (global.isIOS) {
10+
// if (__APPLE__) {
1011
// Utils.ios.setWindowBackgroundColor('blue');
1112
// }
13+
14+
// Note: can test global scene handling by uncommenting following
15+
// Can also view the 'multiple-scenes' demo page in isolation
16+
// setupSceneEvents();
17+
}
18+
19+
function setupSceneEvents() {
20+
if (initSceneEvents) {
21+
return;
22+
}
23+
initSceneEvents = true;
24+
if (__APPLE__) {
25+
if (Application.ios.supportsScenes()) {
26+
console.log('Supports multiple scenes:', Application.ios.supportsMultipleScenes());
27+
// Get all windows and scenes
28+
const windows = Application.ios.getAllWindows();
29+
const scenes = Application.ios.getWindowScenes();
30+
const primaryWindow = Application.ios.getPrimaryWindow();
31+
32+
console.log(`App has ${windows.length} windows`);
33+
console.log(`App has ${scenes.length} scenes`);
34+
console.log('Primary window:', primaryWindow);
35+
36+
// Check if using scene lifecycle
37+
if (Application.ios.isUsingSceneLifecycle()) {
38+
console.log('App is using scene-based lifecycle');
39+
}
40+
41+
// Listen to scene events
42+
Application.on(SceneEvents.sceneWillConnect, (args: SceneEventData) => {
43+
console.log('New scene connecting:', args.scene);
44+
console.log('Window:', args.window);
45+
console.log('Connection options:', args.connectionOptions);
46+
});
47+
48+
Application.on(SceneEvents.sceneDidActivate, (args: SceneEventData) => {
49+
console.log('Scene became active:', args.scene);
50+
});
51+
52+
Application.on(SceneEvents.sceneWillResignActive, (args: SceneEventData) => {
53+
console.log('Scene will resign active:', args.scene);
54+
});
55+
56+
Application.on(SceneEvents.sceneDidEnterBackground, (args: SceneEventData) => {
57+
console.log('Scene entered background:', args.scene);
58+
});
59+
60+
Application.on(SceneEvents.sceneWillEnterForeground, (args: SceneEventData) => {
61+
console.log('Scene will enter foreground:', args.scene);
62+
});
63+
64+
Application.on(SceneEvents.sceneDidDisconnect, (args: SceneEventData) => {
65+
console.log('Scene disconnected:', args.scene);
66+
});
67+
} else {
68+
console.log('Traditional single-window app');
69+
}
70+
}
1271
}

apps/toolbox/src/main-page.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<Button text="image-handling" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1919
<Button text="labels" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
2020
<Button text="list-page" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
21+
<Button text="multiple-scenes" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
2122
<Button text="root-layout" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
2223
<Button text="scroll-view" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
2324
<Button text="status-bar" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />

0 commit comments

Comments
 (0)