-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmodal.component.ts
More file actions
68 lines (63 loc) · 1.86 KB
/
modal.component.ts
File metadata and controls
68 lines (63 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { Component, NO_ERRORS_SCHEMA, OnDestroy, OnInit, ViewContainerRef, inject } from '@angular/core';
import {
ModalDialogService,
NativeDialogModule,
NativeDialogRef,
NativeDialogService,
NativeScriptCommonModule,
} from '@nativescript/angular';
import { ItemService } from '../item/item.service';
import { View } from '@nativescript/core';
@Component({
selector: 'ns-modal',
templateUrl: `./modal.component.html`,
imports: [NativeScriptCommonModule, NativeDialogModule],
schemas: [NO_ERRORS_SCHEMA],
})
export class ModalComponent implements OnInit, OnDestroy {
private ref = inject(NativeDialogRef<ModalComponent>, { optional: true });
private nativeDialog = inject(NativeDialogService);
private modalDialog = inject(ModalDialogService);
private vcRef = inject(ViewContainerRef);
id = Math.floor(Math.random() * 1000);
itemService = inject(ItemService);
logo: string;
color: string;
constructor() {
this.logo = this.itemService.flavors[this.itemService.currentFlavor].logo;
this.color = this.itemService.flavors[this.itemService.currentFlavor].color;
}
openNewModal() {
this.itemService.currentFlavor++;
const ref = this.nativeDialog.open(ModalComponent, {
nativeOptions: {
fullscreen: !!global.isAndroid,
},
});
ref.afterClosed().subscribe(() => {
this.itemService.currentFlavor--;
});
}
ngOnInit() {
console.log('modal init');
}
ngOnDestroy() {
console.log('modal destroy');
}
img: View;
loadedImg(args) {
this.img = args.object as View;
const scaleImage = (up: boolean) => {
this.img
.animate({
scale: { x: up ? 1.5 : 1.0, y: up ? 1.5 : 1.0 },
translate: { x: up ? -100 : 0, y: 0 },
duration: 1000,
})
.then(() => {
scaleImage(up ? false : true);
});
};
scaleImage(true);
}
}