1 | import { Font } from '../styling/font';
|
2 | import { IOSHelper, View } from '../core/view';
|
3 | import { TabViewBase, TabViewItemBase, itemsProperty, selectedIndexProperty, tabTextColorProperty, tabTextFontSizeProperty, tabBackgroundColorProperty, selectedTabTextColorProperty, iosIconRenderingModeProperty, traceMissingIcon } from './tab-view-common';
|
4 | import { Color } from '../../color';
|
5 | import { Trace } from '../../trace';
|
6 | import { fontInternalProperty } from '../styling/style-properties';
|
7 | import { textTransformProperty, getTransformedText } from '../text-base';
|
8 | import { ImageSource } from '../../image-source';
|
9 | import { profile } from '../../profiling';
|
10 | import { Frame } from '../frame';
|
11 | import { layout } from '../../utils';
|
12 | import { SDK_VERSION } from '../../utils/constants';
|
13 | import { Device } from '../../platform';
|
14 | export * from './tab-view-common';
|
15 | var UITabBarControllerImpl = (function (_super) {
|
16 | __extends(UITabBarControllerImpl, _super);
|
17 | function UITabBarControllerImpl() {
|
18 | return _super !== null && _super.apply(this, arguments) || this;
|
19 | }
|
20 | UITabBarControllerImpl.initWithOwner = function (owner) {
|
21 | var handler = UITabBarControllerImpl.new();
|
22 | handler._owner = owner;
|
23 | return handler;
|
24 | };
|
25 | UITabBarControllerImpl.prototype.viewDidLoad = function () {
|
26 | _super.prototype.viewDidLoad.call(this);
|
27 |
|
28 |
|
29 | this.extendedLayoutIncludesOpaqueBars = true;
|
30 | };
|
31 | UITabBarControllerImpl.prototype.viewWillAppear = function (animated) {
|
32 | var _a;
|
33 | _super.prototype.viewWillAppear.call(this, animated);
|
34 | var owner = (_a = this._owner) === null || _a === void 0 ? void 0 : _a.deref();
|
35 | if (!owner) {
|
36 | return;
|
37 | }
|
38 | IOSHelper.updateAutoAdjustScrollInsets(this, owner);
|
39 | if (!owner.parent) {
|
40 | owner.callLoaded();
|
41 | }
|
42 | };
|
43 | UITabBarControllerImpl.prototype.viewDidDisappear = function (animated) {
|
44 | var _a;
|
45 | _super.prototype.viewDidDisappear.call(this, animated);
|
46 | var owner = (_a = this._owner) === null || _a === void 0 ? void 0 : _a.deref();
|
47 | if (owner && !owner.parent && owner.isLoaded && !this.presentedViewController) {
|
48 | owner.callUnloaded();
|
49 | }
|
50 | };
|
51 | UITabBarControllerImpl.prototype.viewWillTransitionToSizeWithTransitionCoordinator = function (size, coordinator) {
|
52 | var _this = this;
|
53 | _super.prototype.viewWillTransitionToSizeWithTransitionCoordinator.call(this, size, coordinator);
|
54 | coordinator.animateAlongsideTransitionCompletion(null, function () {
|
55 | var _a;
|
56 | var owner = (_a = _this._owner) === null || _a === void 0 ? void 0 : _a.deref();
|
57 | if (owner && owner.items) {
|
58 | owner.items.forEach(function (tabItem) { return tabItem._updateTitleAndIconPositions(); });
|
59 | }
|
60 | });
|
61 | };
|
62 |
|
63 | UITabBarControllerImpl.prototype.traitCollectionDidChange = function (previousTraitCollection) {
|
64 | var _a;
|
65 | _super.prototype.traitCollectionDidChange.call(this, previousTraitCollection);
|
66 | if (SDK_VERSION >= 13) {
|
67 | var owner = (_a = this._owner) === null || _a === void 0 ? void 0 : _a.deref();
|
68 | if (owner && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection && this.traitCollection.hasDifferentColorAppearanceComparedToTraitCollection(previousTraitCollection)) {
|
69 | owner.notify({
|
70 | eventName: IOSHelper.traitCollectionColorAppearanceChangedEvent,
|
71 | object: owner,
|
72 | });
|
73 | }
|
74 | }
|
75 | };
|
76 | __decorate([
|
77 | profile,
|
78 | __metadata("design:type", Function),
|
79 | __metadata("design:paramtypes", [Boolean]),
|
80 | __metadata("design:returntype", void 0)
|
81 | ], UITabBarControllerImpl.prototype, "viewWillAppear", null);
|
82 | __decorate([
|
83 | profile,
|
84 | __metadata("design:type", Function),
|
85 | __metadata("design:paramtypes", [Boolean]),
|
86 | __metadata("design:returntype", void 0)
|
87 | ], UITabBarControllerImpl.prototype, "viewDidDisappear", null);
|
88 | return UITabBarControllerImpl;
|
89 | }(UITabBarController));
|
90 | var UITabBarControllerDelegateImpl = (function (_super) {
|
91 | __extends(UITabBarControllerDelegateImpl, _super);
|
92 | function UITabBarControllerDelegateImpl() {
|
93 | return _super !== null && _super.apply(this, arguments) || this;
|
94 | }
|
95 | UITabBarControllerDelegateImpl.initWithOwner = function (owner) {
|
96 | var delegate = UITabBarControllerDelegateImpl.new();
|
97 | delegate._owner = owner;
|
98 | return delegate;
|
99 | };
|
100 | UITabBarControllerDelegateImpl.prototype.tabBarControllerShouldSelectViewController = function (tabBarController, viewController) {
|
101 | var _a;
|
102 | if (Trace.isEnabled()) {
|
103 | Trace.write('TabView.delegate.SHOULD_select(' + tabBarController + ', ' + viewController + ');', Trace.categories.Debug);
|
104 | }
|
105 | var owner = (_a = this._owner) === null || _a === void 0 ? void 0 : _a.deref();
|
106 | if (owner) {
|
107 |
|
108 | var backToMoreWillBeVisible = false;
|
109 | owner._handleTwoNavigationBars(backToMoreWillBeVisible);
|
110 | }
|
111 | if (tabBarController.selectedViewController === viewController) {
|
112 | return false;
|
113 | }
|
114 | tabBarController._willSelectViewController = viewController;
|
115 | return true;
|
116 | };
|
117 | UITabBarControllerDelegateImpl.prototype.tabBarControllerDidSelectViewController = function (tabBarController, viewController) {
|
118 | var _a;
|
119 | if (Trace.isEnabled()) {
|
120 | Trace.write('TabView.delegate.DID_select(' + tabBarController + ', ' + viewController + ');', Trace.categories.Debug);
|
121 | }
|
122 | var owner = (_a = this._owner) === null || _a === void 0 ? void 0 : _a.deref();
|
123 | if (owner) {
|
124 | owner._onViewControllerShown(viewController);
|
125 | }
|
126 | tabBarController._willSelectViewController = undefined;
|
127 | };
|
128 | UITabBarControllerDelegateImpl.ObjCProtocols = [UITabBarControllerDelegate];
|
129 | return UITabBarControllerDelegateImpl;
|
130 | }(NSObject));
|
131 | var UINavigationControllerDelegateImpl = (function (_super) {
|
132 | __extends(UINavigationControllerDelegateImpl, _super);
|
133 | function UINavigationControllerDelegateImpl() {
|
134 | return _super !== null && _super.apply(this, arguments) || this;
|
135 | }
|
136 | UINavigationControllerDelegateImpl.initWithOwner = function (owner) {
|
137 | var delegate = UINavigationControllerDelegateImpl.new();
|
138 | delegate._owner = owner;
|
139 | return delegate;
|
140 | };
|
141 | UINavigationControllerDelegateImpl.prototype.navigationControllerWillShowViewControllerAnimated = function (navigationController, viewController, animated) {
|
142 | var _a;
|
143 | if (Trace.isEnabled()) {
|
144 | Trace.write('TabView.moreNavigationController.WILL_show(' + navigationController + ', ' + viewController + ', ' + animated + ');', Trace.categories.Debug);
|
145 | }
|
146 | var owner = (_a = this._owner) === null || _a === void 0 ? void 0 : _a.deref();
|
147 | if (owner) {
|
148 |
|
149 |
|
150 | var backToMoreWillBeVisible = owner._ios.viewControllers.containsObject(viewController);
|
151 | owner._handleTwoNavigationBars(backToMoreWillBeVisible);
|
152 | }
|
153 | };
|
154 | UINavigationControllerDelegateImpl.prototype.navigationControllerDidShowViewControllerAnimated = function (navigationController, viewController, animated) {
|
155 | var _a;
|
156 | if (Trace.isEnabled()) {
|
157 | Trace.write('TabView.moreNavigationController.DID_show(' + navigationController + ', ' + viewController + ', ' + animated + ');', Trace.categories.Debug);
|
158 | }
|
159 |
|
160 | navigationController.navigationBar.topItem.rightBarButtonItem = null;
|
161 | var owner = (_a = this._owner) === null || _a === void 0 ? void 0 : _a.deref();
|
162 | if (owner) {
|
163 | owner._onViewControllerShown(viewController);
|
164 | }
|
165 | };
|
166 | UINavigationControllerDelegateImpl.ObjCProtocols = [UINavigationControllerDelegate];
|
167 | return UINavigationControllerDelegateImpl;
|
168 | }(NSObject));
|
169 | function updateTitleAndIconPositions(tabItem, tabBarItem, controller) {
|
170 | if (!tabItem || !tabBarItem) {
|
171 | return;
|
172 | }
|
173 |
|
174 |
|
175 | const orientation = controller.interfaceOrientation;
|
176 | const isPortrait = orientation !== 4 && orientation !== 3 ;
|
177 | const isIconAboveTitle = (!__VISIONOS__ && SDK_VERSION < 11) || (Device.deviceType === 'Phone' && isPortrait);
|
178 | if (!tabItem.iconSource) {
|
179 | if (isIconAboveTitle) {
|
180 | tabBarItem.titlePositionAdjustment = {
|
181 | horizontal: 0,
|
182 | vertical: -20,
|
183 | };
|
184 | }
|
185 | else {
|
186 | tabBarItem.titlePositionAdjustment = { horizontal: 0, vertical: 0 };
|
187 | }
|
188 | }
|
189 | if (!tabItem.title) {
|
190 | if (isIconAboveTitle) {
|
191 | tabBarItem.imageInsets = new UIEdgeInsets({
|
192 | top: 6,
|
193 | left: 0,
|
194 | bottom: -6,
|
195 | right: 0,
|
196 | });
|
197 | }
|
198 | else {
|
199 | tabBarItem.imageInsets = new UIEdgeInsets({
|
200 | top: 0,
|
201 | left: 0,
|
202 | bottom: 0,
|
203 | right: 0,
|
204 | });
|
205 | }
|
206 | }
|
207 | }
|
208 | export class TabViewItem extends TabViewItemBase {
|
209 | setViewController(controller, nativeView) {
|
210 | this.__controller = controller;
|
211 | this.setNativeView(nativeView);
|
212 | }
|
213 | disposeNativeView() {
|
214 | this.__controller = undefined;
|
215 | this.setNativeView(undefined);
|
216 | }
|
217 | loadView(view) {
|
218 | const tabView = this.parent;
|
219 | if (tabView && tabView.items) {
|
220 | const index = tabView.items.indexOf(this);
|
221 | if (index === tabView.selectedIndex) {
|
222 | super.loadView(view);
|
223 | }
|
224 | }
|
225 | }
|
226 | _update() {
|
227 | const parent = this.parent;
|
228 | const controller = this.__controller;
|
229 | if (parent && controller) {
|
230 | const icon = parent._getIcon(this.iconSource);
|
231 | const index = parent.items.indexOf(this);
|
232 | const title = getTransformedText(this.title, this.style.textTransform);
|
233 | const tabBarItem = UITabBarItem.alloc().initWithTitleImageTag(title, icon, index);
|
234 | updateTitleAndIconPositions(this, tabBarItem, controller);
|
235 |
|
236 | if (!__VISIONOS__ && SDK_VERSION < 15) {
|
237 |
|
238 |
|
239 | const states = getTitleAttributesForStates(parent);
|
240 | applyStatesToItem(tabBarItem, states);
|
241 | }
|
242 | controller.tabBarItem = tabBarItem;
|
243 | }
|
244 | }
|
245 | _updateTitleAndIconPositions() {
|
246 | if (!this.__controller || !this.__controller.tabBarItem) {
|
247 | return;
|
248 | }
|
249 | updateTitleAndIconPositions(this, this.__controller.tabBarItem, this.__controller);
|
250 | }
|
251 | [textTransformProperty.setNative](value) {
|
252 | this._update();
|
253 | }
|
254 | }
|
255 | export class TabView extends TabViewBase {
|
256 | constructor() {
|
257 | super();
|
258 | this._iconsCache = {};
|
259 | this.viewController = this._ios = UITabBarControllerImpl.initWithOwner(new WeakRef(this));
|
260 | this.nativeViewProtected = this._ios.view;
|
261 | }
|
262 | initNativeView() {
|
263 | super.initNativeView();
|
264 | this._delegate = UITabBarControllerDelegateImpl.initWithOwner(new WeakRef(this));
|
265 | this._moreNavigationControllerDelegate = UINavigationControllerDelegateImpl.initWithOwner(new WeakRef(this));
|
266 | }
|
267 | disposeNativeView() {
|
268 | this._delegate = null;
|
269 | this._moreNavigationControllerDelegate = null;
|
270 | super.disposeNativeView();
|
271 | }
|
272 | onLoaded() {
|
273 | super.onLoaded();
|
274 | const selectedIndex = this.selectedIndex;
|
275 | const selectedView = this.items && this.items[selectedIndex] && this.items[selectedIndex].view;
|
276 | if (selectedView instanceof Frame) {
|
277 | selectedView._pushInFrameStackRecursive();
|
278 | }
|
279 | this._ios.delegate = this._delegate;
|
280 | }
|
281 | onUnloaded() {
|
282 | this._ios.delegate = null;
|
283 | this._ios.moreNavigationController.delegate = null;
|
284 | super.onUnloaded();
|
285 | }
|
286 |
|
287 | get ios() {
|
288 | return this._ios;
|
289 | }
|
290 | layoutNativeView(left, top, right, bottom) {
|
291 |
|
292 | }
|
293 | _setNativeViewFrame(nativeView, frame) {
|
294 |
|
295 | }
|
296 | onSelectedIndexChanged(oldIndex, newIndex) {
|
297 | const items = this.items;
|
298 | if (!items) {
|
299 | return;
|
300 | }
|
301 | const oldItem = items[oldIndex];
|
302 | if (oldItem) {
|
303 | oldItem.unloadView(oldItem.view);
|
304 | }
|
305 | const newItem = items[newIndex];
|
306 | if (newItem && this.isLoaded) {
|
307 | const selectedView = items[newIndex].view;
|
308 | if (selectedView instanceof Frame) {
|
309 | selectedView._pushInFrameStackRecursive();
|
310 | }
|
311 | newItem.loadView(newItem.view);
|
312 | }
|
313 | super.onSelectedIndexChanged(oldIndex, newIndex);
|
314 | }
|
315 | onMeasure(widthMeasureSpec, heightMeasureSpec) {
|
316 | const width = layout.getMeasureSpecSize(widthMeasureSpec);
|
317 | const widthMode = layout.getMeasureSpecMode(widthMeasureSpec);
|
318 | const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
319 | const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
320 | const widthAndState = View.resolveSizeAndState(width, width, widthMode, 0);
|
321 | const heightAndState = View.resolveSizeAndState(height, height, heightMode, 0);
|
322 | this.setMeasuredDimension(widthAndState, heightAndState);
|
323 | }
|
324 | _onViewControllerShown(viewController) {
|
325 |
|
326 | if (Trace.isEnabled()) {
|
327 | Trace.write('TabView._onViewControllerShown(' + viewController + ');', Trace.categories.Debug);
|
328 | }
|
329 | if (this._ios.viewControllers && this._ios.viewControllers.containsObject(viewController)) {
|
330 | this.selectedIndex = this._ios.viewControllers.indexOfObject(viewController);
|
331 | }
|
332 | else {
|
333 | if (Trace.isEnabled()) {
|
334 | Trace.write('TabView._onViewControllerShown: viewController is not one of our viewControllers', Trace.categories.Debug);
|
335 | }
|
336 | }
|
337 | }
|
338 | _handleTwoNavigationBars(backToMoreWillBeVisible) {
|
339 | if (Trace.isEnabled()) {
|
340 | Trace.write(`TabView._handleTwoNavigationBars(backToMoreWillBeVisible: ${backToMoreWillBeVisible})`, Trace.categories.Debug);
|
341 | }
|
342 |
|
343 | const page = this.page || this._selectedView.page || this._selectedView.currentPage;
|
344 | if (!page || !page.frame) {
|
345 | return;
|
346 | }
|
347 | const actionBarVisible = page.frame._getNavBarVisible(page);
|
348 | if (backToMoreWillBeVisible && actionBarVisible) {
|
349 | page.frame.ios._disableNavBarAnimation = true;
|
350 | page.actionBarHidden = true;
|
351 | page.frame.ios._disableNavBarAnimation = false;
|
352 | this._actionBarHiddenByTabView = true;
|
353 | if (Trace.isEnabled()) {
|
354 | Trace.write(`TabView hid action bar`, Trace.categories.Debug);
|
355 | }
|
356 | return;
|
357 | }
|
358 | if (!backToMoreWillBeVisible && this._actionBarHiddenByTabView) {
|
359 | page.frame.ios._disableNavBarAnimation = true;
|
360 | page.actionBarHidden = false;
|
361 | page.frame.ios._disableNavBarAnimation = false;
|
362 | this._actionBarHiddenByTabView = undefined;
|
363 | if (Trace.isEnabled()) {
|
364 | Trace.write(`TabView restored action bar`, Trace.categories.Debug);
|
365 | }
|
366 | return;
|
367 | }
|
368 | }
|
369 | getViewController(item) {
|
370 | let newController = item.view ? item.view.viewController : null;
|
371 | if (newController) {
|
372 | item.setViewController(newController, newController.view);
|
373 | return newController;
|
374 | }
|
375 | if (item.view.ios instanceof UIViewController) {
|
376 | newController = item.view.ios;
|
377 | item.setViewController(newController, newController.view);
|
378 | }
|
379 | else if (item.view.ios && item.view.ios.controller instanceof UIViewController) {
|
380 | newController = item.view.ios.controller;
|
381 | item.setViewController(newController, newController.view);
|
382 | }
|
383 | else {
|
384 | newController = IOSHelper.UILayoutViewController.initWithOwner(new WeakRef(item.view));
|
385 | newController.view.addSubview(item.view.nativeViewProtected);
|
386 | item.view.viewController = newController;
|
387 | item.setViewController(newController, item.view.nativeViewProtected);
|
388 | }
|
389 | return newController;
|
390 | }
|
391 | setViewControllers(items) {
|
392 | const length = items ? items.length : 0;
|
393 | if (length === 0) {
|
394 | this._ios.viewControllers = null;
|
395 | return;
|
396 | }
|
397 | const controllers = NSMutableArray.alloc().initWithCapacity(length);
|
398 | const states = getTitleAttributesForStates(this);
|
399 | items.forEach((item, i) => {
|
400 | const controller = this.getViewController(item);
|
401 | const icon = this._getIcon(item.iconSource);
|
402 | const tabBarItem = UITabBarItem.alloc().initWithTitleImageTag(item.title || '', icon, i);
|
403 | updateTitleAndIconPositions(item, tabBarItem, controller);
|
404 | if (!__VISIONOS__ && SDK_VERSION < 15) {
|
405 | applyStatesToItem(tabBarItem, states);
|
406 | }
|
407 | controller.tabBarItem = tabBarItem;
|
408 | controllers.addObject(controller);
|
409 | item.canBeLoaded = true;
|
410 | });
|
411 | if (SDK_VERSION >= 15) {
|
412 | this.updateBarItemAppearance(this._ios.tabBar, states);
|
413 | }
|
414 | this._ios.viewControllers = controllers;
|
415 | this._ios.customizableViewControllers = null;
|
416 |
|
417 | this._ios.moreNavigationController.delegate = this._moreNavigationControllerDelegate;
|
418 | }
|
419 | _getIconRenderingMode() {
|
420 | switch (this.iosIconRenderingMode) {
|
421 | case 'alwaysOriginal':
|
422 | return 1 ;
|
423 | case 'alwaysTemplate':
|
424 | return 2 ;
|
425 | case 'automatic':
|
426 | default:
|
427 | return 0 ;
|
428 | }
|
429 | }
|
430 | _getIcon(iconSource) {
|
431 | if (!iconSource) {
|
432 | return null;
|
433 | }
|
434 | let image = this._iconsCache[iconSource];
|
435 | if (!image) {
|
436 | const is = ImageSource.fromFileOrResourceSync(iconSource);
|
437 | if (is && is.ios) {
|
438 | const originalRenderedImage = is.ios.imageWithRenderingMode(this._getIconRenderingMode());
|
439 | this._iconsCache[iconSource] = originalRenderedImage;
|
440 | image = originalRenderedImage;
|
441 | }
|
442 | else {
|
443 | traceMissingIcon(iconSource);
|
444 | }
|
445 | }
|
446 | return image;
|
447 | }
|
448 | _updateIOSTabBarColorsAndFonts() {
|
449 | if (!this.items) {
|
450 | return;
|
451 | }
|
452 | const tabBar = this.ios.tabBar;
|
453 | const states = getTitleAttributesForStates(this);
|
454 | if (SDK_VERSION >= 15) {
|
455 | this.updateBarItemAppearance(tabBar, states);
|
456 | }
|
457 | else {
|
458 | for (let i = 0; i < tabBar.items.count; i++) {
|
459 | applyStatesToItem(tabBar.items[i], states);
|
460 | }
|
461 | }
|
462 | }
|
463 | updateBarItemAppearance(tabBar, states) {
|
464 | const appearance = this._getAppearance(tabBar);
|
465 | const itemAppearances = ['stackedLayoutAppearance', 'inlineLayoutAppearance', 'compactInlineLayoutAppearance'];
|
466 | for (let itemAppearance of itemAppearances) {
|
467 | appearance[itemAppearance].normal.titleTextAttributes = states.normalState;
|
468 | appearance[itemAppearance].selected.titleTextAttributes = states.selectedState;
|
469 | }
|
470 | this._updateAppearance(tabBar, appearance);
|
471 | }
|
472 | _getAppearance(tabBar) {
|
473 | if (tabBar.standardAppearance == null) {
|
474 | const appearance = UITabBarAppearance.new();
|
475 | appearance.stackedLayoutAppearance = appearance.inlineLayoutAppearance = appearance.compactInlineLayoutAppearance = UITabBarItemAppearance.new();
|
476 | return appearance;
|
477 | }
|
478 | return tabBar.standardAppearance;
|
479 | }
|
480 | _updateAppearance(tabBar, appearance) {
|
481 | tabBar.standardAppearance = appearance;
|
482 | if (SDK_VERSION >= 15) {
|
483 | tabBar.scrollEdgeAppearance = appearance;
|
484 | }
|
485 | }
|
486 | [selectedIndexProperty.setNative](value) {
|
487 | if (Trace.isEnabled()) {
|
488 | Trace.write('TabView._onSelectedIndexPropertyChangedSetNativeValue(' + value + ')', Trace.categories.Debug);
|
489 | }
|
490 | if (value > -1) {
|
491 | this._ios._willSelectViewController = this._ios.viewControllers[value];
|
492 | this._ios.selectedIndex = value;
|
493 | }
|
494 | }
|
495 | [itemsProperty.getDefault]() {
|
496 | return null;
|
497 | }
|
498 | [itemsProperty.setNative](value) {
|
499 | this.setViewControllers(value);
|
500 | selectedIndexProperty.coerce(this);
|
501 | }
|
502 | [tabTextFontSizeProperty.getDefault]() {
|
503 | return null;
|
504 | }
|
505 | [tabTextFontSizeProperty.setNative](value) {
|
506 | this._updateIOSTabBarColorsAndFonts();
|
507 | }
|
508 | [tabTextColorProperty.getDefault]() {
|
509 | return null;
|
510 | }
|
511 | [tabTextColorProperty.setNative](value) {
|
512 | this._updateIOSTabBarColorsAndFonts();
|
513 | }
|
514 | [tabBackgroundColorProperty.getDefault]() {
|
515 | return this._ios.tabBar.barTintColor;
|
516 | }
|
517 | [tabBackgroundColorProperty.setNative](value) {
|
518 | if (SDK_VERSION >= 13) {
|
519 | const appearance = this._getAppearance(this._ios.tabBar);
|
520 | appearance.configureWithDefaultBackground();
|
521 | appearance.backgroundColor = value instanceof Color ? value.ios : value;
|
522 | this._updateAppearance(this._ios.tabBar, appearance);
|
523 | }
|
524 | else {
|
525 | this._ios.tabBar.barTintColor = value instanceof Color ? value.ios : value;
|
526 | }
|
527 | }
|
528 | [selectedTabTextColorProperty.getDefault]() {
|
529 | return this._ios.tabBar.tintColor;
|
530 | }
|
531 | [selectedTabTextColorProperty.setNative](value) {
|
532 | this._ios.tabBar.tintColor = value instanceof Color ? value.ios : value;
|
533 | this._updateIOSTabBarColorsAndFonts();
|
534 | }
|
535 |
|
536 | [fontInternalProperty.getDefault]() {
|
537 | return null;
|
538 | }
|
539 | [fontInternalProperty.setNative](value) {
|
540 | this._updateIOSTabBarColorsAndFonts();
|
541 | }
|
542 |
|
543 | [iosIconRenderingModeProperty.getDefault]() {
|
544 | return 'automatic';
|
545 | }
|
546 | [iosIconRenderingModeProperty.setNative](value) {
|
547 | this._iconsCache = {};
|
548 | const items = this.items;
|
549 | if (items && items.length) {
|
550 | for (let i = 0, length = items.length; i < length; i++) {
|
551 | const item = items[i];
|
552 | if (item.iconSource) {
|
553 | item._update();
|
554 | }
|
555 | }
|
556 | }
|
557 | }
|
558 | }
|
559 | __decorate([
|
560 | profile,
|
561 | __metadata("design:type", Function),
|
562 | __metadata("design:paramtypes", []),
|
563 | __metadata("design:returntype", void 0)
|
564 | ], TabView.prototype, "onLoaded", null);
|
565 | function getTitleAttributesForStates(tabView) {
|
566 | const result = {
|
567 | normalState: NSMutableDictionary.new(),
|
568 | selectedState: NSMutableDictionary.new(),
|
569 | };
|
570 | const titleFontSize = tabView.style.tabTextFontSize;
|
571 | let font = tabView.style.fontInternal || Font.default;
|
572 | if (titleFontSize != null) {
|
573 | font = font.withFontSize(titleFontSize);
|
574 | }
|
575 | const nativeFont = font.getUIFont(UIFont.systemFontOfSize(UIFont.labelFontSize));
|
576 | result.normalState.setValueForKey(nativeFont, NSFontAttributeName);
|
577 | result.selectedState.setValueForKey(nativeFont, NSFontAttributeName);
|
578 | const titleColor = tabView.style.tabTextColor;
|
579 | if (titleColor instanceof Color) {
|
580 | result.normalState.setValueForKey(titleColor.ios, UITextAttributeTextColor);
|
581 | }
|
582 | const selectedTitleColor = tabView.style.selectedTabTextColor;
|
583 | if (selectedTitleColor instanceof Color) {
|
584 | result.selectedState.setValueForKey(selectedTitleColor.ios, UITextAttributeTextColor);
|
585 | }
|
586 | return result;
|
587 | }
|
588 | function applyStatesToItem(item, states) {
|
589 | item.setTitleTextAttributesForState(states.normalState, 0 );
|
590 | item.setTitleTextAttributesForState(states.selectedState, 4 );
|
591 | }
|
592 |
|
\ | No newline at end of file |