mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
Merge branch 'master' into remove-tns-core-modules-mentions
This commit is contained in:
@ -93,7 +93,7 @@ class CADisplayLinkTarget extends NSObject {
|
||||
/* tslint:disable */
|
||||
export class iOSApplication implements iOSApplicationDefinition {
|
||||
/* tslint:enable */
|
||||
private _backgroundColor = majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
private _backgroundColor = (majorVersion <= 12 || !UIColor.systemBackgroundColor) ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
private _delegate: typeof UIApplicationDelegate;
|
||||
private _window: UIWindow;
|
||||
private _observers: Array<NotificationObserver>;
|
||||
@ -125,7 +125,6 @@ export class iOSApplication implements iOSApplicationDefinition {
|
||||
}
|
||||
|
||||
get systemAppearance(): "light" | "dark" | null {
|
||||
|
||||
// userInterfaceStyle is available on UITraitCollection since iOS 12.
|
||||
if (majorVersion <= 11) {
|
||||
return null;
|
||||
|
@ -9,7 +9,7 @@ const majorVersion = ios.MajorVersion;
|
||||
export class ActivityIndicator extends ActivityIndicatorBase {
|
||||
nativeViewProtected: UIActivityIndicatorView;
|
||||
|
||||
private _activityIndicatorViewStyle = majorVersion <= 12 ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium;
|
||||
private _activityIndicatorViewStyle = (majorVersion <= 12 || !UIActivityIndicatorViewStyle.Medium) ? UIActivityIndicatorViewStyle.Gray : UIActivityIndicatorViewStyle.Medium;
|
||||
|
||||
createNativeView() {
|
||||
const viewStyle = this._activityIndicatorViewStyle;
|
||||
|
@ -93,7 +93,9 @@ class UITabBarControllerImpl extends UITabBarController {
|
||||
|
||||
if (majorVersion >= 13) {
|
||||
const owner = this._owner.get();
|
||||
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
if (owner &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner });
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +312,9 @@ export namespace ios {
|
||||
|
||||
if (majorVersion >= 13) {
|
||||
const owner = this.owner.get();
|
||||
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
if (owner &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
owner.notify({ eventName: traitCollectionColorAppearanceChangedEvent, object: owner });
|
||||
}
|
||||
}
|
||||
|
@ -59,12 +59,12 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
const top = FrameBase.topmost();
|
||||
if (top && top.canGoBack()) {
|
||||
top.goBack();
|
||||
|
||||
|
||||
return true;
|
||||
} else if (top) {
|
||||
let parentFrameCanGoBack = false;
|
||||
let parentFrame = <FrameBase>getAncestor(top, "Frame");
|
||||
|
||||
|
||||
while (parentFrame && !parentFrameCanGoBack) {
|
||||
if (parentFrame && parentFrame.canGoBack()) {
|
||||
parentFrameCanGoBack = true;
|
||||
@ -72,18 +72,18 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
parentFrame = <FrameBase>getAncestor(parentFrame, "Frame");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (parentFrame && parentFrameCanGoBack) {
|
||||
parentFrame.goBack();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (frameStack.length > 1) {
|
||||
top._popFromFrameStack();
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -205,11 +205,11 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition {
|
||||
traceWrite(`NAVIGATE`, traceCategories.Navigation);
|
||||
}
|
||||
|
||||
this._pushInFrameStack();
|
||||
|
||||
const entry = buildEntryFromArgs(param);
|
||||
const page = Builder.createViewFromEntry(entry) as Page;
|
||||
|
||||
this._pushInFrameStack();
|
||||
|
||||
const backstackEntry: BackstackEntry = {
|
||||
entry: entry,
|
||||
resolvedPage: page,
|
||||
|
@ -11,7 +11,7 @@ import * as application from "../../application";
|
||||
|
||||
import {
|
||||
_stack, FrameBase, NavigationType, Observable,
|
||||
traceCategories, traceEnabled, traceError, traceWrite, View
|
||||
traceCategories, traceEnabled, traceError, traceWrite, View, Color
|
||||
} from "./frame-common";
|
||||
|
||||
import {
|
||||
@ -88,6 +88,7 @@ function getAttachListener(): android.view.View.OnAttachStateChangeListener {
|
||||
}
|
||||
|
||||
export class Frame extends FrameBase {
|
||||
public _originalBackground: any;
|
||||
private _android: AndroidFrame;
|
||||
private _containerViewId: number = -1;
|
||||
private _tearDownPending = false;
|
||||
@ -238,6 +239,16 @@ export class Frame extends FrameBase {
|
||||
this.disposeCurrentFragment();
|
||||
}
|
||||
|
||||
onLoaded(): void {
|
||||
if (this._originalBackground) {
|
||||
this.backgroundColor = null;
|
||||
this.backgroundColor = this._originalBackground;
|
||||
this._originalBackground = null;
|
||||
}
|
||||
|
||||
super.onLoaded();
|
||||
}
|
||||
|
||||
onUnloaded() {
|
||||
super.onUnloaded();
|
||||
|
||||
@ -471,6 +482,13 @@ export class Frame extends FrameBase {
|
||||
}
|
||||
|
||||
public createNativeView() {
|
||||
// Create native view with available _currentEntry occur in Don't Keep Activities
|
||||
// scenario when Activity is recreated on app suspend/resume. Push frame back in frame stack
|
||||
// since it was removed in disposeNativeView() method.
|
||||
if (this._currentEntry) {
|
||||
this._pushInFrameStack();
|
||||
}
|
||||
|
||||
return new org.nativescript.widgets.ContentLayout(this._context);
|
||||
}
|
||||
|
||||
@ -945,6 +963,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
|
||||
|
||||
if (hasRemovingParent) {
|
||||
const bitmapDrawable = new android.graphics.drawable.BitmapDrawable(application.android.context.getResources(), this.backgroundBitmap);
|
||||
this.frame._originalBackground = this.frame.backgroundColor || new Color("White");
|
||||
this.frame.nativeViewProtected.setBackgroundDrawable(bitmapDrawable);
|
||||
this.backgroundBitmap = null;
|
||||
}
|
||||
|
@ -541,7 +541,9 @@ class UINavigationControllerImpl extends UINavigationController {
|
||||
|
||||
if (majorVersion >= 13) {
|
||||
const owner = this._owner.get();
|
||||
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
if (owner &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
owner.notify({ eventName: iosViewHelper.traitCollectionColorAppearanceChangedEvent, object: owner });
|
||||
}
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ export class HtmlView extends HtmlViewBase {
|
||||
null
|
||||
);
|
||||
|
||||
if (majorVersion >= 13) {
|
||||
if (majorVersion >= 13 && UIColor.labelColor) {
|
||||
this.nativeViewProtected.textColor = UIColor.labelColor;
|
||||
}
|
||||
}
|
||||
|
@ -287,7 +287,9 @@ class UIViewControllerImpl extends UIViewController {
|
||||
|
||||
if (majorVersion >= 13) {
|
||||
const owner = this._owner.get();
|
||||
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
if (owner &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner });
|
||||
}
|
||||
}
|
||||
@ -298,7 +300,7 @@ export class Page extends PageBase {
|
||||
nativeViewProtected: UIView;
|
||||
viewController: UIViewControllerImpl;
|
||||
|
||||
private _backgroundColor = majorVersion <= 12 ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
private _backgroundColor = (majorVersion <= 12 && !UIColor.systemBackgroundColor) ? UIColor.whiteColor : UIColor.systemBackgroundColor;
|
||||
private _ios: UIViewControllerImpl;
|
||||
public _presentedViewController: UIViewController; // used when our page present native viewController without going through our abstraction.
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
// Types
|
||||
import { TabNavigationBase as TabNavigationBaseDefinition, SelectedIndexChangedEventData } from ".";
|
||||
import { TabContentItem } from "../tab-content-item";
|
||||
import { TabStrip } from "../tab-strip";
|
||||
import { TabStripItem } from "../tab-strip-item";
|
||||
import { ViewBase, AddArrayFromBuilder, AddChildFromBuilder, EventData } from "../../core/view";
|
||||
|
||||
// Requires
|
||||
import { View, Property, CoercibleProperty, isIOS, Color } from "../../core/view";
|
||||
import { View, Property, CoercibleProperty, isIOS } from "../../core/view";
|
||||
import { TabContentItem } from "../tab-content-item";
|
||||
import { TabStrip } from "../tab-strip";
|
||||
|
||||
// TODO: Impl trace
|
||||
// export const traceCategory = "TabView";
|
||||
@ -29,14 +29,14 @@ export class TabNavigationBase extends View implements TabNavigationBaseDefiniti
|
||||
}
|
||||
|
||||
public _addChildFromBuilder(name: string, value: any): void {
|
||||
if (name === "TabContentItem") {
|
||||
if (value instanceof TabContentItem) {
|
||||
if (!this.items) {
|
||||
this.items = new Array<TabContentItem>();
|
||||
}
|
||||
this.items.push(<TabContentItem>value);
|
||||
this._addView(value);
|
||||
// selectedIndexProperty.coerce(this);
|
||||
} else if (name === "TabStrip") {
|
||||
} else if (value instanceof TabStrip) {
|
||||
// Setting tabStrip will trigger onTabStripChanged
|
||||
this.tabStrip = value;
|
||||
}
|
||||
|
@ -3,8 +3,6 @@ import { TabStripItem as TabStripItemDefinition } from ".";
|
||||
import { PropertyChangeData } from "../../../data/observable";
|
||||
import { TabNavigationBase } from "../tab-navigation-base";
|
||||
import { TabStrip } from "../tab-strip";
|
||||
import { Image } from "../../image/image";
|
||||
import { Label } from "../../label/label";
|
||||
import { Color } from "../../../color";
|
||||
import { AddChildFromBuilder } from "../../core/view";
|
||||
|
||||
@ -12,8 +10,9 @@ import { AddChildFromBuilder } from "../../core/view";
|
||||
import {
|
||||
View, ViewBase, CSSType, backgroundColorProperty, backgroundInternalProperty, PseudoClassHandler
|
||||
} from "../../core/view";
|
||||
import { Tabs } from "../../tabs";
|
||||
import { isIOS } from "../../../platform";
|
||||
import { Image } from "../../image/image";
|
||||
import { Label } from "../../label/label";
|
||||
|
||||
export * from "../../core/view";
|
||||
export const traceCategory = "TabView";
|
||||
@ -173,14 +172,14 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
|
||||
}
|
||||
|
||||
public _addChildFromBuilder(name: string, value: any): void {
|
||||
if (name === "Image") {
|
||||
if (value instanceof Image) {
|
||||
this.image = <Image>value;
|
||||
this.iconSource = (<Image>value).src;
|
||||
this._addView(value);
|
||||
// selectedIndexProperty.coerce(this);
|
||||
}
|
||||
|
||||
if (name === "Label") {
|
||||
if (value instanceof Label) {
|
||||
this.label = <Label>value;
|
||||
this.title = (<Label>value).text;
|
||||
this._addView(value);
|
||||
@ -214,6 +213,8 @@ export class TabStripItem extends View implements TabStripItemDefinition, AddChi
|
||||
const tabStripParent = parent && <TabNavigationBase>parent.parent;
|
||||
if (this._index === tabStripParent.selectedIndex &&
|
||||
!(isIOS && tabStripParent.cssType.toLowerCase() === "tabs")) {
|
||||
// HACK: tabStripParent instanceof Tabs creates a circular dependency
|
||||
// HACK: tabStripParent.cssType === "Tabs" is a hacky workaround
|
||||
this._goToVisualState("highlighted");
|
||||
}
|
||||
} else {
|
||||
|
@ -2,7 +2,6 @@
|
||||
import { Color } from "../../../color";
|
||||
import { AddArrayFromBuilder, AddChildFromBuilder, EventData, ViewBase } from "../../core/view";
|
||||
import { TabNavigationBase } from "../tab-navigation-base";
|
||||
import { TabStripItem } from "../tab-strip-item";
|
||||
import { TabStripItemEventData, TabStrip as TabStripDefinition } from "./";
|
||||
|
||||
// Requires
|
||||
@ -10,6 +9,7 @@ import {
|
||||
backgroundColorProperty, backgroundInternalProperty, booleanConverter,
|
||||
colorProperty, CSSType, fontInternalProperty, Property, View
|
||||
} from "../../core/view";
|
||||
import { TabStripItem } from "../tab-strip-item";
|
||||
import { textTransformProperty } from "../../text-base";
|
||||
|
||||
export const traceCategory = "TabView";
|
||||
@ -44,7 +44,7 @@ export class TabStrip extends View implements TabStripDefinition, AddChildFromBu
|
||||
}
|
||||
|
||||
public _addChildFromBuilder(name: string, value: any): void {
|
||||
if (name === "TabStripItem") {
|
||||
if (value instanceof TabStripItem) {
|
||||
if (!this.items) {
|
||||
this.items = new Array<TabStripItem>();
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ export class TabViewBase extends View implements TabViewDefinition, AddChildFrom
|
||||
}
|
||||
|
||||
public _addChildFromBuilder(name: string, value: any): void {
|
||||
if (name === "TabViewItem") {
|
||||
if (value instanceof TabViewItemBase) {
|
||||
if (!this.items) {
|
||||
this.items = new Array<TabViewItemBase>();
|
||||
}
|
||||
|
@ -542,7 +542,11 @@ export class TabView extends TabViewBase {
|
||||
|
||||
public _loadUnloadTabItems(newIndex: number) {
|
||||
const items = this.items;
|
||||
const lastIndex = this.items.length - 1;
|
||||
if (!items) {
|
||||
return;
|
||||
}
|
||||
|
||||
const lastIndex = items.length - 1;
|
||||
const offsideItems = this.androidTabsPosition === "top" ? this.androidOffscreenTabLimit : 1;
|
||||
|
||||
let toUnload = [];
|
||||
|
@ -78,7 +78,9 @@ class UITabBarControllerImpl extends UITabBarController {
|
||||
|
||||
if (majorVersion >= 13) {
|
||||
const owner = this._owner.get();
|
||||
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
if (owner &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner });
|
||||
}
|
||||
}
|
||||
|
@ -465,7 +465,11 @@ export class Tabs extends TabsBase {
|
||||
|
||||
public _loadUnloadTabItems(newIndex: number) {
|
||||
const items = this.items;
|
||||
const lastIndex = this.items.length - 1;
|
||||
if (!items) {
|
||||
return;
|
||||
}
|
||||
|
||||
const lastIndex = items.length - 1;
|
||||
const offsideItems = this.offscreenTabLimit;
|
||||
|
||||
let toUnload = [];
|
||||
|
@ -24,7 +24,7 @@ export * from "./tabs-common";
|
||||
const majorVersion = iosUtils.MajorVersion;
|
||||
|
||||
// Equivalent to dispatch_async(dispatch_get_main_queue(...)) call
|
||||
const invokeOnRunLoop = (function() {
|
||||
const invokeOnRunLoop = (function () {
|
||||
const runloop = CFRunLoopGetMain();
|
||||
|
||||
return (action: () => any) => {
|
||||
@ -100,7 +100,7 @@ class UIPageViewControllerImpl extends UIPageViewController {
|
||||
|
||||
tabBar.delegate = this.tabBarDelegate = MDCTabBarDelegateImpl.initWithOwner(new WeakRef(owner));
|
||||
|
||||
if (majorVersion <= 12) {
|
||||
if (majorVersion <= 12 || !UIColor.labelColor) {
|
||||
tabBar.tintColor = UIColor.blueColor;
|
||||
tabBar.barTintColor = UIColor.whiteColor;
|
||||
tabBar.setTitleColorForState(UIColor.blackColor, MDCTabBarItemState.Normal);
|
||||
@ -216,7 +216,9 @@ class UIPageViewControllerImpl extends UIPageViewController {
|
||||
|
||||
if (majorVersion >= 13) {
|
||||
const owner = this._owner.get();
|
||||
if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
if (owner &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection &&
|
||||
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
||||
owner.notify({ eventName: iosView.traitCollectionColorAppearanceChangedEvent, object: owner });
|
||||
}
|
||||
}
|
||||
@ -634,7 +636,11 @@ export class Tabs extends TabsBase {
|
||||
|
||||
public _loadUnloadTabItems(newIndex: number) {
|
||||
const items = this.items;
|
||||
const lastIndex = this.items.length - 1;
|
||||
if (!items) {
|
||||
return;
|
||||
}
|
||||
|
||||
const lastIndex = items.length - 1;
|
||||
const offsideItems = this.offscreenTabLimit;
|
||||
|
||||
let toUnload = [];
|
||||
@ -766,6 +772,10 @@ export class Tabs extends TabsBase {
|
||||
|
||||
public _setCanBeLoaded(index: number) {
|
||||
const items = this.items;
|
||||
if (!this.items) {
|
||||
return;
|
||||
}
|
||||
|
||||
const lastIndex = items.length - 1;
|
||||
const offsideItems = this.offscreenTabLimit;
|
||||
|
||||
@ -1083,11 +1093,9 @@ export class Tabs extends TabsBase {
|
||||
this._currentNativeSelectedIndex = value;
|
||||
this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, true, (finished: boolean) => {
|
||||
if (finished) {
|
||||
if (majorVersion < 10) {
|
||||
// HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606
|
||||
invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null));
|
||||
}
|
||||
|
||||
// HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606
|
||||
invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null));
|
||||
|
||||
this._canSelectItem = true;
|
||||
this._setCanBeLoaded(value);
|
||||
this._loadUnloadTabItems(value);
|
||||
|
@ -155,7 +155,7 @@ export class TextBase extends TextBaseCommon {
|
||||
this.nativeTextViewProtected.setAttributedTitleForState(attrText, UIControlState.Normal);
|
||||
}
|
||||
else {
|
||||
if (majorVersion >= 13) {
|
||||
if (majorVersion >= 13 && UIColor.labelColor) {
|
||||
this.nativeTextViewProtected.textColor = UIColor.labelColor;
|
||||
}
|
||||
|
||||
@ -207,7 +207,7 @@ export class TextBase extends TextBaseCommon {
|
||||
if (dict.size > 0 || isTextView) {
|
||||
if (style.color) {
|
||||
dict.set(NSForegroundColorAttributeName, style.color.ios);
|
||||
} else if (majorVersion >= 13) {
|
||||
} else if (majorVersion >= 13 && UIColor.labelColor) {
|
||||
dict.set(NSForegroundColorAttributeName, UIColor.labelColor);
|
||||
}
|
||||
}
|
||||
|
@ -116,8 +116,8 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
||||
private _isShowingHint: boolean;
|
||||
public _isEditing: boolean;
|
||||
|
||||
private _hintColor = majorVersion <= 12 ? UIColor.blackColor.colorWithAlphaComponent(0.22) : UIColor.placeholderTextColor;
|
||||
private _textColor = majorVersion <= 12 ? null : UIColor.labelColor;
|
||||
private _hintColor = (majorVersion <= 12 || !UIColor.placeholderTextColor) ? UIColor.blackColor.colorWithAlphaComponent(0.22) : UIColor.placeholderTextColor;
|
||||
private _textColor = (majorVersion <= 12 || !UIColor.labelColor) ? null : UIColor.labelColor;
|
||||
|
||||
createNativeView() {
|
||||
const textView = NoScrollAnimationUITextView.new();
|
||||
|
Reference in New Issue
Block a user