MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / _update

Method _update

packages/core/ui/tab-view/index.ios.ts:261–300  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

259 }
260
261 public _update() {
262 const parent = <TabView>this.parent;
263 const controller = this.__controller;
264 if (parent && controller) {
265 const icon = parent._getIcon(this);
266 const index = parent.items.indexOf(this);
267 const title = getTransformedText(this.title, this.style.textTransform);
268
269 if (SDK_VERSION >= 18) {
270 // iOS 18+: use UITab instead of UITabBarItem.
271 // The UITab instances are created and managed at the TabView level,
272 // so here we just update the corresponding tab for this controller.
273 const identifier = `${index}`;
274 const tabController = parent.viewController as UITabBarController;
275 try {
276 const tab = tabController.tabForIdentifier(identifier);
277 if (tab) {
278 tab.title = title;
279 tab.image = icon;
280 }
281 } catch (e) {
282 // Fallback: if tabForIdentifier is not available for some reason,
283 // do not crash – rely on existing tab configuration.
284 }
285 } else {
286 // iOS < 18: keep using UITabBarItem-based configuration.
287 const tabBarItem = UITabBarItem.alloc().initWithTitleImageTag(title, icon, index);
288 updateTitleAndIconPositions(this, tabBarItem, controller);
289
290 // There is no need to request title styles update here in newer versions as styling is handled by bar appearance instance
291 if (!__VISIONOS__ && SDK_VERSION < 15) {
292 // TODO: Repeating code. Make TabViewItemBase - ViewBase and move the colorProperty on tabViewItem.
293 // Delete the repeating code.
294 const states = getTitleAttributesForStates(parent);
295 applyStatesToItem(tabBarItem, states);
296 }
297 controller.tabBarItem = tabBarItem;
298 }
299 }
300 }
301
302 public _updateTitleAndIconPositions() {
303 // UITab-based configuration (iOS 18+) does not expose the same per-item

Callers 4

titleFunction · 0.45
iconSourceFunction · 0.45

Calls 6

getTransformedTextFunction · 0.90
applyStatesToItemFunction · 0.85
_getIconMethod · 0.80
indexOfMethod · 0.80

Tested by

no test coverage detected