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

Method update

packages/core/ui/action-bar/index.ios.ts:215–309  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

213 }
214
215 public update(): void {
216 const page = this.page;
217 // Page should be attached to frame to update the action bar.
218 if (!page || !page.frame) {
219 return;
220 }
221
222 const viewController = <UIViewController>page.ios;
223 // visionOS may init with different nav stack setup
224 if (!viewController) {
225 return;
226 }
227 const navigationItem: UINavigationItem = viewController.navigationItem;
228 const navController = <UINavigationController>viewController.navigationController;
229
230 if (!navController) {
231 return;
232 }
233
234 const navigationBar = navController.navigationBar;
235 let previousController: UIViewController;
236
237 // Set Title
238 navigationItem.title = this.title;
239 const titleView = this.titleView;
240 if (titleView && titleView.ios) {
241 navigationItem.titleView = titleView.ios;
242 } else {
243 navigationItem.titleView = null;
244 }
245
246 // Find previous ViewController in the navigation stack
247 const indexOfViewController = navController.viewControllers.indexOfObject(viewController);
248 if (indexOfViewController > 0 && indexOfViewController < navController.viewControllers.count) {
249 previousController = navController.viewControllers[indexOfViewController - 1];
250 }
251
252 // Set back button text
253 if (previousController) {
254 if (this.navigationButton) {
255 const tapHandler = TapBarItemHandlerImpl.initWithOwner(new WeakRef(this.navigationButton));
256 const barButtonItem = UIBarButtonItem.alloc().initWithTitleStyleTargetAction(this.navigationButton.text + '', UIBarButtonItemStyle.Plain, tapHandler, 'tap');
257 previousController.navigationItem.backBarButtonItem = barButtonItem;
258 } else {
259 previousController.navigationItem.backBarButtonItem = null;
260 }
261 }
262
263 // Set back button image
264 let img: UIImage;
265 if (this.navigationButton && isVisible(this.navigationButton) && this.navigationButton.icon) {
266 img = loadActionIcon(this.navigationButton);
267 }
268
269 // TODO: This could cause issue when canceling BackEdge gesture - we will change the backIndicator to
270 // show the one from the old page but the new page will still be visible (because we canceled EdgeBackSwipe gesutre)
271 // Consider moving this to new method and call it from - navigationControllerDidShowViewControllerAnimated.
272 const image = img ? img.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) : null;

Calls 10

_getAppearanceMethod · 0.95
_updateAppearanceMethod · 0.95
populateMenuItemsMethod · 0.95
updateFillsMethod · 0.95
updateFlatnessMethod · 0.95
layoutInternalMethod · 0.95
isVisibleFunction · 0.90
loadActionIconFunction · 0.85
initWithOwnerMethod · 0.45

Tested by

no test coverage detected