mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00
refactor(dark-mode): remove compatibility color module
This commit is contained in:
@ -20,7 +20,6 @@ import { createViewFromEntry } from "../ui/builder";
|
||||
import { CLASS_PREFIX, getRootViewCssClasses, pushToRootViewCssClasses } from "../css/system-classes";
|
||||
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";
|
||||
@ -28,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:
|
||||
@ -88,6 +88,8 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
private _orientation: "portrait" | "landscape" | "unknown";
|
||||
private _rootView: View;
|
||||
|
||||
private getBackgroundColor = () => majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
|
||||
constructor() {
|
||||
this._observers = new Array<NotificationObserver>();
|
||||
this.addNotificationObserver(UIApplicationDidFinishLaunchingNotification, this.didFinishLaunchingWithOptions.bind(this));
|
||||
@ -160,7 +162,7 @@ class IOSApplication implements IOSApplicationDefinition {
|
||||
|
||||
this._window = UIWindow.alloc().initWithFrame(UIScreen.mainScreen.bounds);
|
||||
// TODO: Expose Window module so that it can we styled from XML & CSS
|
||||
this._window.backgroundColor = backgroundColor();
|
||||
this._window.backgroundColor = this.getBackgroundColor();
|
||||
|
||||
this.notifyAppStarted(notification);
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
/**
|
||||
* @module "color/compatibility-colors"
|
||||
*/ /** */
|
@ -1,12 +0,0 @@
|
||||
import { ios } from "../utils/utils";
|
||||
|
||||
const majorVersion = ios.MajorVersion;
|
||||
|
||||
export const activityIndicatorViewStyle = () => majorVersion <= 12 ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium;
|
||||
|
||||
// UI Element Colors
|
||||
export const backgroundColor = () => majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
export const labelColor = () => majorVersion <= 12 ? UIColor.blackColor : UIColor.labelColor;
|
||||
|
||||
// Standard Colors
|
||||
export const blueColor = () => majorVersion <= 12 ? UIColor.blueColor : UIColor.systemBlueColor;
|
@ -1,13 +1,19 @@
|
||||
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;
|
||||
|
||||
private getActivityIndicatorViewStyle = () => majorVersion <= 12 ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium;
|
||||
|
||||
createNativeView() {
|
||||
const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(activityIndicatorViewStyle());
|
||||
const viewStyle = this.getActivityIndicatorViewStyle();
|
||||
const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(viewStyle);
|
||||
view.hidesWhenStopped = true;
|
||||
|
||||
return view;
|
||||
|
@ -8,7 +8,6 @@ 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";
|
||||
|
||||
@ -287,6 +286,8 @@ export class Page extends PageBase {
|
||||
nativeViewProtected: UIView;
|
||||
viewController: UIViewControllerImpl;
|
||||
|
||||
private getBackgroundColor = () => majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
|
||||
private _ios: UIViewControllerImpl;
|
||||
public _presentedViewController: UIViewController; // used when our page present native viewController without going through our abstraction.
|
||||
|
||||
@ -296,7 +297,7 @@ export class Page extends PageBase {
|
||||
this.viewController = this._ios = controller;
|
||||
|
||||
// Make transitions look good
|
||||
controller.view.backgroundColor = backgroundColor();
|
||||
controller.view.backgroundColor = this.getBackgroundColor();
|
||||
}
|
||||
|
||||
createNativeView() {
|
||||
|
@ -6,7 +6,6 @@ import { TextTransform } from "../text-base";
|
||||
|
||||
// Requires
|
||||
import { Color } from "../../color";
|
||||
import { backgroundColor, blueColor, labelColor } from "../../color/compatibility-colors.ios";
|
||||
import { fromFileOrResource, fromFontIconCode, ImageSource } from "../../image-source";
|
||||
import { ios as iosUtils, isFontIconURI, layout } from "../../utils/utils";
|
||||
import { ios as iosView, View } from "../core/view";
|
||||
@ -25,6 +24,10 @@ export * from "./tabs-common";
|
||||
const majorVersion = iosUtils.MajorVersion;
|
||||
// const isPhone = device.deviceType === "Phone";
|
||||
|
||||
const getBackgroundColor = () => majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
const getBlueColor = () => majorVersion <= 12 ? UIColor.blueColor : UIColor.systemBlueColor;
|
||||
const getLabelColor = () => majorVersion <= 12 ? UIColor.blackColor : UIColor.labelColor;
|
||||
|
||||
class MDCTabBarDelegateImpl extends NSObject implements MDCTabBarDelegate {
|
||||
public static ObjCProtocols = [MDCTabBarDelegate];
|
||||
|
||||
@ -91,10 +94,10 @@ class UIPageViewControllerImpl extends UIPageViewController {
|
||||
}
|
||||
|
||||
tabBar.delegate = this.tabBarDelegate = MDCTabBarDelegateImpl.initWithOwner(new WeakRef(owner));
|
||||
tabBar.tintColor = blueColor();
|
||||
tabBar.barTintColor = backgroundColor();
|
||||
tabBar.setTitleColorForState(labelColor(), MDCTabBarItemState.Normal);
|
||||
tabBar.setTitleColorForState(labelColor(), MDCTabBarItemState.Selected);
|
||||
tabBar.tintColor = getBlueColor();
|
||||
tabBar.barTintColor = getBackgroundColor();
|
||||
tabBar.setTitleColorForState(getLabelColor(), MDCTabBarItemState.Normal);
|
||||
tabBar.setTitleColorForState(getLabelColor(), MDCTabBarItemState.Selected);
|
||||
|
||||
if (majorVersion >= 13) {
|
||||
tabBar.inkColor = UIColor.clearColor;
|
||||
|
Reference in New Issue
Block a user