mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(dark-mode): compatibility color
This commit is contained in:
@@ -21,6 +21,7 @@ export * from "./application-common";
|
||||
import { createViewFromEntry } from "../ui/builder";
|
||||
import { ios as iosView, View } from "../ui/core/view";
|
||||
import { Frame, NavigationEntry } from "../ui/frame";
|
||||
import { backgroundColor } from "../color/compatibility-colors.ios";
|
||||
import { device } from "../platform/platform";
|
||||
import { profile } from "../profiling";
|
||||
import { ios } from "../utils/utils";
|
||||
@@ -32,7 +33,6 @@ const ROOT_VIEW_CSS_CLASSES = [
|
||||
`${CSS_CLASS_PREFIX}${IOS_PLATFORM}`
|
||||
];
|
||||
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:
|
||||
@@ -164,17 +164,8 @@ 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 = backgroundColor;
|
||||
this._window.backgroundColor = backgroundColor();
|
||||
|
||||
this.notifyAppStarted(notification);
|
||||
}
|
||||
|
||||
3
tns-core-modules/color/compatibility-colors.d.ts
vendored
Normal file
3
tns-core-modules/color/compatibility-colors.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/**
|
||||
* @module "color/compatibility-colors"
|
||||
*/ /** */
|
||||
6
tns-core-modules/color/compatibility-colors.ios.ts
Normal file
6
tns-core-modules/color/compatibility-colors.ios.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ios } from "../utils/utils";
|
||||
|
||||
const majorVersion = ios.MajorVersion;
|
||||
|
||||
export const activityIndicatorViewStyle = () => { return majorVersion <= 12 ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium };
|
||||
export const backgroundColor = () => { return majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor };
|
||||
@@ -1,23 +1,13 @@
|
||||
import { ActivityIndicatorBase, busyProperty, colorProperty, Color } from "./activity-indicator-common";
|
||||
import { activityIndicatorViewStyle } from "../../color/compatibility-colors.ios";
|
||||
|
||||
export * from "./activity-indicator-common";
|
||||
|
||||
import { ios } from "../../utils/utils";
|
||||
|
||||
const majorVersion = ios.MajorVersion;
|
||||
|
||||
export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
nativeViewProtected: UIActivityIndicatorView;
|
||||
|
||||
createNativeView() {
|
||||
let viewStyle;
|
||||
if (majorVersion <= 12) {
|
||||
viewStyle = UIActivityIndicatorViewStyle.Gray;
|
||||
} else {
|
||||
viewStyle = UIActivityIndicatorViewStyle.Medium;
|
||||
}
|
||||
|
||||
const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(viewStyle);
|
||||
const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(activityIndicatorViewStyle());
|
||||
view.hidesWhenStopped = true;
|
||||
|
||||
return view;
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
PageBase, View, layout, actionBarHiddenProperty, statusBarStyleProperty, Color
|
||||
} from "./page-common";
|
||||
|
||||
import { backgroundColor } from "../../color/compatibility-colors.ios";
|
||||
import { profile } from "../../profiling";
|
||||
import { ios as iosUtils } from "../../utils/utils";
|
||||
|
||||
@@ -295,15 +296,7 @@ export class Page extends PageBase {
|
||||
this.viewController = this._ios = controller;
|
||||
|
||||
// Make transitions look good
|
||||
let backgroundColor;
|
||||
if (majorVersion <= 12) {
|
||||
backgroundColor = UIColor.whiteColor;
|
||||
} else {
|
||||
backgroundColor = UIColor.systemBackgroundColor;
|
||||
}
|
||||
|
||||
// TODO: add CompatibilityColor.backgroundColor;
|
||||
controller.view.backgroundColor = backgroundColor;
|
||||
controller.view.backgroundColor = backgroundColor();
|
||||
}
|
||||
|
||||
createNativeView() {
|
||||
|
||||
Reference in New Issue
Block a user