-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement fullscreen image viewer (#602)
- Loading branch information
1 parent
c93dd3d
commit 791dc92
Showing
11 changed files
with
149 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/app/shared/core/image-viewer/image-viewer-routing.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule, Routes } from '@angular/router'; | ||
import { ImageViewerPage } from './image-viewer.page'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: ImageViewerPage, | ||
}, | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule], | ||
}) | ||
export class ImageViewerPageRoutingModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { PinchZoomModule } from 'ngx-pinch-zoom'; | ||
import { SharedModule } from '../../shared.module'; | ||
import { ImageViewerPageRoutingModule } from './image-viewer-routing.module'; | ||
import { ImageViewerPage } from './image-viewer.page'; | ||
|
||
@NgModule({ | ||
imports: [SharedModule, ImageViewerPageRoutingModule, PinchZoomModule], | ||
declarations: [ImageViewerPage], | ||
}) | ||
export class ImageViewerPageModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<ion-button (click)="dismiss()" color="light" fill="clear" class="dismiss"> | ||
<ion-icon name="arrow-back-outline" slot="icon-only"></ion-icon> | ||
</ion-button> | ||
|
||
<pinch-zoom *ngIf="src$ | async as src"> | ||
<img [src]="src" /> | ||
</pinch-zoom> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
:host { | ||
background: var(--ion-color-dark); | ||
} | ||
|
||
.dismiss { | ||
position: absolute; | ||
left: 0; | ||
z-index: 1; | ||
width: 48px; | ||
height: 48px; | ||
|
||
--border-radius: 50%; | ||
--padding-end: 0; | ||
--padding-start: 0; | ||
} | ||
|
||
pinch-zoom { | ||
height: 100%; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/app/shared/core/image-viewer/image-viewer.page.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { SharedTestingModule } from '../../shared-testing.module'; | ||
import { ImageViewerPage } from './image-viewer.page'; | ||
|
||
describe('ImageViewerPage', () => { | ||
let component: ImageViewerPage; | ||
let fixture: ComponentFixture<ImageViewerPage>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ImageViewerPage], | ||
imports: [SharedTestingModule], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ImageViewerPage); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
})); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Component } from '@angular/core'; | ||
import { DomSanitizer } from '@angular/platform-browser'; | ||
import { ActivatedRoute } from '@angular/router'; | ||
import { NavController } from '@ionic/angular'; | ||
import { distinctUntilChanged, map } from 'rxjs/operators'; | ||
import { isNonNullable } from '../../../utils/rx-operators/rx-operators'; | ||
|
||
@Component({ | ||
selector: 'app-image-viewer', | ||
templateUrl: './image-viewer.page.html', | ||
styleUrls: ['./image-viewer.page.scss'], | ||
}) | ||
export class ImageViewerPage { | ||
readonly src$ = this.route.paramMap.pipe( | ||
map(params => params.get('src')), | ||
isNonNullable(), | ||
distinctUntilChanged(), | ||
map(src => this.sanitizer.bypassSecurityTrustUrl(src)) | ||
); | ||
|
||
constructor( | ||
private readonly navController: NavController, | ||
private readonly route: ActivatedRoute, | ||
private readonly sanitizer: DomSanitizer | ||
) {} | ||
|
||
dismiss() { | ||
this.navController.back(); | ||
} | ||
} |