Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
feat: add loading component on home page
Browse files Browse the repository at this point in the history
  • Loading branch information
Messias Junior committed May 12, 2021
1 parent c84431e commit 92bb978
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/app/ui/pages/home/home.component.html
@@ -1,11 +1,20 @@
<app-section
*ngIf="!isRecentlyAddedLoading"
title="{{ 'PAGES.HOME.NEW_RELEASES' | translate }}"
[apps]="recentlyAddedApps"
(seeMoreClicked)="showRecentlyAddedApps()"
></app-section>

<app-section
*ngIf="!isRecentlyUpdatedLoading"
title="{{ 'PAGES.HOME.RECENTLY_UPDATED' | translate }}"
[apps]="recentlyUpdatedApps"
(seeMoreClicked)="showRecentlyUpdatedApps()"
></app-section>

<div
*ngIf="isRecentlyAddedLoading || isRecentlyUpdatedLoading"
[nbSpinner]="true"
nbSpinnerSize="giant"
class="loading-indicator"
></div>
4 changes: 4 additions & 0 deletions src/app/ui/pages/home/home.component.scss
@@ -0,0 +1,4 @@
.loading-indicator {
height: 100%;
position: relative;
}
30 changes: 24 additions & 6 deletions src/app/ui/pages/home/home.component.ts
Expand Up @@ -11,6 +11,8 @@ import { Router } from '@angular/router';
export class HomeComponent implements OnInit {
recentlyUpdatedApps: Application[] = [];
recentlyAddedApps: Application[] = [];
isRecentlyAddedLoading = false;
isRecentlyUpdatedLoading = false;

constructor(
private applicationService: ApplicationService,
Expand All @@ -23,15 +25,31 @@ export class HomeComponent implements OnInit {
}

private getRecentlyAddedApps(): void {
this.applicationService.getRecentlyAdded().then((apps) => {
this.recentlyAddedApps = apps;
});
this.isRecentlyAddedLoading = true;
this.applicationService
.getRecentlyAdded()
.then((apps) => {
this.recentlyAddedApps = apps;
this.isRecentlyAddedLoading = false;
})
.catch((err) => {
console.error(err);
this.isRecentlyAddedLoading = false;
});
}

private getRecentlyUpdatedApps(): void {
this.applicationService.getRecentlyUpdated().then((apps) => {
this.recentlyUpdatedApps = apps;
});
this.isRecentlyUpdatedLoading = true;
this.applicationService
.getRecentlyUpdated()
.then((apps) => {
this.recentlyUpdatedApps = apps;
this.isRecentlyUpdatedLoading = false;
})
.catch((err) => {
console.error(err);
this.isRecentlyUpdatedLoading = false;
});
}

async showRecentlyAddedApps(): Promise<void> {
Expand Down
2 changes: 2 additions & 0 deletions src/app/ui/pages/home/home.module.ts
Expand Up @@ -5,6 +5,7 @@ import { RouterModule, Routes } from '@angular/router';
import { HomeComponent } from './home.component';
import { SectionModule } from '../../components/section/section.module';
import { TranslateModule } from '@ngx-translate/core';
import { NbSpinnerModule } from '@nebular/theme';

const routes: Routes = [{ path: '', component: HomeComponent }];

Expand All @@ -15,6 +16,7 @@ const routes: Routes = [{ path: '', component: HomeComponent }];
RouterModule.forChild(routes),
SectionModule,
TranslateModule.forChild(),
NbSpinnerModule,
],
})
export class HomeModule {}

0 comments on commit 92bb978

Please sign in to comment.