nativescript-community / ui-material-components

Monorepo that contains all of the NativeScript Material Design plugins.
https://nativescript-community.github.io/ui-material-components/
Apache License 2.0
218 stars 80 forks source link

[Tabs] IOS Safe Area Issue when using Tabs and Nested Routing #308

Open limyandi opened 3 years ago

limyandi commented 3 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

I uses the "@nativescript-community/ui-material-tabs" plugin to show tabs in IOS and Android.

MD Tabs

The problem is, the component "strangely" affect the top safe area in IOS (tested in IPhone 11 Pro) as you can see below:

IOS Safe Area Issue

I have troubleshoot and determine the issue to be when using MD Tabs and Nested Routing (where the Action Bar is defined in children tab).

Below is the associated 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; // as can be seen the action bar is hidden in the parent tabs component.
  }

  ngOnInit(): void {
    // Init your component properties here.
    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",
      },
    ]
}]
...

And finally, the "featured" children tab component which defines the action bar (which takes up the 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>

Is there any code involved?

https://github.com/limyandi/fuzzy-octo-memory

farfromrefug commented 3 years ago

@limyandi not sure where the issue comes from. Lot of moving part in your code. If you can reproduce without angular, 3rd party plugins, and a very simple repro code i will fix it

csimpi commented 3 years ago

@farfromrefug Why would he reproduce without angular when he's getting the issue with Angular? He has even linked the whole repo and everything :D

farfromrefug commented 3 years ago

@csimpi to know if the issue is angular related or not! i wont fix any angular issue as i dont work with it. You are welcome to fix it and create a PR

fpaaske commented 2 years ago

@limyandi it's been a while so you might already have solved it, but if not, try replacing page-router-outlet with a router-outlet in home.component.html