mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 03:01:51 +08:00
feat(dark-mode): window and page background color
This commit is contained in:
@ -27,6 +27,7 @@ import { ios } from "../utils/utils";
|
||||
const IOS_PLATFORM = "ios";
|
||||
|
||||
const getVisibleViewController = ios.getVisibleViewController;
|
||||
const majorVersion = ios.MajorVersion;
|
||||
|
||||
// NOTE: UIResponder with implementation of window - related to https://github.com/NativeScript/ios-runtime/issues/430
|
||||
// TODO: Refactor the UIResponder to use Typescript extends when this issue is resolved:
|
||||
@ -158,11 +159,19 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
}
|
||||
|
||||
this._window = UIWindow.alloc().initWithFrame(UIScreen.mainScreen.bounds);
|
||||
|
||||
// TODO: add CompatibilityColor.backgroundColor;
|
||||
let backgroundColor;
|
||||
if (majorVersion <= 12) {
|
||||
backgroundColor = UIColor.whiteColor;
|
||||
} else {
|
||||
backgroundColor = UIColor.systemBackgroundColor;
|
||||
}
|
||||
|
||||
// TODO: Expose Window module so that it can we styled from XML & CSS
|
||||
this._window.backgroundColor = UIColor.whiteColor;
|
||||
this._window.backgroundColor = backgroundColor;
|
||||
|
||||
this.notifyAppStarted(notification);
|
||||
|
||||
}
|
||||
|
||||
public notifyAppStarted(notification?: NSNotification) {
|
||||
|
@ -282,7 +282,6 @@ class UIViewControllerImpl extends UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
const whiteColor = new Color("white").ios;
|
||||
export class Page extends PageBase {
|
||||
nativeViewProtected: UIView;
|
||||
viewController: UIViewControllerImpl;
|
||||
@ -294,7 +293,17 @@ export class Page extends PageBase {
|
||||
super();
|
||||
const controller = UIViewControllerImpl.initWithOwner(new WeakRef(this));
|
||||
this.viewController = this._ios = controller;
|
||||
controller.view.backgroundColor = whiteColor;
|
||||
|
||||
// Make transitions look good
|
||||
let backgroundColor;
|
||||
if (majorVersion <= 12) {
|
||||
backgroundColor = UIColor.whiteColor;
|
||||
} else {
|
||||
backgroundColor = UIColor.systemBackgroundColor;
|
||||
}
|
||||
|
||||
// TODO: add CompatibilityColor.backgroundColor;
|
||||
controller.view.backgroundColor = backgroundColor;
|
||||
}
|
||||
|
||||
createNativeView() {
|
||||
|
Reference in New Issue
Block a user