diff --git a/apps/toolbox/src/app.css b/apps/toolbox/src/app.css index 348e6261c..82f893d56 100644 --- a/apps/toolbox/src/app.css +++ b/apps/toolbox/src/app.css @@ -266,4 +266,76 @@ Button { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; -} \ No newline at end of file +} + +/* Multiple Scenes Demo Styles */ + +.card { + background-color: #f8f9fa; + border-radius: 12; + border-width: 1; + border-color: #e9ecef; + margin-bottom: 15; +} + +.code-block { + background-color: #2d3748; + color: #e2e8f0; + padding: 15; + border-radius: 8; + font-family: "Courier New", monospace; + font-size: 12; +} + +.event-item { + background-color: #f1f3f4; + border-radius: 6; + margin-bottom: 5; +} + +.event-item:nth-child(even) { + background-color: #e8eaed; +} + +.border { + border-width: 1; + border-color: #dee2e6; + border-radius: 8; + background-color: white; +} + +.btn { + border-radius: 8; + font-weight: bold; +} + +.btn-outline { + background-color: transparent; + color: #007bff; + border-width: 2; + border-color: #007bff; +} + +.h3 { + font-size: 18; + font-weight: bold; + color: #2c3e50; +} + +.body { + font-size: 14; + color: #495057; +} + +.caption { + font-size: 12; + color: #6c757d; +} + +.font-weight-bold { + font-weight: bold; +} + +.text-center { + text-align: center; +} diff --git a/apps/toolbox/src/main-page.ts b/apps/toolbox/src/main-page.ts index 83f8dc9b0..d64a8d72c 100644 --- a/apps/toolbox/src/main-page.ts +++ b/apps/toolbox/src/main-page.ts @@ -1,12 +1,71 @@ -import { EventData, Page, Utils } from '@nativescript/core'; +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 = args.object; page.bindingContext = new HelloWorldModel(); // Testing setting window background color - // if (global.isIOS) { + // 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'); + } + } } diff --git a/apps/toolbox/src/main-page.xml b/apps/toolbox/src/main-page.xml index 6752731e1..1286874aa 100644 --- a/apps/toolbox/src/main-page.xml +++ b/apps/toolbox/src/main-page.xml @@ -18,6 +18,7 @@