@@ -22,8 +22,7 @@ import { Builder } from "../ui/builder";
22
22
import {
23
23
CLASS_PREFIX ,
24
24
getRootViewCssClasses ,
25
- pushToRootViewCssClasses ,
26
- resetRootViewCssClasses
25
+ pushToRootViewCssClasses
27
26
} from "../css/system-classes" ;
28
27
29
28
import { ios as iosView , View } from "../ui/core/view" ;
@@ -308,7 +307,7 @@ class IOSApplication implements IOSApplicationDefinition {
308
307
this . _window . makeKeyAndVisible ( ) ;
309
308
}
310
309
311
- setupRootViewCssClasses ( rootView ) ;
310
+ setRootViewSystemAppearanceCssClass ( rootView ) ;
312
311
rootView . on ( iosView . traitCollectionColorAppearanceChangedEvent , ( ) => {
313
312
const userInterfaceStyle = controller . traitCollection . userInterfaceStyle ;
314
313
const newSystemAppearance = getSystemAppearanceValue ( userInterfaceStyle ) ;
@@ -356,6 +355,8 @@ function createRootView(v?: View) {
356
355
}
357
356
}
358
357
358
+ setRootViewCssClasses ( rootView ) ;
359
+
359
360
return rootView ;
360
361
}
361
362
@@ -398,7 +399,7 @@ export function _start(entry?: string | NavigationEntry) {
398
399
399
400
// Mind root view CSS classes in future work
400
401
// on embedding NativeScript applications
401
- setupRootViewCssClasses ( rootView ) ;
402
+ setRootViewSystemAppearanceCssClass ( rootView ) ;
402
403
rootView . on ( iosView . traitCollectionColorAppearanceChangedEvent , ( ) => {
403
404
const userInterfaceStyle = controller . traitCollection . userInterfaceStyle ;
404
405
const newSystemAppearance = getSystemAppearanceValue ( userInterfaceStyle ) ;
@@ -482,22 +483,24 @@ function setViewControllerView(view: View): void {
482
483
}
483
484
}
484
485
485
- function setupRootViewCssClasses ( rootView : View ) : void {
486
- resetRootViewCssClasses ( ) ;
487
-
486
+ function setRootViewCssClasses ( rootView : View ) : void {
488
487
const deviceType = device . deviceType . toLowerCase ( ) ;
489
488
pushToRootViewCssClasses ( `${ CLASS_PREFIX } ${ IOS_PLATFORM } ` ) ;
490
489
pushToRootViewCssClasses ( `${ CLASS_PREFIX } ${ deviceType } ` ) ;
491
490
pushToRootViewCssClasses ( `${ CLASS_PREFIX } ${ iosApp . orientation } ` ) ;
492
491
493
- if ( majorVersion >= 13 ) {
494
- pushToRootViewCssClasses ( `${ CLASS_PREFIX } ${ iosApp . systemAppearance } ` ) ;
495
- }
496
-
497
492
const rootViewCssClasses = getRootViewCssClasses ( ) ;
498
493
rootViewCssClasses . forEach ( c => rootView . cssClasses . add ( c ) ) ;
499
494
}
500
495
496
+ function setRootViewSystemAppearanceCssClass ( rootView : View ) : void {
497
+ if ( majorVersion >= 13 ) {
498
+ const systemAppearanceCssClass = `${ CLASS_PREFIX } ${ iosApp . systemAppearance } ` ;
499
+ pushToRootViewCssClasses ( systemAppearanceCssClass ) ;
500
+ rootView . cssClasses . add ( systemAppearanceCssClass ) ;
501
+ }
502
+ }
503
+
501
504
export function orientation ( ) : "portrait" | "landscape" | "unknown" {
502
505
return iosApp . orientation ;
503
506
}
0 commit comments