mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
refactor(dark-mode): arrow functions to properties
This commit is contained in:
@ -82,14 +82,13 @@ class CADisplayLinkTarget extends NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IOSApplication implements IOSApplicationDefinition {
|
class IOSApplication implements IOSApplicationDefinition {
|
||||||
|
private _backgroundColor = majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||||
private _delegate: typeof UIApplicationDelegate;
|
private _delegate: typeof UIApplicationDelegate;
|
||||||
private _window: UIWindow;
|
private _window: UIWindow;
|
||||||
private _observers: Array<NotificationObserver>;
|
private _observers: Array<NotificationObserver>;
|
||||||
private _orientation: "portrait" | "landscape" | "unknown";
|
private _orientation: "portrait" | "landscape" | "unknown";
|
||||||
private _rootView: View;
|
private _rootView: View;
|
||||||
|
|
||||||
private getBackgroundColor = () => majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._observers = new Array<NotificationObserver>();
|
this._observers = new Array<NotificationObserver>();
|
||||||
this.addNotificationObserver(UIApplicationDidFinishLaunchingNotification, this.didFinishLaunchingWithOptions.bind(this));
|
this.addNotificationObserver(UIApplicationDidFinishLaunchingNotification, this.didFinishLaunchingWithOptions.bind(this));
|
||||||
@ -162,7 +161,7 @@ class IOSApplication implements IOSApplicationDefinition {
|
|||||||
|
|
||||||
this._window = UIWindow.alloc().initWithFrame(UIScreen.mainScreen.bounds);
|
this._window = UIWindow.alloc().initWithFrame(UIScreen.mainScreen.bounds);
|
||||||
// TODO: Expose Window module so that it can we styled from XML & CSS
|
// TODO: Expose Window module so that it can we styled from XML & CSS
|
||||||
this._window.backgroundColor = this.getBackgroundColor();
|
this._window.backgroundColor = this._backgroundColor;
|
||||||
|
|
||||||
this.notifyAppStarted(notification);
|
this.notifyAppStarted(notification);
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,10 @@ const majorVersion = ios.MajorVersion;
|
|||||||
export class ActivityIndicator extends ActivityIndicatorBase {
|
export class ActivityIndicator extends ActivityIndicatorBase {
|
||||||
nativeViewProtected: UIActivityIndicatorView;
|
nativeViewProtected: UIActivityIndicatorView;
|
||||||
|
|
||||||
private getActivityIndicatorViewStyle = () => majorVersion <= 12 ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium;
|
private _activityIndicatorViewStyle = majorVersion <= 12 ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium;
|
||||||
|
|
||||||
createNativeView() {
|
createNativeView() {
|
||||||
const viewStyle = this.getActivityIndicatorViewStyle();
|
const viewStyle = this._activityIndicatorViewStyle;
|
||||||
const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(viewStyle);
|
const view = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(viewStyle);
|
||||||
view.hidesWhenStopped = true;
|
view.hidesWhenStopped = true;
|
||||||
|
|
||||||
|
@ -286,8 +286,7 @@ export class Page extends PageBase {
|
|||||||
nativeViewProtected: UIView;
|
nativeViewProtected: UIView;
|
||||||
viewController: UIViewControllerImpl;
|
viewController: UIViewControllerImpl;
|
||||||
|
|
||||||
private getBackgroundColor = () => majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
private _backgroundColor = majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||||
|
|
||||||
private _ios: UIViewControllerImpl;
|
private _ios: UIViewControllerImpl;
|
||||||
public _presentedViewController: UIViewController; // used when our page present native viewController without going through our abstraction.
|
public _presentedViewController: UIViewController; // used when our page present native viewController without going through our abstraction.
|
||||||
|
|
||||||
@ -297,7 +296,7 @@ export class Page extends PageBase {
|
|||||||
this.viewController = this._ios = controller;
|
this.viewController = this._ios = controller;
|
||||||
|
|
||||||
// Make transitions look good
|
// Make transitions look good
|
||||||
controller.view.backgroundColor = this.getBackgroundColor();
|
controller.view.backgroundColor = this._backgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
createNativeView() {
|
createNativeView() {
|
||||||
|
@ -24,10 +24,6 @@ export * from "./tabs-common";
|
|||||||
const majorVersion = iosUtils.MajorVersion;
|
const majorVersion = iosUtils.MajorVersion;
|
||||||
// const isPhone = device.deviceType === "Phone";
|
// 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 {
|
class MDCTabBarDelegateImpl extends NSObject implements MDCTabBarDelegate {
|
||||||
public static ObjCProtocols = [MDCTabBarDelegate];
|
public static ObjCProtocols = [MDCTabBarDelegate];
|
||||||
|
|
||||||
@ -74,6 +70,9 @@ class UIPageViewControllerImpl extends UIPageViewController {
|
|||||||
scrollView: UIScrollView;
|
scrollView: UIScrollView;
|
||||||
tabBarDelegate: MDCTabBarDelegateImpl;
|
tabBarDelegate: MDCTabBarDelegateImpl;
|
||||||
|
|
||||||
|
private _backgroundColor = majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||||
|
private _blueColor = majorVersion <= 12 ? UIColor.blueColor : UIColor.systemBlueColor;
|
||||||
|
private _labelColor = majorVersion <= 12 ? UIColor.blackColor : UIColor.labelColor;
|
||||||
private _owner: WeakRef<Tabs>;
|
private _owner: WeakRef<Tabs>;
|
||||||
|
|
||||||
public static initWithOwner(owner: WeakRef<Tabs>): UIPageViewControllerImpl {
|
public static initWithOwner(owner: WeakRef<Tabs>): UIPageViewControllerImpl {
|
||||||
@ -94,10 +93,10 @@ class UIPageViewControllerImpl extends UIPageViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tabBar.delegate = this.tabBarDelegate = MDCTabBarDelegateImpl.initWithOwner(new WeakRef(owner));
|
tabBar.delegate = this.tabBarDelegate = MDCTabBarDelegateImpl.initWithOwner(new WeakRef(owner));
|
||||||
tabBar.tintColor = getBlueColor();
|
tabBar.tintColor = this._blueColor;
|
||||||
tabBar.barTintColor = getBackgroundColor();
|
tabBar.barTintColor = this._backgroundColor;
|
||||||
tabBar.setTitleColorForState(getLabelColor(), MDCTabBarItemState.Normal);
|
tabBar.setTitleColorForState(this._labelColor, MDCTabBarItemState.Normal);
|
||||||
tabBar.setTitleColorForState(getLabelColor(), MDCTabBarItemState.Selected);
|
tabBar.setTitleColorForState(this._labelColor, MDCTabBarItemState.Selected);
|
||||||
|
|
||||||
if (majorVersion >= 13) {
|
if (majorVersion >= 13) {
|
||||||
tabBar.inkColor = UIColor.clearColor;
|
tabBar.inkColor = UIColor.clearColor;
|
||||||
|
@ -116,8 +116,8 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
private _isShowingHint: boolean;
|
private _isShowingHint: boolean;
|
||||||
public _isEditing: boolean;
|
public _isEditing: boolean;
|
||||||
|
|
||||||
private getHintColor = () => majorVersion <= 12 ? UIColor.blackColor.colorWithAlphaComponent(0.22) : UIColor.placeholderTextColor;
|
private _hintColor = majorVersion <= 12 ? UIColor.blackColor.colorWithAlphaComponent(0.22) : UIColor.placeholderTextColor;
|
||||||
private getTextColor = () => majorVersion <= 12 ? null : UIColor.labelColor;
|
private _textColor = majorVersion <= 12 ? null : UIColor.labelColor;
|
||||||
|
|
||||||
createNativeView() {
|
createNativeView() {
|
||||||
const textView = NoScrollAnimationUITextView.new();
|
const textView = NoScrollAnimationUITextView.new();
|
||||||
@ -179,7 +179,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
// Use semi-transparent version of color for back-compatibility
|
// Use semi-transparent version of color for back-compatibility
|
||||||
this.nativeTextViewProtected.textColor = color.ios.colorWithAlphaComponent(0.22);
|
this.nativeTextViewProtected.textColor = color.ios.colorWithAlphaComponent(0.22);
|
||||||
} else {
|
} else {
|
||||||
this.nativeTextViewProtected.textColor = this.getHintColor();
|
this.nativeTextViewProtected.textColor = this._hintColor;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const color = this.style.color;
|
const color = this.style.color;
|
||||||
@ -188,8 +188,8 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
this.nativeTextViewProtected.textColor = color.ios;
|
this.nativeTextViewProtected.textColor = color.ios;
|
||||||
this.nativeTextViewProtected.tintColor = color.ios;
|
this.nativeTextViewProtected.tintColor = color.ios;
|
||||||
} else {
|
} else {
|
||||||
this.nativeTextViewProtected.textColor = this.getTextColor();
|
this.nativeTextViewProtected.textColor = this._textColor;
|
||||||
this.nativeTextViewProtected.tintColor = this.getTextColor();
|
this.nativeTextViewProtected.tintColor = this._textColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user