Skip to content

Commit 5ad8a89

Browse files
committed
feat(ListView): sticky headers, search bar and sectioned data support with v9
1 parent 9bf7068 commit 5ad8a89

File tree

4 files changed

+1750
-17
lines changed

4 files changed

+1750
-17
lines changed

apps/nativescript-demo-ng/src/app/app.routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Routes } from '@angular/router';
22
import { ItemDetailComponent } from './item/item-detail.component';
33
import { ItemsComponent } from './item/items.component';
4+
import { ListViewStickyComponent } from './list-view-sticky/list-view-sticky.component';
45
// import { HomeComponent } from './home/home.component';
56
// import { BootGuardService } from './boot-guard.service';
67

@@ -10,6 +11,10 @@ export const routes: Routes = [
1011
{ path: 'item/:id', component: ItemDetailComponent },
1112
{ path: 'item2', loadChildren: () => import('./item2/item2.routes').then((m) => m.ITEM2_ROUTES) },
1213
{ path: 'rootlazy', loadChildren: () => import('./item3/item3.module').then((m) => m.Item3Module) },
14+
{
15+
path: 'list-view-sticky',
16+
component: ListViewStickyComponent,
17+
},
1318

1419
/**
1520
* Test tab named outlets
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<ActionBar title="ListView Sticky Headers"></ActionBar>
2+
3+
<GridLayout rows="1,*" columns="*">
4+
<GridLayout row="1" columns="*">
5+
<!-- Using inside this grid setup helps Android position search bar if used. It also helps iOS with ActionBar safe area overflow cases with sticky header. -->
6+
<ListView
7+
[items]="countries()"
8+
[sectioned]="true"
9+
[stickyHeader]="true"
10+
[stickyHeaderHeight]="45"
11+
[stickyHeaderTopPadding]="false"
12+
[showSearch]="true"
13+
[searchAutoHide]="true"
14+
[stickyHeaderTemplate]="headerTemplateString"
15+
[itemTemplateSelector]="templateSelector"
16+
(searchChange)="onSearchChange($event)"
17+
>
18+
<ng-template let-item="item" nsTemplateKey="main">
19+
<GridLayout
20+
columns="auto,auto,*"
21+
class="p-3 my-1 mx-2 rounded-xl bg-white"
22+
boxShadow="0px 1px 2px rgba(0,0,0,0.2)"
23+
>
24+
<Label color="black" [text]="item?.flag" class="ml-1"></Label>
25+
<Label col="1" [text]="item?.name" class="ml-2 text-black"></Label>
26+
<Label col="2" [text]="item?.code" class="ml-1 text-[#999]"></Label>
27+
</GridLayout>
28+
</ng-template>
29+
</ListView>
30+
</GridLayout>
31+
</GridLayout>

0 commit comments

Comments
 (0)