Troubleshooting problems with NativeScript IOS Safe Area when using Children Action Bar

I am utilizing the "@nativescript-community/ui-material-tabs" plugin to display tabs on IOS and Android.

https://i.sstatic.net/zixkl.png

However, there seems to be a problem as the component is affecting the top safe area in IOS (specifically tested on IPhone 11 Pro) as seen in the image below:

https://i.sstatic.net/ZWPcB.png

After troubleshooting, I found that the issue arises when using MD Tabs and Nested Routing (especially when the Action Bar is defined in a children's tab).

Here are the relevant components:

app.component.html

<page-router-outlet></page-router-outlet>

app-routing.module.ts

import { NgModule } from '@angular/core'
import { Routes } from '@angular/router'
import { NativeScriptRouterModule } from '@nativescript/angular'

const routes: Routes = [
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  {
    path: 'home',
    loadChildren: () => import('~/app/home/home.module').then((m) => m.HomeModule),
  }
]

@NgModule({
  imports: [NativeScriptRouterModule.forRoot(routes)],
  exports: [NativeScriptRouterModule],
})
export class AppRoutingModule {}

home.component.html

<MDTabs tabsPosition="bottom">
  <MDTabStrip>
    <MDTabStripItem>
      <Label text="Featured"></Label>
      <Image src="font://&#xf015;" class="fas"></Image>
    </MDTabStripItem>
  </MDTabStrip>

  <MDTabContentItem>
    <page-router-outlet name="featuredTab"></page-router-outlet>
  </MDTabContentItem>
</MDTabs>

home.component.ts

...
export class HomeComponent implements OnInit {
  constructor(private routerExtension: RouterExtensions,
    private activeRoute: ActivatedRoute, private page: Page) {
    this.page.actionBarHidden = true; // The action bar is hidden in the parent tabs component.
  }

  ngOnInit(): void {
    this.routerExtension.navigate(
            [
                {
                    outlets: {
                        featuredTab: ["featured"]
                    },
                },
            ],
            { relativeTo: this.activeRoute }
    )
  }
}

home-routing.module.ts

...
const routes: Routes = [
  { path: '', redirectTo: "home", pathMatch: 'full' }, 
  {
    path: "home",
    component: HomeComponent,
    children: [
      {
        path: "featured",
        component: NSEmptyOutletComponent,
        loadChildren: () =>
          import("~/app/home/featured/featured.module").then(
            (m) => m.FeaturedModule
          ),
        outlet: "featuredTab",
      },
    ]
}]
...

The "featured" children tab component defines the action bar which occupies space in the ios safe area:

featured.component.html

<ActionBar>
  <NavigationButton visibility="hidden"></NavigationButton>
  <GridLayout columns="50, *">
    <Label class="action-bar-title" text="Home" colSpan="2"></Label>

    <Label class="fas" text="&#xf0c9;" (tap)="openDrawer()"></Label>
  </GridLayout>
</ActionBar>

<Label text="You are in featured component"></Label>

For testing purposes, here is the GitHub link: https://github.com/limyandi/fuzzy-octo-memory

Answer №1

I encountered a similar issue when using BottomNavigationBar and discovered that lazy loading Modules (loadChildren) in app-routing.modules.ts was causing the problem. To work around this, I decided to convert the module into a component and remove the lazy loading.

Despite wanting to keep my code organized into Modules, further investigation revealed that including the property:

component: NSEmptyOutletComponent

Removing this property resolved the layout issue, but it led to other subtle bugs. Instead, I found guidance in this bug report, which set me on the right path. I developed the WrappedEmptyOutlet as an alternative to NSEmptyOutletComponent, detailed in this repository, and successfully resolved the layout problems without encountering any additional issues so far :)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Show varying mat-options based on the selected value of another mat-select

When selecting a continent from the first mat-select, only the countries belonging to that continent should appear in the second mat-select options. For example, if Asia is chosen as the continent, only Asian countries should be displayed. <div class=&q ...

Progress Bar Modules

I am currently working on creating a customizable animated progress bar that can be utilized as follows: <bar [type]="'health'" [percentage]="'80'"></bar> It is functional up to the point where I need to adjust different p ...

The application encountered an error while trying to call the method `tableView:numberOfRowsInSection:` on an instance with the memory address 0x7fc748e37ea

I'm currently in the process of developing an application that loads a collection of names from a .plist file. I have successfully implemented the functionality to load the .plist file into a UITableView. However, I am encountering an issue whenever I ...

Leveraging the power of segues and NSNotificationCenter

I have a situation involving 2 view controllers where I need to trigger a notification from one to the other and alter a label based on the name of the notification (by pressing a UIButton). Recently, I started utilizing segues and discovered their effecti ...

sass: node_modules/ionic-angular/themes/ionic.variables.scss

Encountered error during the execution of Ionic Cordova build command sass: node_modules/ionic-angular/themes/ionic.functions.scss Full Error: [11:34:50] sass started ... [11:34:51] sass: node_modules/ionic-angular/themes/ionic.functions.scss, line: 35 ...

Transferring data from two child components back to the parent component

Within my web application, I have a parent component (A) and two children components (B, C). The parent component is responsible for maintaining the basic layout of the page, which remains consistent across all layouts. However, I need to dynamically swap ...

Encountering a hiccup with dependencies during the transition to Angular 9 with jodit-angular

Encountering the following error when attempting to execute the command npm install after migrating Angular to version 9. Error npm ERR! code ERESOLVE npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While resolving: <a href="/cdn-cgi/l/email-pro ...

The Google Javascript API Photo getURL function provides a temporary URL that may not always lead to the correct photo_reference

Currently, I am integrating Google Autocomplete with Maps Javascript API into my Angular 5 application. As part of my website functionality, I fetch details about a place, including available photos. The photo URL is obtained through the getURL() method. ...

What is the method for resizing an image on iOS devices?

I'm working on a photo app that allows users to add stickers and then save the final image. I have code in place to save the full-screen image, but now I need help cropping it. The current image can be viewed at this link: The specific cropping requi ...

The present URL of Next.js version 13

When working with Next.js App Router in SSR, how can I retrieve the complete URL of the current page? I am unable to use window.location.href due to the absence of a defined window object, and using useRouter() does not provide access to the full URL. ...

Creating a sequence of HTTP calls that call upon themselves using RxJs operators

When retrieving data by passing pageIndex (1) and pageSize (500) for each HTTP call, I use the following method: this.demoService.geList(1, 500).subscribe(data => { this.data = data.items; }); If the response contains a property called isMore with ...

I encountered difficulty in testing the Angular Material Select Component due to complications with the CDK Test Harness

While working on testing a component that utilizes Angular Material Components, I came across the CDK Test Harness and decided to use it to retrieve the count of options in the Mat Select component. You can find more information about the CDK Test Harness ...

Adding dependency service to the parent class in Angular

I am working with classes parent and child. The child class is an extension of the parent class. I want to inject the injectable class service into the parent class since all instances of the child class will be using it as well. Can someone guide me on ...

When not in use, a float is considered to be equivalent to zero

In the world of my game, there exists a header file that holds the key to the seasons within the game. This file boasts static properties, including a float that signifies the current season and another float that indicates the progress of transitioning be ...

What methods are available to expedite webpack compilation (or decouple it from server restart)?

My current setup includes the following configurations: import path from 'path' import type {Configuration} from 'webpack' const config: Configuration = { mode: 'development', entry: path.join(__dirname, '../..&apos ...

Using setBounds in ng2-ui/map: A step-by-step guide

I have been attempting to display a map using the setBounds feature with the ng2-ui/map library. Unfortunately, I am having trouble finding documentation on how to achieve this. https://github.com/ng2-ui/map Currently, here is the code that I have writte ...

Trigger a response according to the information received from the preceding action

I'm facing an issue with dispatching actions in sequence after the completion of the previous one. My goal is to dispatch an action (let's call it getDetails), use the data from this action to dispatch another action (getUserLists), and finally ...

issue with uploading files in angular 7

Currently, I am facing an issue with Angular 7 where the input type "file" is not working as expected. However, in Angular 6, everything works fine. When submitting the input file type data in Angular 6, I receive a field list like this: https://i.sstat ...

Is it TypeScript's return type a double arrow (Observable)?

I'm having a hard time understanding this: const loadData: (detailsStore: RecipeDetailsStore) => (source$: Observable<string>) => Observable<RecipeDetails> How should I interpret this? My understanding is: loadData is a function t ...

Can you explain the purpose of the `never[]` parameter type as defined in the TypeScript Handbook?

Exploring the topic of Inferring Within Conditional Types, an illustrative example is provided: type GetReturnType<Type> = Type extends (...args: never[]) => infer Return ? Return : never; type Num = GetReturnType<() => number>; type ...