fix(ios): Objective-C class name "UITabBar..." already in use handling

This commit is contained in:
Nathan Walker
2020-09-07 10:50:24 -07:00
parent 5e4cd9865a
commit c8273931f3
3 changed files with 157 additions and 143 deletions

View File

@ -3,7 +3,7 @@
"main": "index", "main": "index",
"types": "index.d.ts", "types": "index.d.ts",
"description": "NativeScript Core Modules", "description": "NativeScript Core Modules",
"version": "6.5.17", "version": "6.5.18",
"homepage": "https://www.nativescript.org", "homepage": "https://www.nativescript.org",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -18,12 +18,18 @@ export * from "./tab-view-common";
const majorVersion = iosUtils.MajorVersion; const majorVersion = iosUtils.MajorVersion;
const isPhone = device.deviceType === "Phone"; const isPhone = device.deviceType === "Phone";
class UITabBarControllerImpl extends UITabBarController { let UITabBarControllerImpl;
let UITabBarControllerDelegateImpl;
let UINavigationControllerDelegateImpl;
const setupControllers = function () {
if (typeof UITabBarControllerImpl === 'undefined') {
class UITabBarControllerClass extends UITabBarController {
private _owner: WeakRef<TabView>; private _owner: WeakRef<TabView>;
public static initWithOwner(owner: WeakRef<TabView>): UITabBarControllerImpl { public static initWithOwner(owner: WeakRef<TabView>): typeof UITabBarControllerImpl {
let handler = <UITabBarControllerImpl>UITabBarControllerImpl.new(); let handler = <typeof UITabBarControllerImpl>UITabBarControllerImpl.new();
handler._owner = owner; handler._owner = owner;
return handler; return handler;
@ -85,14 +91,15 @@ class UITabBarControllerImpl extends UITabBarController {
} }
} }
} }
UITabBarControllerImpl = UITabBarControllerClass;
class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControllerDelegate { class UITabBarControllerDelegateClass extends NSObject implements UITabBarControllerDelegate {
public static ObjCProtocols = [UITabBarControllerDelegate]; public static ObjCProtocols = [UITabBarControllerDelegate];
private _owner: WeakRef<TabView>; private _owner: WeakRef<TabView>;
public static initWithOwner(owner: WeakRef<TabView>): UITabBarControllerDelegateImpl { public static initWithOwner(owner: WeakRef<TabView>): typeof UITabBarControllerDelegateImpl {
let delegate = <UITabBarControllerDelegateImpl>UITabBarControllerDelegateImpl.new(); let delegate = <typeof UITabBarControllerDelegateImpl>UITabBarControllerDelegateImpl.new();
delegate._owner = owner; delegate._owner = owner;
return delegate; return delegate;
@ -132,14 +139,15 @@ class UITabBarControllerDelegateImpl extends NSObject implements UITabBarControl
(<any>tabBarController)._willSelectViewController = undefined; (<any>tabBarController)._willSelectViewController = undefined;
} }
} }
UITabBarControllerDelegateImpl = UITabBarControllerDelegateClass;
class UINavigationControllerDelegateImpl extends NSObject implements UINavigationControllerDelegate { class UINavigationControllerDelegateClass extends NSObject implements UINavigationControllerDelegate {
public static ObjCProtocols = [UINavigationControllerDelegate]; public static ObjCProtocols = [UINavigationControllerDelegate];
private _owner: WeakRef<TabView>; private _owner: WeakRef<TabView>;
public static initWithOwner(owner: WeakRef<TabView>): UINavigationControllerDelegateImpl { public static initWithOwner(owner: WeakRef<TabView>): typeof UINavigationControllerDelegateImpl {
let delegate = <UINavigationControllerDelegateImpl>UINavigationControllerDelegateImpl.new(); let delegate = <typeof UINavigationControllerDelegateImpl>UINavigationControllerDelegateImpl.new();
delegate._owner = owner; delegate._owner = owner;
return delegate; return delegate;
@ -171,6 +179,12 @@ class UINavigationControllerDelegateImpl extends NSObject implements UINavigatio
} }
} }
} }
UINavigationControllerDelegateImpl = UINavigationControllerDelegateClass;
}
};
setupControllers();
function updateTitleAndIconPositions(tabItem: TabViewItem, tabBarItem: UITabBarItem, controller: UIViewController) { function updateTitleAndIconPositions(tabItem: TabViewItem, tabBarItem: UITabBarItem, controller: UIViewController) {
if (!tabItem || !tabBarItem) { if (!tabItem || !tabBarItem) {
@ -256,11 +270,11 @@ export class TabViewItem extends TabViewItemBase {
} }
export class TabView extends TabViewBase { export class TabView extends TabViewBase {
public viewController: UITabBarControllerImpl; public viewController: typeof UITabBarControllerImpl;
public items: TabViewItem[]; public items: TabViewItem[];
public _ios: UITabBarControllerImpl; public _ios: typeof UITabBarControllerImpl;
private _delegate: UITabBarControllerDelegateImpl; private _delegate: typeof UITabBarControllerDelegateImpl;
private _moreNavigationControllerDelegate: UINavigationControllerDelegateImpl; private _moreNavigationControllerDelegate: typeof UINavigationControllerDelegateImpl;
private _iconsCache = {}; private _iconsCache = {};
constructor() { constructor() {

View File

@ -3,7 +3,7 @@
"main": "index", "main": "index",
"types": "index.d.ts", "types": "index.d.ts",
"description": "NativeScript Core Modules", "description": "NativeScript Core Modules",
"version": "6.5.17", "version": "6.5.18",
"homepage": "https://www.nativescript.org", "homepage": "https://www.nativescript.org",
"repository": { "repository": {
"type": "git", "type": "git",
@ -11,7 +11,7 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@nativescript/core": "6.5.17" "@nativescript/core": "6.5.18"
}, },
"devDependencies": { "devDependencies": {
"tns-platform-declarations": "6.5.15" "tns-platform-declarations": "6.5.15"