Skip to content

Commit

Permalink
Show video icon on thumbnail if the asset is video. (#629)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanwu1105 committed Apr 20, 2021
1 parent 64af111 commit 9c739a4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@
src="/assets/images/location.svg"
class="located"
></ion-icon>
<img *ngIf="thumbnailUrl$ | async as thumbnailUrl" [src]="thumbnailUrl" />
<ion-icon *ngIf="isVideo$ | async" name="videocam" class="is-video"></ion-icon>
<img
*ngIf="thumbnailUrl$ | async as thumbnailUrl"
loading="lazy"
decoding="async"
[src]="thumbnailUrl"
/>
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,34 @@
ion-icon {
color: white;
z-index: 10;
position: absolute;
opacity: 0.3;
}

ion-icon.collecting {
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
opacity: 0.3;
font-size: 24px;
}

ion-icon.uploaded {
position: absolute;
bottom: 9px;
left: 5px;
font-size: 13px;
opacity: 0.3;
}

ion-icon.located {
position: absolute;
bottom: 8px;
left: 23px;
font-size: 16px;
opacity: 0.3;
}

ion-icon.is-video {
top: 8px;
right: 8px;
font-size: 16px;
}

img {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ export class CaptureItemComponent {
map(proof => isValidGeolocation(proof))
);

readonly isVideo$ = this.proof$.pipe(
concatMap(proof => proof.getFirstAssetMeta()),
map(meta => meta.mimeType.startsWith('video'))
);

constructor(
private readonly captureService: CaptureService,
private readonly router: Router,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
"
[routerLink]="['post-capture-details', { id: postCapture.id }]"
>
<ng-container *ngIf="postCapture.parsed_meta.mime_type as mimeType">
<ion-icon
*ngIf="mimeType | startsWith: 'video'"
name="videocam"
class="is-video"
></ion-icon
></ng-container>
<ion-img [src]="postCapture.asset_file_thumbnail"></ion-img>
</mat-grid-tile>
</mat-grid-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ ion-segment {
overflow: hidden;
border-radius: 4px;
}

ion-icon.is-video {
color: white;
z-index: 10;
position: absolute;
opacity: 0.3;
top: 8px;
right: 8px;
font-size: 16px;
}
}
}

Expand Down
8 changes: 8 additions & 0 deletions src/app/shared/pipes/starts-with/starts-with.pipe.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { StartsWithPipe } from './starts-with.pipe';

describe('StartsWithPipe', () => {
it('create an instance', () => {
const pipe = new StartsWithPipe();
expect(pipe).toBeTruthy();
});
});
11 changes: 11 additions & 0 deletions src/app/shared/pipes/starts-with/starts-with.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'startsWith',
})
export class StartsWithPipe implements PipeTransform {
// eslint-disable-next-line class-methods-use-this
transform(value: string, prefix: string) {
return value.startsWith(prefix);
}
}
2 changes: 2 additions & 0 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ import { MediaComponent } from './components/media/media.component';
import { MigratingDialogComponent } from './components/migrating-dialog/migrating-dialog.component';
import { CapacitorPluginsModule } from './core/capacitor-plugins/capacitor-plugins.module';
import { MaterialModule } from './core/material/material.module';
import { StartsWithPipe } from './pipes/starts-with/starts-with.pipe';

const declarations = [
MigratingDialogComponent,
AvatarComponent,
MediaComponent,
StartsWithPipe,
];

const imports = [
Expand Down

0 comments on commit 9c739a4

Please sign in to comment.