fix and add documents view
This commit is contained in:
@@ -5,6 +5,7 @@ import { CityPage } from './pages/city-page/city-page';
|
||||
import { CollectionsPage } from './pages/collections-page/collections-page';
|
||||
import { IconPreviewPage } from './pages/icon-preview-page/icon-preview-page';
|
||||
import { MapItemPage } from './pages/map-item-page/map-item-page';
|
||||
import { visitedItemGuard } from './pages/map-item-page/visited-item.guard';
|
||||
import { MapPage } from './pages/map-page/map-page';
|
||||
|
||||
export const routes: Routes = [
|
||||
@@ -13,7 +14,7 @@ export const routes: Routes = [
|
||||
{ path: 'collections', component: CollectionsPage },
|
||||
{ path: 'collection', pathMatch: 'full', redirectTo: '' },
|
||||
{ path: 'city/:areaId/:id/icon', component: IconPreviewPage },
|
||||
{ path: 'city/:areaId/:id', component: MapItemPage },
|
||||
{ path: 'city/:areaId/:id', component: MapItemPage, canActivate: [visitedItemGuard] },
|
||||
{ path: 'city/:areaId', component: CityPage },
|
||||
{ path: '**', redirectTo: '' },
|
||||
];
|
||||
|
||||
@@ -65,15 +65,11 @@ export function findAttraction(area: Area | AreaDetails, id: string): Attraction
|
||||
return areaAttractions(area).find((item) => item.id === id) ?? null;
|
||||
}
|
||||
|
||||
export function isObtained(attraction: Attraction, collectedIds: ReadonlySet<string>): boolean {
|
||||
return attraction.visited || collectedIds.has(attraction.id);
|
||||
}
|
||||
|
||||
export function areaOpenedCount(area: Area | AreaDetails, collectedIds: ReadonlySet<string>): number {
|
||||
export function areaOpenedCount(area: Area | AreaDetails): number {
|
||||
const attractions = areaAttractions(area);
|
||||
|
||||
if (attractions.length > 0) {
|
||||
return attractions.filter((item) => isObtained(item, collectedIds)).length;
|
||||
return attractions.filter((item) => item.visited).length;
|
||||
}
|
||||
|
||||
return area.progress?.visited ?? 0;
|
||||
@@ -89,12 +85,12 @@ export function areaTotalCount(area: Area | AreaDetails): number {
|
||||
return area.progress?.total ?? 0;
|
||||
}
|
||||
|
||||
export function areaProgress(area: Area | AreaDetails, collectedIds: ReadonlySet<string>): number {
|
||||
export function areaProgress(area: Area | AreaDetails): number {
|
||||
const total = areaTotalCount(area);
|
||||
|
||||
if (!total) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return Math.round((areaOpenedCount(area, collectedIds) / total) * 100);
|
||||
return Math.round((areaOpenedCount(area) / total) * 100);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,12 @@
|
||||
{{ pending() ? 'Отправляем…' : 'Получить код' }}
|
||||
</button>
|
||||
<button class="sheet__ghost" type="button" (click)="dismiss()">Пока просто посмотрю</button>
|
||||
<p class="sheet__legal">
|
||||
Продолжая, вы принимаете
|
||||
<a [href]="termsUrl" target="_blank" rel="noopener noreferrer">Пользовательское соглашение</a>
|
||||
и
|
||||
<a [href]="privacyUrl" target="_blank" rel="noopener noreferrer">Политику обработки персональных данных</a>.
|
||||
</p>
|
||||
} @else {
|
||||
<h2 id="auth-sheet-title">{{ title() }}</h2>
|
||||
<p class="sheet__lead">
|
||||
|
||||
@@ -73,11 +73,7 @@
|
||||
.sheet__lock {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
margin: 8px auto 16px;
|
||||
border: 1.5px solid var(--color-accent);
|
||||
border-radius: 18px;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
@@ -205,6 +201,20 @@
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sheet__legal {
|
||||
margin: 8px 0 0;
|
||||
color: var(--color-muted);
|
||||
font-size: 12px;
|
||||
line-height: 1.45;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sheet__legal a {
|
||||
color: var(--color-accent-soft);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
@keyframes sheet-in {
|
||||
from {
|
||||
transform: translateY(24px);
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { Icon } from '../../../shared/icon/icon';
|
||||
import { privacyDocumentUrl, termsDocumentUrl } from '../../../shared/legal-documents';
|
||||
import { RESEND_SECONDS } from '../../../state/gorodar.models';
|
||||
import {
|
||||
GorodarActions,
|
||||
@@ -57,6 +58,8 @@ export class AuthSheet {
|
||||
private dragVelocity = 0;
|
||||
private closeTimer = 0;
|
||||
|
||||
protected readonly termsUrl = termsDocumentUrl;
|
||||
protected readonly privacyUrl = privacyDocumentUrl;
|
||||
protected readonly emailDraft = signal('');
|
||||
protected readonly digits = signal<string[]>(emptyDigits());
|
||||
protected readonly secondsLeft = signal(0);
|
||||
|
||||
@@ -13,11 +13,9 @@ import {
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { Geolocation, type Position } from '@capacitor/geolocation';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import type { Attraction } from '../../areas/area.models';
|
||||
import { Icon } from '../../shared/icon/icon';
|
||||
import { selectCollectedIdSet } from '../../state';
|
||||
import { MapItemSheet } from '../map-item-sheet/map-item-sheet';
|
||||
|
||||
const MAP_KEY = 'bf0a466f-43a6-48c7-b274-7fea5952957b';
|
||||
@@ -136,7 +134,6 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
||||
@ViewChild('map', { static: true })
|
||||
private mapElement!: ElementRef<HTMLElement>;
|
||||
|
||||
private readonly store = inject(Store);
|
||||
private readonly zone = inject(NgZone);
|
||||
private raster: DgApi | null = null;
|
||||
private map: DgMap | null = null;
|
||||
@@ -154,7 +151,6 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
||||
private readonly markers = new Map<string, DgMarker>();
|
||||
private readonly mapReady = signal(false);
|
||||
private placedKey = '';
|
||||
private readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
||||
private readonly stopFollowing = (): void => {
|
||||
this.programmaticMove = false;
|
||||
this.zone.run(() => this.following.set(false));
|
||||
@@ -182,13 +178,12 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const items = this.attractions();
|
||||
const ids = this.collectedIds();
|
||||
|
||||
if (!this.mapReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.placeMarkers(items, ids);
|
||||
this.placeMarkers(items);
|
||||
});
|
||||
|
||||
effect(() => {
|
||||
@@ -366,7 +361,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
||||
this.watchId = null;
|
||||
}
|
||||
|
||||
private placeMarkers(items: Attraction[], collectedIds: Set<string>): void {
|
||||
private placeMarkers(items: Attraction[]): void {
|
||||
const map = this.map;
|
||||
const api = this.raster;
|
||||
|
||||
@@ -381,7 +376,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
||||
const element = this.markerElements.get(item.id);
|
||||
|
||||
if (element) {
|
||||
this.setMarkerIcon(element, collectedIds.has(item.id) || item.visited);
|
||||
this.setMarkerIcon(element, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -401,10 +396,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.markers.set(
|
||||
item.id,
|
||||
this.createMarker(api, map, item, collectedIds.has(item.id) || item.visited),
|
||||
);
|
||||
this.markers.set(item.id, this.createMarker(api, map, item));
|
||||
}
|
||||
|
||||
if (this.markers.size > 0) {
|
||||
@@ -412,26 +404,29 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
private createMarker(api: DgApi, map: DgMap, landmark: Attraction, collected: boolean): DgMarker {
|
||||
private createMarker(api: DgApi, map: DgMap, item: Attraction): DgMarker {
|
||||
const markerElement = document.createElement('button');
|
||||
markerElement.type = 'button';
|
||||
markerElement.className = 'city-map__marker';
|
||||
markerElement.setAttribute('aria-label', landmark.name);
|
||||
markerElement.innerHTML =
|
||||
'<span class="city-map__radius"></span><img width="40" height="40" alt="" /><span class="city-map__label"></span>';
|
||||
markerElement.setAttribute('aria-label', item.name);
|
||||
markerElement.innerHTML = `<span></span><img width="40" height="40" alt="" /><span class="city-map__label"></span>`;
|
||||
// '<span class="city-map__radius"></span><img width="40" height="40" alt="" /><span class="city-map__label"></span>';
|
||||
// Marker with radius
|
||||
// markerElement.innerHTML =
|
||||
// '<span class="city-map__radius"></span><img width="40" height="40" alt="" /><span class="city-map__label"></span>';
|
||||
const label = markerElement.querySelector('.city-map__label');
|
||||
|
||||
if (label) {
|
||||
label.textContent = landmark.name;
|
||||
label.textContent = item.name;
|
||||
}
|
||||
|
||||
this.markerElements.set(landmark.id, markerElement);
|
||||
this.setMarkerIcon(markerElement, collected);
|
||||
this.markerElements.set(item.id, markerElement);
|
||||
this.setMarkerIcon(markerElement, item);
|
||||
|
||||
const marker = this.addHtmlMarker(
|
||||
api,
|
||||
map,
|
||||
[landmark.longitude, landmark.latitude],
|
||||
[item.longitude, item.latitude],
|
||||
markerElement,
|
||||
LANDMARK_SIZE,
|
||||
1,
|
||||
@@ -439,7 +434,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
||||
);
|
||||
|
||||
marker.on('click', () => {
|
||||
this.zone.run(() => this.selectLandmark(landmark));
|
||||
this.zone.run(() => this.selectLandmark(item));
|
||||
});
|
||||
|
||||
return marker;
|
||||
@@ -491,20 +486,20 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
||||
return marker;
|
||||
}
|
||||
|
||||
private setMarkerIcon(element: HTMLElement, collected: boolean): void {
|
||||
private setMarkerIcon(element: HTMLElement, item: Attraction): void {
|
||||
const img = element.querySelector('img');
|
||||
|
||||
if (!img) {
|
||||
return;
|
||||
}
|
||||
|
||||
const src = collected ? '/assets/icons/check-marker.svg' : '/assets/icons/lock-marker.svg';
|
||||
const src = item.visited ? '/assets/icons/check-marker.svg' : '/assets/icons/lock-marker.svg';
|
||||
|
||||
if (img.getAttribute('src') !== src) {
|
||||
img.setAttribute('src', src);
|
||||
}
|
||||
|
||||
element.classList.toggle('city-map__marker--open', collected);
|
||||
element.classList.toggle('city-map__marker--open', item.visited);
|
||||
}
|
||||
|
||||
private selectLandmark(landmark: Attraction): void {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<article class="card">
|
||||
<div class="card__row">
|
||||
@let lockIcon = '/assets/icons/cell-lock.svg';
|
||||
<div class="card__row" [style.margin-bottom]="attraction().visited ? '0' : '16px'">
|
||||
<img
|
||||
class="card__stamp"
|
||||
[src]="attraction().iconUrl || '/assets/icons/cell-lock.svg'"
|
||||
[src]="!attraction().visited ? lockIcon : attraction().iconUrl || lockIcon"
|
||||
alt=""
|
||||
width="72"
|
||||
height="72"
|
||||
@@ -18,7 +19,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a class="btn" [routerLink]="['/city', areaId(), attraction().id]">
|
||||
Открыть карточку
|
||||
</a>
|
||||
@if (!attraction().visited) {
|
||||
<a class="btn" [routerLink]="['/city', areaId(), attraction().id]">Открыть карточку</a>
|
||||
}
|
||||
</article>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 14px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.card__stamp {
|
||||
@@ -51,4 +50,3 @@
|
||||
color: var(--color-success);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,7 @@ import {
|
||||
type Area,
|
||||
type Attraction,
|
||||
} from '../../areas/area.models';
|
||||
import {
|
||||
GorodarActions,
|
||||
selectAreas,
|
||||
selectAreasError,
|
||||
selectAreasStatus,
|
||||
selectCollectedIdSet,
|
||||
} from '../../state';
|
||||
import { GorodarActions, selectAreas, selectAreasError, selectAreasStatus } from '../../state';
|
||||
|
||||
@Component({
|
||||
selector: 'app-cities-page',
|
||||
@@ -30,10 +24,8 @@ export class CitiesPage {
|
||||
protected readonly areas = this.store.selectSignal(selectAreas);
|
||||
protected readonly status = this.store.selectSignal(selectAreasStatus);
|
||||
protected readonly error = this.store.selectSignal(selectAreasError);
|
||||
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
||||
|
||||
protected openedCount(area: Area): number {
|
||||
return areaOpenedCount(area, this.collectedIds());
|
||||
return areaOpenedCount(area);
|
||||
}
|
||||
|
||||
protected totalCount(area: Area): number {
|
||||
@@ -41,11 +33,11 @@ export class CitiesPage {
|
||||
}
|
||||
|
||||
protected progress(area: Area): number {
|
||||
return areaProgress(area, this.collectedIds());
|
||||
return areaProgress(area);
|
||||
}
|
||||
|
||||
protected obtained(attraction: Attraction): boolean {
|
||||
return attraction.visited || this.collectedIds().has(attraction.id);
|
||||
return attraction.visited;
|
||||
}
|
||||
|
||||
protected reload(): void {
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
areaProgress,
|
||||
areaTotalCount,
|
||||
findAttraction,
|
||||
isObtained,
|
||||
type Attraction,
|
||||
} from '../../areas/area.models';
|
||||
import { CityMap } from '../../map/city-map/city-map';
|
||||
@@ -26,7 +25,6 @@ import {
|
||||
selectAreaDetailError,
|
||||
selectAreaDetails,
|
||||
selectAreaDetailStatus,
|
||||
selectCollectedIdSet,
|
||||
} from '../../state';
|
||||
|
||||
type CollectionFilter = 'all' | 'open' | 'closed';
|
||||
@@ -53,10 +51,9 @@ export class CityPage {
|
||||
protected readonly tab = signal<CityTab>('objects');
|
||||
protected readonly mapReady = signal(false);
|
||||
protected readonly filter = signal<CollectionFilter>('all');
|
||||
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
||||
protected readonly openedCount = computed(() => {
|
||||
const area = this.area();
|
||||
return area ? areaOpenedCount(area, this.collectedIds()) : 0;
|
||||
return area ? areaOpenedCount(area) : 0;
|
||||
});
|
||||
protected readonly totalCount = computed(() => {
|
||||
const area = this.area();
|
||||
@@ -64,7 +61,7 @@ export class CityPage {
|
||||
});
|
||||
protected readonly progress = computed(() => {
|
||||
const area = this.area();
|
||||
return area ? areaProgress(area, this.collectedIds()) : 0;
|
||||
return area ? areaProgress(area) : 0;
|
||||
});
|
||||
protected readonly closedCount = computed(() => this.totalCount() - this.openedCount());
|
||||
protected readonly mapAttractions = computed(() => {
|
||||
@@ -74,13 +71,12 @@ export class CityPage {
|
||||
protected readonly landmarks = computed(() => {
|
||||
const current = this.area();
|
||||
const items = current ? areaAttractions(current) : [];
|
||||
const ids = this.collectedIds();
|
||||
|
||||
switch (this.filter()) {
|
||||
case 'open':
|
||||
return items.filter((item) => isObtained(item, ids));
|
||||
return items.filter((item) => item.visited);
|
||||
case 'closed':
|
||||
return items.filter((item) => !isObtained(item, ids));
|
||||
return items.filter((item) => !item.visited);
|
||||
default:
|
||||
return items;
|
||||
}
|
||||
@@ -117,13 +113,14 @@ export class CityPage {
|
||||
}
|
||||
|
||||
protected isOpen(attraction: Attraction): boolean {
|
||||
return isObtained(attraction, this.collectedIds());
|
||||
return attraction.visited;
|
||||
}
|
||||
|
||||
protected objectRoute(id: string): string[] {
|
||||
const current = this.area();
|
||||
const attraction = current ? findAttraction(current, id) : null;
|
||||
const open = attraction ? isObtained(attraction, this.collectedIds()) : false;
|
||||
return open ? ['/city', this.areaId(), id, 'icon'] : ['/city', this.areaId(), id];
|
||||
return attraction?.visited
|
||||
? ['/city', this.areaId(), id, 'icon']
|
||||
: ['/city', this.areaId(), id];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,18 @@
|
||||
@if (authenticated()) {
|
||||
<header class="account">
|
||||
<p class="account__email">{{ accountEmail() }}</p>
|
||||
<button class="account__logout" type="button" aria-label="Выйти" (click)="logout()">
|
||||
<app-icon name="logout" [size]="22" />
|
||||
</button>
|
||||
<div class="account__actions">
|
||||
<button class="account__action" type="button" aria-label="Документы" (click)="openDocuments()">
|
||||
<app-icon name="document" [size]="22" />
|
||||
</button>
|
||||
<button class="account__action" type="button" aria-label="Выйти" (click)="logout()">
|
||||
<app-icon name="logout" [size]="22" />
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
} @else {
|
||||
<header class="account">
|
||||
<button class="account__login" type="button" (click)="login()">Войти</button>
|
||||
</header>
|
||||
}
|
||||
|
||||
@@ -64,4 +73,8 @@
|
||||
} @else {
|
||||
<p class="empty">Пока нет полученных объектов.</p>
|
||||
}
|
||||
|
||||
@if (documentsOpen()) {
|
||||
<app-documents-sheet (dismissed)="closeDocuments()" />
|
||||
}
|
||||
</section>
|
||||
|
||||
@@ -27,7 +27,13 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.account__logout {
|
||||
.account__actions {
|
||||
display: flex;
|
||||
flex: none;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.account__action {
|
||||
display: flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
@@ -35,13 +41,27 @@
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
padding: 0;
|
||||
border: 1px solid var(--color-border);
|
||||
border: 0;
|
||||
border-radius: 14px;
|
||||
background: var(--color-surface);
|
||||
background: transparent;
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.account__login {
|
||||
margin-left: auto;
|
||||
height: 44px;
|
||||
padding: 0 16px;
|
||||
border: 0;
|
||||
border-radius: 14px;
|
||||
background: var(--color-primary);
|
||||
color: var(--color-label);
|
||||
font: inherit;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.page__intro {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { afterNextRender, ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
|
||||
import {
|
||||
afterNextRender,
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
computed,
|
||||
inject,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
@@ -7,23 +14,22 @@ import {
|
||||
areaOpenedCount,
|
||||
areaProgress,
|
||||
areaTotalCount,
|
||||
isObtained,
|
||||
type Attraction,
|
||||
} from '../../areas/area.models';
|
||||
import { DocumentsSheet } from '../../shared/documents-sheet/documents-sheet';
|
||||
import { Icon } from '../../shared/icon/icon';
|
||||
import {
|
||||
GorodarActions,
|
||||
selectAreas,
|
||||
selectAuthEmail,
|
||||
selectAuthenticated,
|
||||
selectCollectedIdSet,
|
||||
selectOpenedCount,
|
||||
selectProfile,
|
||||
} from '../../state';
|
||||
|
||||
@Component({
|
||||
selector: 'app-collections-page',
|
||||
imports: [Icon, RouterLink],
|
||||
imports: [Icon, RouterLink, DocumentsSheet],
|
||||
templateUrl: './collections-page.html',
|
||||
styleUrl: './collections-page.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
@@ -33,26 +39,24 @@ export class CollectionsPage {
|
||||
|
||||
private readonly areas = this.store.selectSignal(selectAreas);
|
||||
protected readonly profile = this.store.selectSignal(selectProfile);
|
||||
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
||||
protected readonly openedCount = this.store.selectSignal(selectOpenedCount);
|
||||
protected readonly authenticated = this.store.selectSignal(selectAuthenticated);
|
||||
private readonly authEmail = this.store.selectSignal(selectAuthEmail);
|
||||
protected readonly accountEmail = computed(() =>
|
||||
this.authenticated() ? this.authEmail() : this.profile().email,
|
||||
);
|
||||
protected readonly packs = computed(() => {
|
||||
const ids = this.collectedIds();
|
||||
|
||||
return this.areas()
|
||||
protected readonly documentsOpen = signal(false);
|
||||
protected readonly packs = computed(() =>
|
||||
this.areas()
|
||||
.map((area) => ({
|
||||
area,
|
||||
items: areaAttractions(area).filter((item) => isObtained(item, ids)),
|
||||
opened: areaOpenedCount(area, ids),
|
||||
items: areaAttractions(area).filter((item) => item.visited),
|
||||
opened: areaOpenedCount(area),
|
||||
total: areaTotalCount(area),
|
||||
progress: areaProgress(area, ids),
|
||||
progress: areaProgress(area),
|
||||
}))
|
||||
.filter((pack) => pack.items.length > 0);
|
||||
});
|
||||
.filter((pack) => pack.items.length > 0),
|
||||
);
|
||||
|
||||
constructor() {
|
||||
afterNextRender(() => {
|
||||
@@ -69,12 +73,25 @@ export class CollectionsPage {
|
||||
);
|
||||
|
||||
protected objectRoute(areaId: string, attraction: Attraction): string[] {
|
||||
return isObtained(attraction, this.collectedIds())
|
||||
return attraction.visited
|
||||
? ['/city', areaId, attraction.id, 'icon']
|
||||
: ['/city', areaId, attraction.id];
|
||||
}
|
||||
|
||||
protected openDocuments(): void {
|
||||
this.documentsOpen.set(true);
|
||||
}
|
||||
|
||||
protected closeDocuments(): void {
|
||||
this.documentsOpen.set(false);
|
||||
}
|
||||
|
||||
protected login(): void {
|
||||
this.store.dispatch(GorodarActions.authSheetOpened({ intent: 'collection' }));
|
||||
}
|
||||
|
||||
protected logout(): void {
|
||||
this.documentsOpen.set(false);
|
||||
this.store.dispatch(GorodarActions.logout());
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,9 @@ import { ChangeDetectionStrategy, Component, computed, effect, inject, input } f
|
||||
import { Router, RouterLink } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { findAttraction, isObtained } from '../../areas/area.models';
|
||||
import { findAttraction } from '../../areas/area.models';
|
||||
import { CollectSuccess } from '../../claim/collect-success/collect-success';
|
||||
import {
|
||||
GorodarActions,
|
||||
selectAreaDetails,
|
||||
selectAreaDetailStatus,
|
||||
selectCollectedIdSet,
|
||||
} from '../../state';
|
||||
import { GorodarActions, selectAreaDetails, selectAreaDetailStatus } from '../../state';
|
||||
|
||||
@Component({
|
||||
selector: 'app-icon-preview-page',
|
||||
@@ -24,7 +19,6 @@ export class IconPreviewPage {
|
||||
private readonly details = this.store.selectSignal(selectAreaDetails);
|
||||
private readonly detailStatus = this.store.selectSignal(selectAreaDetailStatus);
|
||||
protected readonly status = computed(() => this.detailStatus()[this.areaId()] ?? 'loading');
|
||||
private readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
||||
|
||||
readonly areaId = input.required<string>();
|
||||
readonly id = input.required<string>();
|
||||
@@ -33,10 +27,7 @@ export class IconPreviewPage {
|
||||
const area = this.details()[this.areaId()];
|
||||
return area ? findAttraction(area, this.id()) : null;
|
||||
});
|
||||
protected readonly collected = computed(() => {
|
||||
const item = this.landmark();
|
||||
return item ? isObtained(item, this.collectedIds()) : false;
|
||||
});
|
||||
protected readonly collected = computed(() => this.landmark()?.visited ?? false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
@@ -53,7 +44,7 @@ export class IconPreviewPage {
|
||||
effect(() => {
|
||||
const item = this.landmark();
|
||||
|
||||
if (this.status() !== 'ready' || !item || isObtained(item, this.collectedIds())) {
|
||||
if (this.status() !== 'ready' || !item || item.visited) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,33 +68,14 @@
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (collected()) {
|
||||
<section>
|
||||
<h2>Ваше фото</h2>
|
||||
<button class="owned-photo" type="button" (click)="openPhoto()">
|
||||
<img
|
||||
[src]="userPhoto() ?? '/assets/illustrations/photo-day.svg'"
|
||||
alt="Ваше фото объекта"
|
||||
/>
|
||||
<span class="owned-photo__badge">
|
||||
<app-icon name="check" [size]="14" />
|
||||
Подтверждено
|
||||
</span>
|
||||
</button>
|
||||
<p class="object__hint">
|
||||
Этот объект уже в вашей коллекции. Повторно его получить нельзя.
|
||||
</p>
|
||||
</section>
|
||||
} @else {
|
||||
<section>
|
||||
<h2>Как забрать</h2>
|
||||
<ol class="steps">
|
||||
<li>Приезжайте на место и найдите объект</li>
|
||||
<li>Нажмите «Забрать» и сфотографируйте объект</li>
|
||||
<li>Получите объект в свою коллекцию</li>
|
||||
</ol>
|
||||
</section>
|
||||
}
|
||||
<section>
|
||||
<h2>Как забрать</h2>
|
||||
<ol class="steps">
|
||||
<li>Приезжайте на место и найдите объект</li>
|
||||
<li>Нажмите «Забрать» и сфотографируйте объект</li>
|
||||
<li>Получите объект в свою коллекцию</li>
|
||||
</ol>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@if (!collected()) {
|
||||
@@ -108,22 +89,6 @@
|
||||
}
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (photoOpen()) {
|
||||
@if (userPhoto(); as image) {
|
||||
<div class="photo-viewer" (click)="closePhoto()">
|
||||
<button
|
||||
class="photo-viewer__close"
|
||||
type="button"
|
||||
aria-label="Закрыть"
|
||||
(click)="closePhoto()"
|
||||
>
|
||||
<app-icon name="chevron-left" [size]="22" />
|
||||
</button>
|
||||
<img [src]="image" alt="Ваше фото объекта" (click)="$event.stopPropagation()" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
} @else if (status() === 'loading') {
|
||||
<section class="object object--empty">
|
||||
<p>Загружаем…</p>
|
||||
|
||||
@@ -13,12 +13,7 @@ import { MatButton } from '@angular/material/button';
|
||||
import { Router } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import {
|
||||
areaOpenedCount,
|
||||
areaTotalCount,
|
||||
isObtained,
|
||||
type AreaDetails,
|
||||
} from '../../areas/area.models';
|
||||
import { areaOpenedCount, areaTotalCount, type AreaDetails } from '../../areas/area.models';
|
||||
import { ClaimFlow } from '../../claim/claim-flow/claim-flow';
|
||||
import { AudioGuide } from '../../shared/audio-guide/audio-guide';
|
||||
import { Icon } from '../../shared/icon/icon';
|
||||
@@ -32,7 +27,6 @@ import {
|
||||
selectAuthenticated,
|
||||
selectClaim,
|
||||
selectCollectedAt,
|
||||
selectCollectedIdSet,
|
||||
selectPhotos,
|
||||
} from '../../state';
|
||||
|
||||
@@ -63,28 +57,19 @@ export class MapItemPage {
|
||||
(): AreaDetails | null => this.details()[this.areaId()] ?? null,
|
||||
);
|
||||
protected readonly landmark = computed(() => this.attractions()[this.id()] ?? null);
|
||||
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
||||
protected readonly photos = this.store.selectSignal(selectPhotos);
|
||||
protected readonly collectedAtMap = this.store.selectSignal(selectCollectedAt);
|
||||
protected readonly claim = this.store.selectSignal(selectClaim);
|
||||
protected readonly openedCount = computed(() => {
|
||||
const area = this.area();
|
||||
return area ? areaOpenedCount(area, this.collectedIds()) : 0;
|
||||
return area ? areaOpenedCount(area) : 0;
|
||||
});
|
||||
protected readonly totalCount = computed(() => {
|
||||
const area = this.area();
|
||||
return area ? areaTotalCount(area) : 0;
|
||||
});
|
||||
|
||||
protected readonly collected = computed(() => {
|
||||
const item = this.landmark();
|
||||
return item ? isObtained(item, this.collectedIds()) : false;
|
||||
});
|
||||
|
||||
protected readonly userPhoto = computed(() => {
|
||||
const item = this.landmark();
|
||||
return item ? (this.photos()[item.id] ?? null) : null;
|
||||
});
|
||||
protected readonly collected = computed(() => this.landmark()?.visited ?? false);
|
||||
|
||||
protected readonly collectedLabel = computed(() => {
|
||||
if (!this.collected()) {
|
||||
@@ -111,8 +96,6 @@ export class MapItemPage {
|
||||
return claim.landmarkId === this.id() && claim.stage !== 'idle';
|
||||
});
|
||||
|
||||
protected readonly photoOpen = signal(false);
|
||||
|
||||
constructor() {
|
||||
effect(() => {
|
||||
const areaId = this.areaId();
|
||||
@@ -147,19 +130,4 @@ export class MapItemPage {
|
||||
|
||||
this.store.dispatch(GorodarActions.authSheetOpened({ intent: 'claim', landmarkId: this.id() }));
|
||||
}
|
||||
|
||||
protected openPhoto(): void {
|
||||
if (this.userPhoto()) {
|
||||
this.photoOpen.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected closePhoto(): void {
|
||||
this.photoOpen.set(false);
|
||||
}
|
||||
|
||||
@HostListener('document:keydown.escape')
|
||||
protected onEscape(): void {
|
||||
this.closePhoto();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { type CanActivateFn, Router } from '@angular/router';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { filter, map, take } from 'rxjs';
|
||||
|
||||
import { findAttraction } from '../../areas/area.models';
|
||||
import { GorodarActions, selectAreaDetails } from '../../state';
|
||||
|
||||
export const visitedItemGuard: CanActivateFn = (route) => {
|
||||
const store = inject(Store);
|
||||
const router = inject(Router);
|
||||
const areaId = route.paramMap.get('areaId') ?? '';
|
||||
const id = route.paramMap.get('id') ?? '';
|
||||
|
||||
store.dispatch(GorodarActions.areaRequested({ id: areaId }));
|
||||
|
||||
return store.select(selectAreaDetails).pipe(
|
||||
map((details) => {
|
||||
const area = details[areaId];
|
||||
return area ? findAttraction(area, id) : undefined;
|
||||
}),
|
||||
filter((item) => item !== undefined),
|
||||
take(1),
|
||||
map((item) => (item?.visited ? router.createUrlTree(['/city', areaId]) : true)),
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
<div class="sheet-root" [style.--drag-y.px]="dragY()">
|
||||
<button
|
||||
class="sheet-root__backdrop"
|
||||
type="button"
|
||||
aria-label="Закрыть"
|
||||
(click)="dismiss()"
|
||||
></button>
|
||||
|
||||
<div class="sheet-pop">
|
||||
<section
|
||||
class="sheet"
|
||||
[class.sheet--dragging]="dragging()"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="documents-sheet-title"
|
||||
(pointerdown)="onDragStart($event)"
|
||||
(pointermove)="onDragMove($event)"
|
||||
(pointerup)="onDragEnd($event)"
|
||||
(pointercancel)="onDragEnd($event)"
|
||||
>
|
||||
<button class="sheet__handle" type="button" aria-label="Закрыть" (click)="dismiss()"></button>
|
||||
|
||||
<div class="sheet__mark" aria-hidden="true">
|
||||
<app-icon name="document" [size]="28" />
|
||||
</div>
|
||||
|
||||
<h2 id="documents-sheet-title">Документы</h2>
|
||||
|
||||
<ul class="docs">
|
||||
@for (document of documents; track document.href) {
|
||||
<li>
|
||||
<a [href]="document.href" target="_blank" rel="noopener noreferrer">
|
||||
<span>{{ document.title }}</span>
|
||||
<app-icon name="chevron-right" [size]="20" />
|
||||
</a>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,132 @@
|
||||
:host {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.sheet-root {
|
||||
position: fixed;
|
||||
z-index: 70;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sheet-root__backdrop {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border: 0;
|
||||
background: rgb(8 7 6 / 64%);
|
||||
cursor: pointer;
|
||||
opacity: calc(1 - min(var(--drag-y, 0px), 280px) / 280px);
|
||||
}
|
||||
|
||||
.sheet-pop {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: min(100%, 480px);
|
||||
max-height: min(92dvh, 760px);
|
||||
animation: sheet-in 0.28s ease-out;
|
||||
}
|
||||
|
||||
.sheet {
|
||||
width: 100%;
|
||||
max-height: min(92dvh, 760px);
|
||||
overflow: hidden auto;
|
||||
padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
|
||||
border: 1px solid var(--color-border);
|
||||
border-bottom: 0;
|
||||
border-radius: 28px 28px 0 0;
|
||||
background: #1a1815;
|
||||
transform: translateY(var(--drag-y, 0px));
|
||||
transition: transform 0.22s ease-out;
|
||||
touch-action: pan-y;
|
||||
}
|
||||
|
||||
.sheet--dragging {
|
||||
overflow: hidden;
|
||||
transition: none;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.sheet__handle {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 28px;
|
||||
margin: 0 auto 4px;
|
||||
padding: 10px 0 12px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
cursor: grab;
|
||||
touch-action: none;
|
||||
}
|
||||
|
||||
.sheet__handle::before {
|
||||
content: '';
|
||||
display: block;
|
||||
width: 42px;
|
||||
height: 4px;
|
||||
margin: 0 auto;
|
||||
border-radius: 4px;
|
||||
background: #4a453c;
|
||||
}
|
||||
|
||||
.sheet__mark {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
margin: 8px auto 16px;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.sheet h2 {
|
||||
margin: 0;
|
||||
font-family: var(--font-display);
|
||||
font-size: clamp(26px, 7vw, 32px);
|
||||
font-weight: 700;
|
||||
line-height: 1.15;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.docs {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
margin: 20px 0 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.docs a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
min-height: 56px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 16px;
|
||||
background: #12110f;
|
||||
color: var(--color-text);
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@keyframes sheet-in {
|
||||
from {
|
||||
transform: translateY(24px);
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.sheet-pop {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
.sheet {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
DestroyRef,
|
||||
HostListener,
|
||||
inject,
|
||||
output,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
|
||||
import { Icon } from '../icon/icon';
|
||||
import { legalDocuments } from '../legal-documents';
|
||||
|
||||
const DISMISS_DISTANCE = 120;
|
||||
const DISMISS_VELOCITY = 0.55;
|
||||
|
||||
@Component({
|
||||
selector: 'app-documents-sheet',
|
||||
imports: [Icon],
|
||||
templateUrl: './documents-sheet.html',
|
||||
styleUrl: './documents-sheet.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class DocumentsSheet {
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private pointerId: number | null = null;
|
||||
private dragOriginY = 0;
|
||||
private dragOriginX = 0;
|
||||
private dragScrollTop = 0;
|
||||
private dragFromHandle = false;
|
||||
private dragTracking = false;
|
||||
private dragMoved = false;
|
||||
private dragLastY = 0;
|
||||
private dragLastTime = 0;
|
||||
private dragVelocity = 0;
|
||||
private closeTimer = 0;
|
||||
|
||||
protected readonly documents = legalDocuments;
|
||||
protected readonly dragY = signal(0);
|
||||
protected readonly dragging = signal(false);
|
||||
|
||||
readonly dismissed = output<void>();
|
||||
|
||||
constructor() {
|
||||
this.destroyRef.onDestroy(() => window.clearTimeout(this.closeTimer));
|
||||
}
|
||||
|
||||
protected dismiss(): void {
|
||||
window.clearTimeout(this.closeTimer);
|
||||
this.closeTimer = 0;
|
||||
this.dragY.set(0);
|
||||
this.dragging.set(false);
|
||||
this.dismissed.emit();
|
||||
}
|
||||
|
||||
protected onDragStart(event: PointerEvent): void {
|
||||
if (!event.isPrimary || event.button !== 0 || !this.canDragFrom(event.target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sheet = event.currentTarget as HTMLElement;
|
||||
this.pointerId = event.pointerId;
|
||||
this.dragOriginY = event.clientY;
|
||||
this.dragOriginX = event.clientX;
|
||||
this.dragScrollTop = sheet.scrollTop;
|
||||
this.dragFromHandle = this.isHandle(event.target);
|
||||
this.dragTracking = false;
|
||||
this.dragMoved = false;
|
||||
this.dragLastY = event.clientY;
|
||||
this.dragLastTime = event.timeStamp;
|
||||
this.dragVelocity = 0;
|
||||
}
|
||||
|
||||
protected onDragMove(event: PointerEvent): void {
|
||||
if (event.pointerId !== this.pointerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const dy = event.clientY - this.dragOriginY;
|
||||
const dx = event.clientX - this.dragOriginX;
|
||||
const sheet = event.currentTarget as HTMLElement;
|
||||
|
||||
if (!this.dragTracking) {
|
||||
if (Math.abs(dy) < 8 && Math.abs(dx) < 8) {
|
||||
return;
|
||||
}
|
||||
|
||||
const pullingDown = dy > 0 && Math.abs(dy) > Math.abs(dx);
|
||||
const atTop = this.dragScrollTop <= 0;
|
||||
|
||||
if (!pullingDown || (!atTop && !this.dragFromHandle)) {
|
||||
this.pointerId = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.dragTracking = true;
|
||||
this.dragMoved = true;
|
||||
this.dragging.set(true);
|
||||
sheet.setPointerCapture(event.pointerId);
|
||||
}
|
||||
|
||||
const elapsed = event.timeStamp - this.dragLastTime;
|
||||
|
||||
if (elapsed > 0) {
|
||||
this.dragVelocity = (event.clientY - this.dragLastY) / elapsed;
|
||||
}
|
||||
|
||||
this.dragLastY = event.clientY;
|
||||
this.dragLastTime = event.timeStamp;
|
||||
this.dragY.set(Math.max(0, dy));
|
||||
}
|
||||
|
||||
protected onDragEnd(event: PointerEvent): void {
|
||||
if (event.pointerId !== this.pointerId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sheet = event.currentTarget as HTMLElement;
|
||||
const offset = this.dragY();
|
||||
const close =
|
||||
event.type !== 'pointercancel' &&
|
||||
this.dragTracking &&
|
||||
(offset > DISMISS_DISTANCE || (offset > 48 && this.dragVelocity > DISMISS_VELOCITY));
|
||||
|
||||
this.pointerId = null;
|
||||
this.dragTracking = false;
|
||||
this.dragging.set(false);
|
||||
|
||||
if (this.dragMoved) {
|
||||
const stopClick = (clickEvent: Event): void => {
|
||||
clickEvent.preventDefault();
|
||||
clickEvent.stopPropagation();
|
||||
};
|
||||
sheet.addEventListener('click', stopClick, { capture: true, once: true });
|
||||
this.dragMoved = false;
|
||||
}
|
||||
|
||||
if (!close) {
|
||||
this.dragY.set(0);
|
||||
return;
|
||||
}
|
||||
|
||||
this.dragY.set(sheet.getBoundingClientRect().height);
|
||||
window.clearTimeout(this.closeTimer);
|
||||
this.closeTimer = window.setTimeout(() => this.dismiss(), 200);
|
||||
}
|
||||
|
||||
@HostListener('document:keydown.escape')
|
||||
protected onEscape(): void {
|
||||
this.dismiss();
|
||||
}
|
||||
|
||||
private canDragFrom(target: EventTarget | null): boolean {
|
||||
if (!(target instanceof Element)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.isHandle(target)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return target.closest('a, button') == null;
|
||||
}
|
||||
|
||||
private isHandle(target: EventTarget | null): boolean {
|
||||
return target instanceof Element && target.closest('.sheet__handle') != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export const termsDocumentUrl = '/assets/documents/terms-of-use.pdf';
|
||||
export const privacyDocumentUrl = '/assets/documents/privacy-policy.pdf';
|
||||
|
||||
export const legalDocuments = [
|
||||
{ title: 'Пользовательское соглашение', href: termsDocumentUrl },
|
||||
{ title: 'Политика обработки персональных данных', href: privacyDocumentUrl },
|
||||
] as const;
|
||||
@@ -42,7 +42,6 @@ export interface AuthState {
|
||||
}
|
||||
|
||||
export interface GorodarState {
|
||||
collectedIds: string[];
|
||||
photos: Record<string, string>;
|
||||
collectedAt: Record<string, string>;
|
||||
claim: ClaimState;
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createFeature, createReducer, on } from '@ngrx/store';
|
||||
|
||||
import {
|
||||
areaAttractions,
|
||||
type Area,
|
||||
type AreaDetails,
|
||||
type AreaProgress,
|
||||
type Attraction,
|
||||
@@ -42,7 +43,6 @@ const restoredAuth: AuthState = {
|
||||
};
|
||||
|
||||
export const initialState: GorodarState = {
|
||||
collectedIds: [],
|
||||
photos: {},
|
||||
collectedAt: {},
|
||||
claim: initialClaim,
|
||||
@@ -87,9 +87,7 @@ const gorodarReducer = createReducer(
|
||||
GorodarActions.claimCompleted,
|
||||
(state, { landmarkId, photo, collectedAt, alreadyVisited, progress }): GorodarState => ({
|
||||
...state,
|
||||
collectedIds: state.collectedIds.includes(landmarkId)
|
||||
? state.collectedIds
|
||||
: [...state.collectedIds, landmarkId],
|
||||
areas: markListVisited(state.areas, landmarkId, progress),
|
||||
photos: {
|
||||
...state.photos,
|
||||
[landmarkId]: photo,
|
||||
@@ -268,7 +266,6 @@ const gorodarReducer = createReducer(
|
||||
GorodarActions.logout,
|
||||
(state): GorodarState => ({
|
||||
...state,
|
||||
collectedIds: [],
|
||||
photos: {},
|
||||
collectedAt: {},
|
||||
claim: initialClaim,
|
||||
@@ -408,6 +405,22 @@ function markVisited(item: Attraction, id: string): Attraction {
|
||||
return item.id === id ? { ...item, visited: true } : item;
|
||||
}
|
||||
|
||||
function markListVisited(areas: Area[], landmarkId: string, progress: AreaProgress): Area[] {
|
||||
return areas.map((area) => {
|
||||
const attractions = area.attractions ?? [];
|
||||
|
||||
if (!attractions.some((item) => item.id === landmarkId)) {
|
||||
return area;
|
||||
}
|
||||
|
||||
return {
|
||||
...area,
|
||||
progress: progress ?? area.progress,
|
||||
attractions: attractions.map((item) => markVisited(item, landmarkId)),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function markAreaVisited(
|
||||
details: Record<string, AreaDetails>,
|
||||
landmarkId: string,
|
||||
|
||||
@@ -4,7 +4,6 @@ import { areaOpenedCount, areaTotalCount, type Area, type AreaDetails } from '..
|
||||
import { gorodarFeature } from './gorodar.reducer';
|
||||
|
||||
export const {
|
||||
selectCollectedIds,
|
||||
selectPhotos,
|
||||
selectCollectedAt,
|
||||
selectClaim,
|
||||
@@ -21,14 +20,8 @@ export const {
|
||||
selectAttractionError,
|
||||
} = gorodarFeature;
|
||||
|
||||
export const selectCollectedIdSet = createSelector(selectCollectedIds, (ids) => new Set(ids));
|
||||
|
||||
export const selectOpenedCount = createSelector(
|
||||
selectAreas,
|
||||
selectAreaDetails,
|
||||
selectCollectedIdSet,
|
||||
(areas, details, ids) =>
|
||||
areas.reduce((sum, area) => sum + areaOpenedCount(resolveArea(area, details), ids), 0),
|
||||
export const selectOpenedCount = createSelector(selectAreas, selectAreaDetails, (areas, details) =>
|
||||
areas.reduce((sum, area) => sum + areaOpenedCount(resolveArea(area, details)), 0),
|
||||
);
|
||||
|
||||
export const selectTotalCount = createSelector(selectAreas, selectAreaDetails, (areas, details) =>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
.city-map__label {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: calc(50% + (var(--radius-px, 80px) / 2) + 6px);
|
||||
bottom: calc(20% + (var(--radius-px, 80px) / 2) + 6px);
|
||||
display: none;
|
||||
padding: 0 4px;
|
||||
color: var(--color-text);
|
||||
|
||||
@@ -26,75 +26,3 @@
|
||||
height: 120px;
|
||||
background: linear-gradient(to bottom, transparent, var(--color-bg));
|
||||
}
|
||||
|
||||
.owned-photo {
|
||||
position: relative;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 220px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
border: 1px solid var(--color-accent-strong);
|
||||
border-radius: 16px;
|
||||
background: var(--color-surface);
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.owned-photo img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.owned-photo__badge {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
bottom: 12px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 5px 11px;
|
||||
overflow: visible;
|
||||
border-radius: 10px;
|
||||
background: rgb(18 17 15 / 82%);
|
||||
color: var(--color-accent-soft);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.photo-viewer {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 40;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 56px 16px 24px;
|
||||
background: rgb(18 17 15 / 94%);
|
||||
}
|
||||
|
||||
.photo-viewer img {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
object-fit: contain;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.photo-viewer__close {
|
||||
position: absolute;
|
||||
top: 16px;
|
||||
left: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 14px;
|
||||
background: rgb(28 26 23 / 86%);
|
||||
color: var(--color-text);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user