@nativescript-community/ui-material-tabs 7.0.26 → 7.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/angular/index.d.ts +1 -1
- package/package.json +4 -4
- package/index-common.d.ts +0 -19
- package/index-common.js +0 -36
- package/index-common.js.map +0 -1
- package/pnpm-lock.yaml +0 -90
- package/tabs-common.d.ts +0 -18
- package/tabs-common.js +0 -34
- package/tabs-common.js.map +0 -1
- package/tabs.android.d.ts +0 -63
- package/tabs.android.js +0 -779
- package/tabs.android.js.map +0 -1
- package/tabs.ios.d.ts +0 -108
- package/tabs.ios.js +0 -995
- package/tabs.ios.js.map +0 -1
package/tabs.ios.js
DELETED
@@ -1,995 +0,0 @@
|
|
1
|
-
import { themer } from '@nativescript-community/ui-material-core';
|
2
|
-
import { Color, Device, Font, Frame, IOSHelper, ImageSource, Property, Utils, View, booleanConverter } from '@nativescript/core';
|
3
|
-
import { TabsBase, swipeEnabledProperty } from './tabs-common';
|
4
|
-
import { getIconSpecSize, itemsProperty, selectedIndexProperty, tabStripProperty } from '@nativescript-community/ui-material-core/tab-navigation-base/tab-navigation-base';
|
5
|
-
import { TabStrip } from '@nativescript-community/ui-material-core/tab-navigation-base/tab-strip';
|
6
|
-
import { TabStripItem } from '@nativescript-community/ui-material-core/tab-navigation-base/tab-strip-item';
|
7
|
-
import { TabContentItem } from '@nativescript-community/ui-material-core/tab-navigation-base/tab-content-item';
|
8
|
-
export { TabContentItem, TabStrip, TabStripItem };
|
9
|
-
const majorVersion = Utils.ios.MajorVersion;
|
10
|
-
const isPhone = Device.deviceType === 'Phone';
|
11
|
-
const invokeOnRunLoop = (function () {
|
12
|
-
const runloop = CFRunLoopGetMain();
|
13
|
-
return (action) => {
|
14
|
-
CFRunLoopPerformBlock(runloop, kCFRunLoopDefaultMode, action);
|
15
|
-
CFRunLoopWakeUp(runloop);
|
16
|
-
};
|
17
|
-
})();
|
18
|
-
var MDCTabBarViewDelegateImpl = /** @class */ (function (_super) {
|
19
|
-
__extends(MDCTabBarViewDelegateImpl, _super);
|
20
|
-
function MDCTabBarViewDelegateImpl() {
|
21
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
22
|
-
}
|
23
|
-
MDCTabBarViewDelegateImpl.initWithOwner = function (owner) {
|
24
|
-
var delegate = MDCTabBarViewDelegateImpl.new();
|
25
|
-
delegate._owner = owner;
|
26
|
-
return delegate;
|
27
|
-
};
|
28
|
-
MDCTabBarViewDelegateImpl.prototype.tabBarViewShouldSelectItem = function (tabBar, item) {
|
29
|
-
var owner = this._owner.get();
|
30
|
-
var shouldSelectItem = owner._canSelectItem;
|
31
|
-
var selectedIndex = owner.tabBarItems.indexOf(item);
|
32
|
-
if (owner.selectedIndex !== selectedIndex) {
|
33
|
-
owner.beginTabTransition();
|
34
|
-
}
|
35
|
-
var tabStrip = owner.tabStrip;
|
36
|
-
var tabStripItems = tabStrip && tabStrip.items;
|
37
|
-
if (tabStripItems && tabStripItems[selectedIndex]) {
|
38
|
-
tabStripItems[selectedIndex]._emit(TabStripItem.tapEvent);
|
39
|
-
tabStrip.notify({ eventName: TabStrip.itemTapEvent, object: tabStrip, index: selectedIndex });
|
40
|
-
}
|
41
|
-
return shouldSelectItem;
|
42
|
-
};
|
43
|
-
MDCTabBarViewDelegateImpl.prototype.tabBarViewDidSelectItem = function (tabBar, selectedItem) {
|
44
|
-
var owner = this._owner.get();
|
45
|
-
var tabBarItems = owner.tabBarItems;
|
46
|
-
var selectedIndex = tabBarItems.indexOf(selectedItem);
|
47
|
-
owner.selectedIndex = selectedIndex;
|
48
|
-
};
|
49
|
-
MDCTabBarViewDelegateImpl.ObjCProtocols = [MDCTabBarViewDelegate];
|
50
|
-
return MDCTabBarViewDelegateImpl;
|
51
|
-
}(NSObject));
|
52
|
-
var BackgroundIndicatorTemplate = /** @class */ (function (_super) {
|
53
|
-
__extends(BackgroundIndicatorTemplate, _super);
|
54
|
-
function BackgroundIndicatorTemplate() {
|
55
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
56
|
-
}
|
57
|
-
BackgroundIndicatorTemplate.prototype.indicatorAttributesForContext = function (context) {
|
58
|
-
var attributes = new MDCTabBarViewIndicatorAttributes();
|
59
|
-
attributes.path = UIBezierPath.bezierPathWithRect(context.bounds);
|
60
|
-
return attributes;
|
61
|
-
};
|
62
|
-
BackgroundIndicatorTemplate.ObjCProtocols = [MDCTabBarViewIndicatorTemplate];
|
63
|
-
return BackgroundIndicatorTemplate;
|
64
|
-
}(NSObject));
|
65
|
-
var UIPageViewControllerImpl = /** @class */ (function (_super) {
|
66
|
-
__extends(UIPageViewControllerImpl, _super);
|
67
|
-
function UIPageViewControllerImpl() {
|
68
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
69
|
-
}
|
70
|
-
UIPageViewControllerImpl.initWithOwner = function (owner) {
|
71
|
-
var handler = UIPageViewControllerImpl.alloc().initWithTransitionStyleNavigationOrientationOptions(UIPageViewControllerTransitionStyle.Scroll, UIPageViewControllerNavigationOrientation.Horizontal, null);
|
72
|
-
handler._owner = owner;
|
73
|
-
return handler;
|
74
|
-
};
|
75
|
-
UIPageViewControllerImpl.prototype.accessibilityScroll = function (direction) {
|
76
|
-
var _a, _b;
|
77
|
-
if ((_b = (_a = this._owner.get()) === null || _a === void 0 ? void 0 : _a.swipeEnabled) !== null && _b !== void 0 ? _b : true) {
|
78
|
-
return _super.prototype.accessibilityScroll.call(this, direction);
|
79
|
-
}
|
80
|
-
return false;
|
81
|
-
};
|
82
|
-
UIPageViewControllerImpl.prototype.viewDidLoad = function () {
|
83
|
-
var owner = this._owner.get();
|
84
|
-
var tabBarItems = owner.tabBarItems;
|
85
|
-
var tabBar = MDCTabBarView.alloc().init();
|
86
|
-
this.tabBar = tabBar;
|
87
|
-
var colorScheme = themer.getAppColorScheme();
|
88
|
-
if (tabBarItems && tabBarItems.length) {
|
89
|
-
tabBar.items = NSArray.arrayWithArray(tabBarItems);
|
90
|
-
}
|
91
|
-
tabBar.tabBarDelegate = this.tabBarDelegate = MDCTabBarViewDelegateImpl.initWithOwner(new WeakRef(owner));
|
92
|
-
if (colorScheme && colorScheme.primaryColor) {
|
93
|
-
tabBar.rippleColor = colorScheme.primaryColor.colorWithAlphaComponent(0.24);
|
94
|
-
tabBar.tintColor = colorScheme.primaryColor;
|
95
|
-
tabBar.selectionIndicatorStrokeColor = colorScheme.primaryColor;
|
96
|
-
owner.setTabBarColor(colorScheme.primaryColor);
|
97
|
-
}
|
98
|
-
else {
|
99
|
-
if (majorVersion <= 12 || !UIColor.labelColor) {
|
100
|
-
tabBar.tintColor = UIColor.blueColor;
|
101
|
-
tabBar.barTintColor = UIColor.whiteColor;
|
102
|
-
tabBar.setTitleColorForState(UIColor.blackColor, UIControlState.Normal);
|
103
|
-
tabBar.setTitleColorForState(UIColor.blackColor, UIControlState.Selected);
|
104
|
-
}
|
105
|
-
else {
|
106
|
-
tabBar.tintColor = UIColor.systemBlueColor;
|
107
|
-
tabBar.barTintColor = UIColor.systemBackgroundColor;
|
108
|
-
tabBar.setTitleColorForState(UIColor.labelColor, UIControlState.Normal);
|
109
|
-
tabBar.setTitleColorForState(UIColor.labelColor, UIControlState.Selected);
|
110
|
-
tabBar.rippleColor = UIColor.clearColor;
|
111
|
-
}
|
112
|
-
}
|
113
|
-
tabBar.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleBottomMargin;
|
114
|
-
// tabBar.alignment = MDCTabBarViewAlignment.Justified;
|
115
|
-
this.view.addSubview(tabBar);
|
116
|
-
tabBar.sizeToFit();
|
117
|
-
};
|
118
|
-
UIPageViewControllerImpl.prototype.viewWillAppear = function (animated) {
|
119
|
-
_super.prototype.viewWillAppear.call(this, animated);
|
120
|
-
var owner = this._owner.get();
|
121
|
-
if (!owner) {
|
122
|
-
return;
|
123
|
-
}
|
124
|
-
IOSHelper.updateAutoAdjustScrollInsets(this, owner);
|
125
|
-
// Tabs can be reset as a root view. Call loaded here in this scenario.
|
126
|
-
if (!owner.isLoaded) {
|
127
|
-
owner.callLoaded();
|
128
|
-
}
|
129
|
-
};
|
130
|
-
// public viewWillLayoutSubviews(): void {
|
131
|
-
// super.viewWillLayoutSubviews();
|
132
|
-
// this.tabBar.sizeToFit();
|
133
|
-
// }
|
134
|
-
UIPageViewControllerImpl.prototype.viewDidLayoutSubviews = function () {
|
135
|
-
_super.prototype.viewDidLayoutSubviews.call(this);
|
136
|
-
var owner = this._owner.get();
|
137
|
-
if (!owner) {
|
138
|
-
return;
|
139
|
-
}
|
140
|
-
var safeAreaInsetsBottom = 0;
|
141
|
-
var safeAreaInsetsTop = 0;
|
142
|
-
if (majorVersion > 10) {
|
143
|
-
safeAreaInsetsBottom = this.view.safeAreaInsets.bottom;
|
144
|
-
safeAreaInsetsTop = this.view.safeAreaInsets.top;
|
145
|
-
}
|
146
|
-
else {
|
147
|
-
safeAreaInsetsTop = this.topLayoutGuide.length;
|
148
|
-
}
|
149
|
-
var conditionalSafeAreaBottom = owner.iosOverflowSafeArea ? safeAreaInsetsBottom : 0;
|
150
|
-
var scrollViewTop = 0;
|
151
|
-
var scrollViewHeight = this.view.bounds.size.height + conditionalSafeAreaBottom;
|
152
|
-
if (owner.tabStrip && this.tabBar) {
|
153
|
-
var viewWidth = this.view.bounds.size.width;
|
154
|
-
var viewHeight = this.view.bounds.size.height;
|
155
|
-
var tabBarHeight = this.tabBar.frame.size.height;
|
156
|
-
var tabBarTop = safeAreaInsetsTop;
|
157
|
-
scrollViewTop = tabBarHeight;
|
158
|
-
scrollViewHeight = this.view.bounds.size.height - tabBarHeight + conditionalSafeAreaBottom;
|
159
|
-
var tabsPosition = owner.tabsPosition;
|
160
|
-
if (tabsPosition === 'bottom') {
|
161
|
-
tabBarTop = viewHeight - tabBarHeight - safeAreaInsetsBottom;
|
162
|
-
scrollViewTop = this.view.frame.origin.y;
|
163
|
-
scrollViewHeight = viewHeight - tabBarHeight;
|
164
|
-
}
|
165
|
-
var parent = owner.parent;
|
166
|
-
// Handle Angular scenario where Tabs is in a ProxyViewContainer
|
167
|
-
// It is possible to wrap components in ProxyViewContainers indefinitely
|
168
|
-
while (parent && !parent.nativeViewProtected) {
|
169
|
-
parent = parent.parent;
|
170
|
-
}
|
171
|
-
if (parent && majorVersion > 10) {
|
172
|
-
// TODO: Figure out a better way to handle ViewController nesting/Safe Area nesting
|
173
|
-
tabBarTop = Math.max(tabBarTop, parent.nativeView.safeAreaInsets.top);
|
174
|
-
}
|
175
|
-
this.tabBar.frame = CGRectMake(0, tabBarTop, viewWidth, tabBarHeight);
|
176
|
-
}
|
177
|
-
else {
|
178
|
-
this.tabBar.hidden = true;
|
179
|
-
}
|
180
|
-
var subViews = this.view.subviews;
|
181
|
-
var scrollView = null;
|
182
|
-
for (var i = 0; i < subViews.count; i++) {
|
183
|
-
var view = subViews[i];
|
184
|
-
if (view instanceof UIScrollView && !(view instanceof MDCTabBarView)) {
|
185
|
-
scrollView = view;
|
186
|
-
}
|
187
|
-
}
|
188
|
-
if (scrollView) {
|
189
|
-
// The part of the UIPageViewController that is changing the pages is a UIScrollView
|
190
|
-
// We want to expand it to the size of the UIPageViewController as it is not so by default
|
191
|
-
this.scrollView = scrollView;
|
192
|
-
if (!owner.swipeEnabled) {
|
193
|
-
scrollView.scrollEnabled = false;
|
194
|
-
}
|
195
|
-
else {
|
196
|
-
scrollView.scrollEnabled = true;
|
197
|
-
}
|
198
|
-
scrollView.frame = CGRectMake(0, scrollViewTop, this.view.bounds.size.width, scrollViewHeight); //this.view.bounds;
|
199
|
-
}
|
200
|
-
};
|
201
|
-
// Mind implementation for other controllers
|
202
|
-
UIPageViewControllerImpl.prototype.traitCollectionDidChange = function (previousTraitCollection) {
|
203
|
-
_super.prototype.traitCollectionDidChange.call(this, previousTraitCollection);
|
204
|
-
if (majorVersion >= 13) {
|
205
|
-
var owner = this._owner.get();
|
206
|
-
if (owner &&
|
207
|
-
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection &&
|
208
|
-
this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
209
|
-
owner.notify({ eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent, object: owner });
|
210
|
-
}
|
211
|
-
}
|
212
|
-
};
|
213
|
-
UIPageViewControllerImpl.prototype.viewWillTransitionToSizeWithTransitionCoordinator = function (size, coordinator) {
|
214
|
-
var _this = this;
|
215
|
-
_super.prototype.viewWillTransitionToSizeWithTransitionCoordinator.call(this, size, coordinator);
|
216
|
-
coordinator.animateAlongsideTransitionCompletion(function () {
|
217
|
-
var owner = _this._owner.get();
|
218
|
-
if (owner && owner.tabStrip && owner.tabStrip.items) {
|
219
|
-
var tabStrip_1 = owner.tabStrip;
|
220
|
-
tabStrip_1.items.forEach(function (tabStripItem) {
|
221
|
-
updateBackgroundPositions(tabStrip_1, tabStripItem, owner.selectedIndex !== tabStripItem._index ? owner._defaultItemBackgroundColor : null);
|
222
|
-
var index = tabStripItem._index;
|
223
|
-
var tabBarItemController = owner.viewControllers[index];
|
224
|
-
updateTitleAndIconPositions(tabStripItem, tabBarItemController.tabBarItem, tabBarItemController);
|
225
|
-
});
|
226
|
-
}
|
227
|
-
}, null);
|
228
|
-
};
|
229
|
-
return UIPageViewControllerImpl;
|
230
|
-
}(UIPageViewController));
|
231
|
-
var UIPageViewControllerDataSourceImpl = /** @class */ (function (_super) {
|
232
|
-
__extends(UIPageViewControllerDataSourceImpl, _super);
|
233
|
-
function UIPageViewControllerDataSourceImpl() {
|
234
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
235
|
-
}
|
236
|
-
UIPageViewControllerDataSourceImpl.initWithOwner = function (owner) {
|
237
|
-
var dataSource = UIPageViewControllerDataSourceImpl.new();
|
238
|
-
dataSource._owner = owner;
|
239
|
-
return dataSource;
|
240
|
-
};
|
241
|
-
UIPageViewControllerDataSourceImpl.prototype.pageViewControllerViewControllerBeforeViewController = function (pageViewController, viewController) {
|
242
|
-
// TODO
|
243
|
-
// if (traceEnabled()) {
|
244
|
-
// traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug);
|
245
|
-
// }
|
246
|
-
var owner = this._owner.get();
|
247
|
-
var selectedIndex = owner.selectedIndex;
|
248
|
-
if (selectedIndex === 0) {
|
249
|
-
return null;
|
250
|
-
}
|
251
|
-
selectedIndex--;
|
252
|
-
var prevItem = owner.items[selectedIndex];
|
253
|
-
var prevViewController = prevItem.__controller;
|
254
|
-
// if (!prevViewController) {
|
255
|
-
// prevViewController = owner.getViewController(prevItem);
|
256
|
-
// }
|
257
|
-
owner._setCanBeLoaded(selectedIndex);
|
258
|
-
owner._loadUnloadTabItems(selectedIndex);
|
259
|
-
return prevViewController;
|
260
|
-
};
|
261
|
-
UIPageViewControllerDataSourceImpl.prototype.pageViewControllerViewControllerAfterViewController = function (pageViewController, viewController) {
|
262
|
-
// if (Trace.isEnabled()) {
|
263
|
-
// traceWrite('TabView.delegate.SHOULD_select(' + tabBarController + ', ' + viewController + ');', traceCategories.Debug);
|
264
|
-
// }
|
265
|
-
var owner = this._owner.get();
|
266
|
-
var selectedIndex = owner.selectedIndex;
|
267
|
-
if (selectedIndex === owner.items.length - 1) {
|
268
|
-
return null;
|
269
|
-
}
|
270
|
-
selectedIndex++;
|
271
|
-
var nextItem = owner.items[selectedIndex];
|
272
|
-
var nextViewController = nextItem.__controller;
|
273
|
-
// if (!nextViewController) {
|
274
|
-
// nextViewController = owner.getViewController(nextItem);
|
275
|
-
// }
|
276
|
-
owner._setCanBeLoaded(selectedIndex);
|
277
|
-
owner._loadUnloadTabItems(selectedIndex);
|
278
|
-
// nextItem.loadView(nextItem.view);
|
279
|
-
return nextViewController;
|
280
|
-
};
|
281
|
-
UIPageViewControllerDataSourceImpl.prototype.presentationCountForPageViewController = function (pageViewController) {
|
282
|
-
// TODO
|
283
|
-
// if (traceEnabled()) {
|
284
|
-
// traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug);
|
285
|
-
// }
|
286
|
-
return 0;
|
287
|
-
};
|
288
|
-
UIPageViewControllerDataSourceImpl.prototype.presentationIndexForPageViewController = function (pageViewController) {
|
289
|
-
// TODO
|
290
|
-
// if (traceEnabled()) {
|
291
|
-
// traceWrite("TabView.delegate.SHOULD_select(" + tabBarController + ", " + viewController + ");", traceCategories.Debug);
|
292
|
-
// }
|
293
|
-
return 0;
|
294
|
-
};
|
295
|
-
UIPageViewControllerDataSourceImpl.ObjCProtocols = [UIPageViewControllerDataSource];
|
296
|
-
return UIPageViewControllerDataSourceImpl;
|
297
|
-
}(NSObject));
|
298
|
-
var UIPageViewControllerDelegateImpl = /** @class */ (function (_super) {
|
299
|
-
__extends(UIPageViewControllerDelegateImpl, _super);
|
300
|
-
function UIPageViewControllerDelegateImpl() {
|
301
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
302
|
-
}
|
303
|
-
UIPageViewControllerDelegateImpl.initWithOwner = function (owner) {
|
304
|
-
var delegate = UIPageViewControllerDelegateImpl.new();
|
305
|
-
delegate._owner = owner;
|
306
|
-
return delegate;
|
307
|
-
};
|
308
|
-
UIPageViewControllerDelegateImpl.prototype.pageViewControllerWillTransitionToViewControllers = function (pageViewController, viewControllers) {
|
309
|
-
// const owner = this._owner.get();
|
310
|
-
// const ownerViewControllers = owner.viewControllers;
|
311
|
-
// const selectedIndex = owner.selectedIndex;
|
312
|
-
// const nextViewController = viewControllers[0];
|
313
|
-
// const nextViewControllerIndex = ownerViewControllers.indexOf(nextViewController);
|
314
|
-
// if (selectedIndex > nextViewControllerIndex) {
|
315
|
-
// owner.selectedIndex--;
|
316
|
-
// } else {
|
317
|
-
// owner.selectedIndex++;
|
318
|
-
// }
|
319
|
-
};
|
320
|
-
UIPageViewControllerDelegateImpl.prototype.pageViewControllerDidFinishAnimatingPreviousViewControllersTransitionCompleted = function (pageViewController, didFinishAnimating, previousViewControllers, transitionCompleted) {
|
321
|
-
if (!transitionCompleted) {
|
322
|
-
return;
|
323
|
-
}
|
324
|
-
var owner = this._owner.get();
|
325
|
-
var ownerViewControllers = owner.viewControllers;
|
326
|
-
var selectedIndex = owner.selectedIndex;
|
327
|
-
var nextViewController = pageViewController.viewControllers[0];
|
328
|
-
var nextViewControllerIndex = ownerViewControllers.indexOf(nextViewController);
|
329
|
-
if (selectedIndex !== nextViewControllerIndex) {
|
330
|
-
// let s not animate again on selectedIndex change
|
331
|
-
// or it will create weird behaviors
|
332
|
-
owner._animateNextChange = false;
|
333
|
-
owner.selectedIndex = nextViewControllerIndex;
|
334
|
-
owner.finishTabTransition();
|
335
|
-
}
|
336
|
-
// HACK: UIPageViewController fix; see https://stackoverflow.com/questions/15325891
|
337
|
-
if (owner._needsCacheUpdate) {
|
338
|
-
invokeOnRunLoop(function () {
|
339
|
-
owner._needsCacheUpdate = false;
|
340
|
-
var viewController = owner.viewController;
|
341
|
-
viewController.dataSource = null;
|
342
|
-
viewController.dataSource = owner._dataSource;
|
343
|
-
});
|
344
|
-
}
|
345
|
-
};
|
346
|
-
UIPageViewControllerDelegateImpl.ObjCProtocols = [UIPageViewControllerDelegate];
|
347
|
-
return UIPageViewControllerDelegateImpl;
|
348
|
-
}(NSObject));
|
349
|
-
function iterateIndexRange(index, eps, lastIndex, callback) {
|
350
|
-
const rangeStart = Math.max(0, index - eps);
|
351
|
-
const rangeEnd = Math.min(index + eps, lastIndex);
|
352
|
-
for (let i = rangeStart; i <= rangeEnd; i++) {
|
353
|
-
callback(i);
|
354
|
-
}
|
355
|
-
}
|
356
|
-
function updateBackgroundPositions(tabStrip, tabStripItem, color = null) {
|
357
|
-
if (!tabStrip.nativeView || tabStripItem._index === undefined) {
|
358
|
-
return;
|
359
|
-
}
|
360
|
-
let bgView = tabStripItem.bgView;
|
361
|
-
const index = tabStripItem._index;
|
362
|
-
const width = tabStrip.nativeView.frame.size.width / tabStrip.items.filter((s) => s._index !== undefined).length;
|
363
|
-
const frame = CGRectMake(width * index, 0, width, tabStrip.nativeView.frame.size.width);
|
364
|
-
if (!bgView) {
|
365
|
-
bgView = UIView.alloc().initWithFrame(frame);
|
366
|
-
tabStrip.nativeView.insertSubviewAtIndex(bgView, 0);
|
367
|
-
tabStripItem.bgView = bgView;
|
368
|
-
}
|
369
|
-
else {
|
370
|
-
bgView.frame = frame;
|
371
|
-
}
|
372
|
-
const backgroundColor = tabStripItem.style.backgroundColor;
|
373
|
-
bgView.backgroundColor = color || (backgroundColor instanceof Color ? backgroundColor.ios : backgroundColor);
|
374
|
-
}
|
375
|
-
function updateTitleAndIconPositions(tabStripItem, tabBarItem, controller) {
|
376
|
-
if (!tabStripItem || !tabBarItem) {
|
377
|
-
return;
|
378
|
-
}
|
379
|
-
const orientation = controller.interfaceOrientation;
|
380
|
-
const isPortrait = orientation !== 4 && orientation !== 3;
|
381
|
-
const isIconAboveTitle = majorVersion < 11 || (isPhone && isPortrait);
|
382
|
-
if (!tabStripItem.iconSource) {
|
383
|
-
if (isIconAboveTitle) {
|
384
|
-
tabBarItem.titlePositionAdjustment = { horizontal: 0, vertical: -20 };
|
385
|
-
}
|
386
|
-
else {
|
387
|
-
tabBarItem.titlePositionAdjustment = { horizontal: 0, vertical: 0 };
|
388
|
-
}
|
389
|
-
}
|
390
|
-
if (!tabStripItem.title) {
|
391
|
-
if (isIconAboveTitle) {
|
392
|
-
tabBarItem.imageInsets = new UIEdgeInsets({ top: 6, left: 0, bottom: -6, right: 0 });
|
393
|
-
}
|
394
|
-
else {
|
395
|
-
tabBarItem.imageInsets = new UIEdgeInsets({ top: 0, left: 0, bottom: 0, right: 0 });
|
396
|
-
}
|
397
|
-
}
|
398
|
-
}
|
399
|
-
export const iosCustomPositioningProperty = new Property({
|
400
|
-
name: 'iosCustomPositioning',
|
401
|
-
defaultValue: false,
|
402
|
-
valueConverter: booleanConverter
|
403
|
-
});
|
404
|
-
export class Tabs extends TabsBase {
|
405
|
-
constructor() {
|
406
|
-
super();
|
407
|
-
this._iconsCache = {};
|
408
|
-
this._needsCacheUpdate = false;
|
409
|
-
this._animateNextChange = true;
|
410
|
-
this._layoutPending = false;
|
411
|
-
this.viewController = this._ios = UIPageViewControllerImpl.initWithOwner(new WeakRef(this));
|
412
|
-
}
|
413
|
-
createNativeView() {
|
414
|
-
return this._ios.view;
|
415
|
-
}
|
416
|
-
initNativeView() {
|
417
|
-
super.initNativeView();
|
418
|
-
this._dataSource = UIPageViewControllerDataSourceImpl.initWithOwner(new WeakRef(this));
|
419
|
-
this._delegate = UIPageViewControllerDelegateImpl.initWithOwner(new WeakRef(this));
|
420
|
-
}
|
421
|
-
disposeNativeView() {
|
422
|
-
this._dataSource = null;
|
423
|
-
this._delegate = null;
|
424
|
-
this._ios.tabBarDelegate = null;
|
425
|
-
this._ios.tabBar = null;
|
426
|
-
super.disposeNativeView();
|
427
|
-
}
|
428
|
-
requestLayout() {
|
429
|
-
if (!this._canSelectItem) {
|
430
|
-
this._layoutPending = true;
|
431
|
-
}
|
432
|
-
else {
|
433
|
-
this._layoutPending = false;
|
434
|
-
super.requestLayout();
|
435
|
-
}
|
436
|
-
}
|
437
|
-
beginTabTransition() {
|
438
|
-
this._canSelectItem = false;
|
439
|
-
}
|
440
|
-
finishTabTransition() {
|
441
|
-
this._canSelectItem = true;
|
442
|
-
if (this._layoutPending) {
|
443
|
-
this.requestLayout();
|
444
|
-
}
|
445
|
-
}
|
446
|
-
onLoaded() {
|
447
|
-
super.onLoaded();
|
448
|
-
this.setViewControllers(this.items);
|
449
|
-
const selectedIndex = this.selectedIndex;
|
450
|
-
const selectedView = this.items && this.items[selectedIndex] && this.items[selectedIndex].content;
|
451
|
-
if (selectedView instanceof Frame) {
|
452
|
-
selectedView._pushInFrameStackRecursive();
|
453
|
-
}
|
454
|
-
this._ios.dataSource = this._dataSource;
|
455
|
-
this._ios.delegate = this._delegate;
|
456
|
-
}
|
457
|
-
onUnloaded() {
|
458
|
-
this._ios.dataSource = null;
|
459
|
-
this._ios.delegate = null;
|
460
|
-
super.onUnloaded();
|
461
|
-
}
|
462
|
-
get ios() {
|
463
|
-
return this._ios;
|
464
|
-
}
|
465
|
-
layoutNativeView(left, top, right, bottom) {
|
466
|
-
if (this.iosCustomPositioning) {
|
467
|
-
super.layoutNativeView(left, top, right, bottom);
|
468
|
-
}
|
469
|
-
}
|
470
|
-
_setNativeViewFrame(nativeView, frame) {
|
471
|
-
if (this.iosCustomPositioning) {
|
472
|
-
super._setNativeViewFrame(nativeView, frame);
|
473
|
-
}
|
474
|
-
}
|
475
|
-
onSelectedIndexChanged(oldIndex, newIndex) {
|
476
|
-
const items = this.items;
|
477
|
-
if (!items) {
|
478
|
-
return;
|
479
|
-
}
|
480
|
-
const oldItem = items[oldIndex];
|
481
|
-
if (oldItem) {
|
482
|
-
oldItem.canBeLoaded = false;
|
483
|
-
oldItem.unloadView(oldItem.content);
|
484
|
-
}
|
485
|
-
const newItem = items[newIndex];
|
486
|
-
if (newItem && this.isLoaded) {
|
487
|
-
const selectedView = items[newIndex].content;
|
488
|
-
if (selectedView instanceof Frame) {
|
489
|
-
selectedView._pushInFrameStackRecursive();
|
490
|
-
}
|
491
|
-
newItem.canBeLoaded = true;
|
492
|
-
newItem.loadView(newItem.content);
|
493
|
-
}
|
494
|
-
const tabStripItems = this.tabStrip && this.tabStrip.items;
|
495
|
-
if (tabStripItems) {
|
496
|
-
if (tabStripItems[newIndex]) {
|
497
|
-
tabStripItems[newIndex]._emit(TabStripItem.selectEvent);
|
498
|
-
this.updateItemColors(tabStripItems[newIndex]);
|
499
|
-
}
|
500
|
-
if (tabStripItems[oldIndex]) {
|
501
|
-
tabStripItems[oldIndex]._emit(TabStripItem.unselectEvent);
|
502
|
-
this.updateItemColors(tabStripItems[oldIndex]);
|
503
|
-
}
|
504
|
-
}
|
505
|
-
this._loadUnloadTabItems(newIndex);
|
506
|
-
super.onSelectedIndexChanged(oldIndex, newIndex);
|
507
|
-
}
|
508
|
-
_loadUnloadTabItems(newIndex) {
|
509
|
-
const items = this.items;
|
510
|
-
if (!items) {
|
511
|
-
return;
|
512
|
-
}
|
513
|
-
const lastIndex = items.length - 1;
|
514
|
-
const offsideItems = this.offscreenTabLimit;
|
515
|
-
const toUnload = [];
|
516
|
-
const toLoad = [];
|
517
|
-
iterateIndexRange(newIndex, offsideItems, lastIndex, (i) => toLoad.push(i));
|
518
|
-
if (this.unloadOnTabChange) {
|
519
|
-
items.forEach((item, i) => {
|
520
|
-
const indexOfI = toLoad.indexOf(i);
|
521
|
-
if (indexOfI < 0) {
|
522
|
-
toUnload.push(i);
|
523
|
-
}
|
524
|
-
});
|
525
|
-
toUnload.forEach((index) => {
|
526
|
-
const item = items[index];
|
527
|
-
if (items[index]) {
|
528
|
-
item.unloadView(item.content);
|
529
|
-
}
|
530
|
-
});
|
531
|
-
}
|
532
|
-
const newItem = items[newIndex];
|
533
|
-
const selectedView = newItem && newItem.content;
|
534
|
-
if (selectedView instanceof Frame) {
|
535
|
-
selectedView._pushInFrameStackRecursive();
|
536
|
-
}
|
537
|
-
toLoad.forEach((index) => {
|
538
|
-
const item = items[index];
|
539
|
-
if (this.isLoaded && items[index]) {
|
540
|
-
item.loadView(item.content);
|
541
|
-
}
|
542
|
-
});
|
543
|
-
}
|
544
|
-
onMeasure(widthMeasureSpec, heightMeasureSpec) {
|
545
|
-
const width = Utils.layout.getMeasureSpecSize(widthMeasureSpec);
|
546
|
-
const widthMode = Utils.layout.getMeasureSpecMode(widthMeasureSpec);
|
547
|
-
const height = Utils.layout.getMeasureSpecSize(heightMeasureSpec);
|
548
|
-
const heightMode = Utils.layout.getMeasureSpecMode(heightMeasureSpec);
|
549
|
-
const widthAndState = View.resolveSizeAndState(width, width, widthMode, 0);
|
550
|
-
const heightAndState = View.resolveSizeAndState(height, height, heightMode, 0);
|
551
|
-
this.setMeasuredDimension(widthAndState, heightAndState);
|
552
|
-
}
|
553
|
-
_onViewControllerShown(viewController) {
|
554
|
-
if (this._ios.viewControllers && this._ios.viewControllers.containsObject(viewController)) {
|
555
|
-
this.selectedIndex = this._ios.viewControllers.indexOfObject(viewController);
|
556
|
-
}
|
557
|
-
else {
|
558
|
-
}
|
559
|
-
}
|
560
|
-
getViewController(item) {
|
561
|
-
let newController = item.content ? item.content.viewController : null;
|
562
|
-
if (newController) {
|
563
|
-
item.setViewController(newController, newController.view);
|
564
|
-
return newController;
|
565
|
-
}
|
566
|
-
if (item.content.ios instanceof UIViewController) {
|
567
|
-
newController = item.content.ios;
|
568
|
-
item.setViewController(newController, newController.view);
|
569
|
-
}
|
570
|
-
else if (item.content.ios && item.content.ios.controller instanceof UIViewController) {
|
571
|
-
newController = item.content.ios.controller;
|
572
|
-
item.setViewController(newController, newController.view);
|
573
|
-
}
|
574
|
-
else {
|
575
|
-
newController = IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(item.content));
|
576
|
-
newController.view.addSubview(item.content.nativeViewProtected);
|
577
|
-
item.content.viewController = newController;
|
578
|
-
item.setViewController(newController, item.content.nativeViewProtected);
|
579
|
-
}
|
580
|
-
return newController;
|
581
|
-
}
|
582
|
-
_setCanBeLoaded(index) {
|
583
|
-
const items = this.items;
|
584
|
-
if (!this.items) {
|
585
|
-
return;
|
586
|
-
}
|
587
|
-
const lastIndex = items.length - 1;
|
588
|
-
const offsideItems = this.offscreenTabLimit;
|
589
|
-
iterateIndexRange(index, offsideItems, lastIndex, (i) => {
|
590
|
-
if (items[i]) {
|
591
|
-
items[i].canBeLoaded = true;
|
592
|
-
}
|
593
|
-
});
|
594
|
-
}
|
595
|
-
setViewControllers(items) {
|
596
|
-
const length = items ? items.length : 0;
|
597
|
-
if (length === 0) {
|
598
|
-
this.viewControllers = null;
|
599
|
-
return;
|
600
|
-
}
|
601
|
-
const viewControllers = [];
|
602
|
-
const tabBarItems = [];
|
603
|
-
if (this.tabStrip) {
|
604
|
-
this.tabStrip.setNativeView(this._ios.tabBar);
|
605
|
-
}
|
606
|
-
const tabStripItems = this.tabStrip && this.tabStrip.items;
|
607
|
-
if (tabStripItems) {
|
608
|
-
if (tabStripItems[this.selectedIndex]) {
|
609
|
-
tabStripItems[this.selectedIndex]._emit(TabStripItem.selectEvent);
|
610
|
-
}
|
611
|
-
}
|
612
|
-
items.forEach((item, i) => {
|
613
|
-
const controller = this.getViewController(item);
|
614
|
-
if (this.tabStrip && this.tabStrip.items && this.tabStrip.items[i]) {
|
615
|
-
const tabStripItem = this.tabStrip.items[i];
|
616
|
-
const tabBarItem = this.createTabBarItem(tabStripItem, i);
|
617
|
-
updateTitleAndIconPositions(tabStripItem, tabBarItem, controller);
|
618
|
-
this.setViewTextAttributes(tabStripItem.label, i === this.selectedIndex);
|
619
|
-
controller.tabBarItem = tabBarItem;
|
620
|
-
tabStripItem._index = i;
|
621
|
-
tabBarItems.push(tabBarItem);
|
622
|
-
tabStripItem.setNativeView(tabBarItem);
|
623
|
-
}
|
624
|
-
item.canBeLoaded = true;
|
625
|
-
viewControllers.push(controller);
|
626
|
-
});
|
627
|
-
this.setItemImages();
|
628
|
-
this.viewControllers = viewControllers;
|
629
|
-
this.tabBarItems = tabBarItems;
|
630
|
-
if (this.viewController && this.viewController.tabBar) {
|
631
|
-
this.viewController.tabBar.items = NSArray.arrayWithArray(this.tabBarItems);
|
632
|
-
this.viewController.tabBar.sizeToFit();
|
633
|
-
this.viewController.tabBar.setSelectedItemAnimated(this.tabBarItems[this.selectedIndex], false);
|
634
|
-
}
|
635
|
-
}
|
636
|
-
onItemsChanged(oldItems, newItems) {
|
637
|
-
this._needsCacheUpdate = true;
|
638
|
-
super.onItemsChanged(oldItems, newItems);
|
639
|
-
if (oldItems) {
|
640
|
-
if (!this._canSelectItem) {
|
641
|
-
this.finishTabTransition();
|
642
|
-
}
|
643
|
-
this._setCanBeLoaded(this.selectedIndex);
|
644
|
-
this._loadUnloadTabItems(this.selectedIndex);
|
645
|
-
}
|
646
|
-
}
|
647
|
-
setItemImages() {
|
648
|
-
if (this._selectedItemColor || this._unSelectedItemColor) {
|
649
|
-
if (this.tabStrip && this.tabStrip.items) {
|
650
|
-
this.tabStrip.items.forEach((item) => {
|
651
|
-
if (this._unSelectedItemColor && item.nativeView) {
|
652
|
-
item.nativeView.image = this.getIcon(item, this._unSelectedItemColor);
|
653
|
-
}
|
654
|
-
if (this._selectedItemColor && item.nativeView) {
|
655
|
-
if (this.selectedIndex === item._index) {
|
656
|
-
item.nativeView.image = this.getIcon(item, this._selectedItemColor);
|
657
|
-
}
|
658
|
-
}
|
659
|
-
});
|
660
|
-
}
|
661
|
-
}
|
662
|
-
}
|
663
|
-
updateAllItemsColors() {
|
664
|
-
this._defaultItemBackgroundColor = null;
|
665
|
-
this.setItemColors();
|
666
|
-
if (this.tabStrip && this.tabStrip.items) {
|
667
|
-
this.tabStrip.items.forEach((tabStripItem) => {
|
668
|
-
this.updateItemColors(tabStripItem);
|
669
|
-
});
|
670
|
-
}
|
671
|
-
}
|
672
|
-
updateItemColors(tabStripItem) {
|
673
|
-
updateBackgroundPositions(this.tabStrip, tabStripItem);
|
674
|
-
this.setIconColor(tabStripItem, true);
|
675
|
-
}
|
676
|
-
createTabBarItem(item, index) {
|
677
|
-
let image;
|
678
|
-
let title;
|
679
|
-
if (item.isLoaded) {
|
680
|
-
image = this.getIcon(item);
|
681
|
-
title = item.label.text;
|
682
|
-
if (!this.tabStrip._hasImage) {
|
683
|
-
this.tabStrip._hasImage = !!image;
|
684
|
-
}
|
685
|
-
if (!this.tabStrip._hasTitle) {
|
686
|
-
this.tabStrip._hasTitle = !!title;
|
687
|
-
}
|
688
|
-
}
|
689
|
-
const tabBarItem = UITabBarItem.alloc().initWithTitleImageTag(title, image, index);
|
690
|
-
return tabBarItem;
|
691
|
-
}
|
692
|
-
getIconRenderingMode() {
|
693
|
-
switch (this.tabStrip && this.tabStrip.iosIconRenderingMode) {
|
694
|
-
case 'alwaysOriginal':
|
695
|
-
return 1;
|
696
|
-
case 'alwaysTemplate':
|
697
|
-
return 2;
|
698
|
-
case 'automatic':
|
699
|
-
default:
|
700
|
-
const hasItemColor = this._selectedItemColor || this._unSelectedItemColor;
|
701
|
-
return hasItemColor ? 2 : 1;
|
702
|
-
}
|
703
|
-
}
|
704
|
-
getIcon(tabStripItem, color) {
|
705
|
-
const iconSource = tabStripItem.image && tabStripItem.image.src;
|
706
|
-
if (!iconSource) {
|
707
|
-
return null;
|
708
|
-
}
|
709
|
-
const target = tabStripItem.image;
|
710
|
-
const font = target.style.fontInternal || Font.default;
|
711
|
-
if (!color) {
|
712
|
-
color = target.style.color;
|
713
|
-
}
|
714
|
-
const iconTag = [iconSource, font.fontStyle, font.fontWeight, font.fontSize, font.fontFamily, color].join(';');
|
715
|
-
let isFontIcon = false;
|
716
|
-
let image = this._iconsCache[iconTag];
|
717
|
-
if (!image) {
|
718
|
-
let is;
|
719
|
-
if (Utils.isFontIconURI(iconSource)) {
|
720
|
-
isFontIcon = true;
|
721
|
-
const fontIconCode = iconSource.split('//')[1];
|
722
|
-
is = ImageSource.fromFontIconCodeSync(fontIconCode, font, color);
|
723
|
-
}
|
724
|
-
else {
|
725
|
-
is = ImageSource.fromFileOrResourceSync(iconSource);
|
726
|
-
}
|
727
|
-
if (is && is.ios) {
|
728
|
-
image = is.ios;
|
729
|
-
if (this.tabStrip && this.tabStrip.isIconSizeFixed) {
|
730
|
-
image = this.getFixedSizeIcon(image);
|
731
|
-
}
|
732
|
-
let renderingMode = 0;
|
733
|
-
if (!isFontIcon) {
|
734
|
-
renderingMode = this.getIconRenderingMode();
|
735
|
-
}
|
736
|
-
const originalRenderedImage = image.imageWithRenderingMode(renderingMode);
|
737
|
-
this._iconsCache[iconTag] = originalRenderedImage;
|
738
|
-
image = originalRenderedImage;
|
739
|
-
}
|
740
|
-
}
|
741
|
-
return image;
|
742
|
-
}
|
743
|
-
getFixedSizeIcon(image) {
|
744
|
-
const inWidth = image.size.width;
|
745
|
-
const inHeight = image.size.height;
|
746
|
-
const iconSpecSize = getIconSpecSize({ width: inWidth, height: inHeight });
|
747
|
-
const widthPts = iconSpecSize.width;
|
748
|
-
const heightPts = iconSpecSize.height;
|
749
|
-
UIGraphicsBeginImageContextWithOptions({ width: widthPts, height: heightPts }, false, Utils.layout.getDisplayDensity());
|
750
|
-
image.drawInRect(CGRectMake(0, 0, widthPts, heightPts));
|
751
|
-
const resultImage = UIGraphicsGetImageFromCurrentImageContext();
|
752
|
-
UIGraphicsEndImageContext();
|
753
|
-
return resultImage;
|
754
|
-
}
|
755
|
-
getTabBarBackgroundColor() {
|
756
|
-
return this._ios.tabBar.barTintColor;
|
757
|
-
}
|
758
|
-
setTabBarBackgroundColor(value) {
|
759
|
-
this._ios.tabBar.barTintColor = value instanceof Color ? value.ios : value;
|
760
|
-
this.updateAllItemsColors();
|
761
|
-
}
|
762
|
-
setTabBarItemTitle(tabStripItem, value) {
|
763
|
-
const nativeView = tabStripItem.nativeView;
|
764
|
-
if (!nativeView) {
|
765
|
-
return;
|
766
|
-
}
|
767
|
-
nativeView.title = value;
|
768
|
-
}
|
769
|
-
equalUIColor(first, second) {
|
770
|
-
if (!first && !second) {
|
771
|
-
return true;
|
772
|
-
}
|
773
|
-
if (!first || !second) {
|
774
|
-
return false;
|
775
|
-
}
|
776
|
-
const firstComponents = CGColorGetComponents(first.CGColor);
|
777
|
-
const secondComponents = CGColorGetComponents(second.CGColor);
|
778
|
-
return firstComponents[0] === secondComponents[0] && firstComponents[1] === secondComponents[1] && firstComponents[2] === secondComponents[2] && firstComponents[3] === secondComponents[3];
|
779
|
-
}
|
780
|
-
isSelectedAndHightlightedItem(tabStripItem) {
|
781
|
-
return tabStripItem._index === this.selectedIndex && tabStripItem['_visualState'] === 'highlighted';
|
782
|
-
}
|
783
|
-
setTabBarItemBackgroundColor(tabStripItem, value) {
|
784
|
-
if (!this.tabStrip || !tabStripItem || !tabStripItem.nativeView) {
|
785
|
-
return;
|
786
|
-
}
|
787
|
-
const newColor = value instanceof Color ? value.ios : value;
|
788
|
-
const itemSelectedAndHighlighted = this.isSelectedAndHightlightedItem(tabStripItem);
|
789
|
-
if (!this._defaultItemBackgroundColor && !itemSelectedAndHighlighted) {
|
790
|
-
this._defaultItemBackgroundColor = newColor;
|
791
|
-
}
|
792
|
-
if (itemSelectedAndHighlighted && !this.equalUIColor(this._defaultItemBackgroundColor, newColor)) {
|
793
|
-
if (!this._backgroundIndicatorColor) {
|
794
|
-
this._backgroundIndicatorColor = newColor;
|
795
|
-
this._ios.tabBar.selectionIndicatorTemplate = new BackgroundIndicatorTemplate();
|
796
|
-
this._ios.tabBar.tintColor = newColor;
|
797
|
-
}
|
798
|
-
}
|
799
|
-
else {
|
800
|
-
updateBackgroundPositions(this.tabStrip, tabStripItem, newColor);
|
801
|
-
}
|
802
|
-
}
|
803
|
-
setTabBarItemColor(tabStripItem, value) {
|
804
|
-
this.setViewTextAttributes(tabStripItem.label);
|
805
|
-
}
|
806
|
-
setItemColors() {
|
807
|
-
if (this._selectedItemColor) {
|
808
|
-
this.viewController.tabBar.setTitleColorForState(this._selectedItemColor.ios, 4);
|
809
|
-
}
|
810
|
-
if (this._unSelectedItemColor) {
|
811
|
-
this.viewController.tabBar.setTitleColorForState(this._unSelectedItemColor.ios, 0);
|
812
|
-
}
|
813
|
-
}
|
814
|
-
setIconColor(tabStripItem, forceReload = false) {
|
815
|
-
const nativeView = tabStripItem.nativeView;
|
816
|
-
if (!nativeView) {
|
817
|
-
return;
|
818
|
-
}
|
819
|
-
if (!forceReload && !this._selectedItemColor && !this._unSelectedItemColor) {
|
820
|
-
return;
|
821
|
-
}
|
822
|
-
if (this._selectedItemColor) {
|
823
|
-
const image = this.getIcon(tabStripItem, this._selectedItemColor);
|
824
|
-
nativeView.selectedImage = image;
|
825
|
-
}
|
826
|
-
if (this._unSelectedItemColor) {
|
827
|
-
const image = this.getIcon(tabStripItem, this._unSelectedItemColor);
|
828
|
-
nativeView.image = image;
|
829
|
-
}
|
830
|
-
}
|
831
|
-
setTabBarIconColor(tabStripItem, value) {
|
832
|
-
this.setIconColor(tabStripItem, true);
|
833
|
-
}
|
834
|
-
setTabBarIconSource(tabStripItem, value) {
|
835
|
-
this.updateItemColors(tabStripItem);
|
836
|
-
}
|
837
|
-
setTabBarItemFontInternal(tabStripItem, value) {
|
838
|
-
this.setViewTextAttributes(tabStripItem.label);
|
839
|
-
}
|
840
|
-
getTabBarFontInternal() {
|
841
|
-
return this._ios.tabBar.titleFontForState(0);
|
842
|
-
}
|
843
|
-
setTabBarFontInternal(value) {
|
844
|
-
const defaultTabItemFontSize = 10;
|
845
|
-
const tabItemFontSize = this.tabStrip.style.fontSize || defaultTabItemFontSize;
|
846
|
-
const font = (this.tabStrip.style.fontInternal || Font.default).getUIFont(UIFont.systemFontOfSize(tabItemFontSize));
|
847
|
-
this._ios.tabBar.setTitleFontForState(font, 0);
|
848
|
-
this._ios.tabBar.setTitleFontForState(font, 4);
|
849
|
-
}
|
850
|
-
getTabBarColor() {
|
851
|
-
return this._ios.tabBar.titleColorForState(0);
|
852
|
-
}
|
853
|
-
setTabBarColor(value) {
|
854
|
-
const nativeColor = value instanceof Color ? value.ios : value;
|
855
|
-
this._ios.tabBar.setTitleColorForState(nativeColor, 4);
|
856
|
-
this._ios.tabBar.setImageTintColorForState(nativeColor, 4);
|
857
|
-
}
|
858
|
-
getTabBarHighlightColor() {
|
859
|
-
return this._selectionIndicatorColor;
|
860
|
-
}
|
861
|
-
setTabBarHighlightColor(value) {
|
862
|
-
this._selectionIndicatorColor = value;
|
863
|
-
this._ios.tabBar.selectionIndicatorStrokeColor = value.ios;
|
864
|
-
}
|
865
|
-
getTabBarSelectedItemColor() {
|
866
|
-
return this._selectedItemColor;
|
867
|
-
}
|
868
|
-
setTabBarSelectedItemColor(value) {
|
869
|
-
this._selectedItemColor = value;
|
870
|
-
this.updateAllItemsColors();
|
871
|
-
}
|
872
|
-
getTabBarUnSelectedItemColor() {
|
873
|
-
return this._unSelectedItemColor;
|
874
|
-
}
|
875
|
-
setTabBarUnSelectedItemColor(value) {
|
876
|
-
this._unSelectedItemColor = value;
|
877
|
-
this.updateAllItemsColors();
|
878
|
-
}
|
879
|
-
visitFrames(view, operation) {
|
880
|
-
if (view instanceof Frame) {
|
881
|
-
operation(view);
|
882
|
-
}
|
883
|
-
view.eachChild((child) => {
|
884
|
-
this.visitFrames(child, operation);
|
885
|
-
return true;
|
886
|
-
});
|
887
|
-
}
|
888
|
-
setTabBarRippleColor(value) {
|
889
|
-
this._rippleColor = value;
|
890
|
-
this._ios.tabBar.rippleColor = value.ios;
|
891
|
-
}
|
892
|
-
getTabBarRippleColor() {
|
893
|
-
return this._rippleColor;
|
894
|
-
}
|
895
|
-
[selectedIndexProperty.setNative](value) {
|
896
|
-
if (value > -1) {
|
897
|
-
const item = this.items[value];
|
898
|
-
const controllers = NSMutableArray.alloc().initWithCapacity(1);
|
899
|
-
const itemController = item.__controller;
|
900
|
-
controllers.addObject(itemController);
|
901
|
-
let navigationDirection = 0;
|
902
|
-
if (this._currentNativeSelectedIndex && this._currentNativeSelectedIndex > value) {
|
903
|
-
navigationDirection = 1;
|
904
|
-
}
|
905
|
-
this._currentNativeSelectedIndex = value;
|
906
|
-
this.visitFrames(item, (frame) => (frame._animationInProgress = true));
|
907
|
-
const doneAnimating = () => {
|
908
|
-
this.visitFrames(item, (frame) => (frame._animationInProgress = false));
|
909
|
-
this.finishTabTransition();
|
910
|
-
this._setCanBeLoaded(value);
|
911
|
-
this._loadUnloadTabItems(value);
|
912
|
-
};
|
913
|
-
if (this._animateNextChange) {
|
914
|
-
invokeOnRunLoop(() => {
|
915
|
-
this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, this.animationEnabled, (finished) => {
|
916
|
-
if (finished) {
|
917
|
-
if (this.animationEnabled) {
|
918
|
-
invokeOnRunLoop(() => {
|
919
|
-
doneAnimating();
|
920
|
-
});
|
921
|
-
}
|
922
|
-
else {
|
923
|
-
doneAnimating();
|
924
|
-
}
|
925
|
-
}
|
926
|
-
});
|
927
|
-
});
|
928
|
-
}
|
929
|
-
else {
|
930
|
-
this._animateNextChange = true;
|
931
|
-
doneAnimating();
|
932
|
-
}
|
933
|
-
if (this.tabBarItems && this.tabBarItems.length && this.viewController && this.viewController.tabBar) {
|
934
|
-
this.viewController.tabBar.setSelectedItemAnimated(this.tabBarItems[value], this.animationEnabled);
|
935
|
-
}
|
936
|
-
}
|
937
|
-
}
|
938
|
-
[itemsProperty.getDefault]() {
|
939
|
-
return null;
|
940
|
-
}
|
941
|
-
[itemsProperty.setNative](value) {
|
942
|
-
if (value) {
|
943
|
-
value.forEach((item, i) => {
|
944
|
-
item.index = i;
|
945
|
-
});
|
946
|
-
}
|
947
|
-
this.setViewControllers(value);
|
948
|
-
selectedIndexProperty.coerce(this);
|
949
|
-
}
|
950
|
-
[tabStripProperty.getDefault]() {
|
951
|
-
return null;
|
952
|
-
}
|
953
|
-
[tabStripProperty.setNative](value) {
|
954
|
-
this.setViewControllers(this.items);
|
955
|
-
selectedIndexProperty.coerce(this);
|
956
|
-
}
|
957
|
-
[swipeEnabledProperty.getDefault]() {
|
958
|
-
return true;
|
959
|
-
}
|
960
|
-
[swipeEnabledProperty.setNative](value) {
|
961
|
-
if (this.viewController && this.viewController.scrollView) {
|
962
|
-
this.viewController.scrollView.scrollEnabled = value;
|
963
|
-
}
|
964
|
-
}
|
965
|
-
setViewTextAttributes(view, setSelected = false) {
|
966
|
-
if (!view) {
|
967
|
-
return null;
|
968
|
-
}
|
969
|
-
const defaultTabItemFontSize = 10;
|
970
|
-
const tabItemFontSize = view.style.fontSize || defaultTabItemFontSize;
|
971
|
-
const font = (view.style.fontInternal || Font.default).getUIFont(UIFont.systemFontOfSize(tabItemFontSize));
|
972
|
-
this.viewController.tabBar.setTitleFontForState(font, 0);
|
973
|
-
this.viewController.tabBar.setTitleFontForState(font, 4);
|
974
|
-
const tabItemTextColor = view.style.color;
|
975
|
-
const textColor = tabItemTextColor instanceof Color ? tabItemTextColor.ios : null;
|
976
|
-
if (textColor) {
|
977
|
-
this.viewController.tabBar.setTitleColorForState(textColor, 0);
|
978
|
-
this.viewController.tabBar.setImageTintColorForState(textColor, 0);
|
979
|
-
if (setSelected) {
|
980
|
-
this.viewController.tabBar.setTitleColorForState(textColor, 4);
|
981
|
-
this.viewController.tabBar.setImageTintColorForState(textColor, 4);
|
982
|
-
}
|
983
|
-
}
|
984
|
-
if (this._selectedItemColor) {
|
985
|
-
this.viewController.tabBar.setTitleColorForState(this._selectedItemColor.ios, 4);
|
986
|
-
this.viewController.tabBar.setImageTintColorForState(this._selectedItemColor.ios, 4);
|
987
|
-
}
|
988
|
-
if (this._unSelectedItemColor) {
|
989
|
-
this.viewController.tabBar.setTitleColorForState(this._unSelectedItemColor.ios, 0);
|
990
|
-
this.viewController.tabBar.setImageTintColorForState(this._unSelectedItemColor.ios, 4);
|
991
|
-
}
|
992
|
-
}
|
993
|
-
}
|
994
|
-
iosCustomPositioningProperty.register(Tabs);
|
995
|
-
//# sourceMappingURL=tabs.ios.js.map
|