add mp with icons and update after review
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
CUSTOM_ELEMENTS_SCHEMA,
|
||||
computed,
|
||||
effect,
|
||||
inject,
|
||||
input,
|
||||
} from '@angular/core';
|
||||
import { MatButton } from '@angular/material/button';
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { Icon } from '../../shared/icon/icon';
|
||||
@@ -11,21 +20,46 @@ import { GorodarActions } from '../../state';
|
||||
imports: [Icon, RouterLink, MatButton],
|
||||
templateUrl: './collect-success.html',
|
||||
styleUrl: './collect-success.scss',
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class CollectSuccess {
|
||||
private readonly store = inject(Store);
|
||||
private readonly location = inject(Location);
|
||||
private readonly router = inject(Router);
|
||||
|
||||
readonly mode = input<'claim' | 'preview'>('claim');
|
||||
readonly title = input.required<string>();
|
||||
readonly cityName = input.required<string>();
|
||||
readonly opened = input.required<number>();
|
||||
readonly total = input.required<number>();
|
||||
readonly matchPercent = input(91);
|
||||
readonly image = input.required<string>();
|
||||
readonly model = input<string | undefined>(undefined);
|
||||
readonly cityName = input('');
|
||||
readonly opened = input(0);
|
||||
readonly total = input(1);
|
||||
|
||||
protected readonly from = computed(() =>
|
||||
Math.max(0, Math.round(((this.opened() - 1) / this.total()) * 100)),
|
||||
);
|
||||
protected readonly to = computed(() => Math.round((this.opened() / this.total()) * 100));
|
||||
constructor() {
|
||||
effect(() => {
|
||||
if (!this.model()) {
|
||||
return;
|
||||
}
|
||||
|
||||
void import('@google/model-viewer/dist/model-viewer.min.js');
|
||||
});
|
||||
}
|
||||
|
||||
protected readonly from = computed(() => {
|
||||
const total = this.total();
|
||||
if (total <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.max(0, Math.round(((this.opened() - 1) / total) * 100));
|
||||
});
|
||||
protected readonly to = computed(() => {
|
||||
const total = this.total();
|
||||
if (total <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.round((this.opened() / total) * 100);
|
||||
});
|
||||
|
||||
protected readonly rays = Array.from({ length: 24 }, (_, index) => {
|
||||
const angle = (index / 24) * Math.PI * 2;
|
||||
@@ -44,4 +78,13 @@ export class CollectSuccess {
|
||||
protected leave(): void {
|
||||
this.store.dispatch(GorodarActions.claimReset());
|
||||
}
|
||||
|
||||
protected goBack(): void {
|
||||
if (window.history.length > 1) {
|
||||
this.location.back();
|
||||
return;
|
||||
}
|
||||
|
||||
void this.router.navigateByUrl('/city');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user