Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a738fbc729 | ||
|
|
33cc27797e | ||
|
|
0119ac291f | ||
|
|
c62136481b | ||
|
|
26b8459121 | ||
|
|
dbf6e05f29 | ||
|
|
053d83245f | ||
|
|
5e266c0ebd | ||
|
|
41c5f81027 | ||
|
|
a65d4185f3 | ||
|
|
548ba43dc2 | ||
|
|
2b4967dd8c | ||
|
|
f86777e2cd |
@@ -6,7 +6,7 @@ COPY package.json package-lock.json ./
|
|||||||
RUN npm i
|
RUN npm i
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN npm run build -- --configuration=test
|
RUN npm run build
|
||||||
|
|
||||||
FROM nginx:1.27-alpine
|
FROM nginx:1.27-alpine
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,23 @@
|
|||||||
{
|
{
|
||||||
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
||||||
"index": "/index.html",
|
"index": "/index.html",
|
||||||
|
|
||||||
|
"navigationUrls": [
|
||||||
|
"/**",
|
||||||
|
"!/**/*.*",
|
||||||
|
"!/**/*__*",
|
||||||
|
"!/**/*__*/**",
|
||||||
|
"!/admin",
|
||||||
|
"!/admin/**"
|
||||||
|
],
|
||||||
|
|
||||||
"assetGroups": [
|
"assetGroups": [
|
||||||
{
|
{
|
||||||
"name": "app",
|
"name": "app",
|
||||||
"installMode": "prefetch",
|
"installMode": "prefetch",
|
||||||
"resources": {
|
"resources": {
|
||||||
"files": [
|
"files": [
|
||||||
|
"/apple-touch-icon.png",
|
||||||
"/favicon.ico",
|
"/favicon.ico",
|
||||||
"/favicon.svg",
|
"/favicon.svg",
|
||||||
"/index.csr.html",
|
"/index.csr.html",
|
||||||
@@ -22,19 +33,15 @@
|
|||||||
"installMode": "lazy",
|
"installMode": "lazy",
|
||||||
"updateMode": "prefetch",
|
"updateMode": "prefetch",
|
||||||
"resources": {
|
"resources": {
|
||||||
"files": [
|
"files": ["/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"]
|
||||||
"/**/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
"dataGroups": [
|
"dataGroups": [
|
||||||
{
|
{
|
||||||
"name": "fonts",
|
"name": "fonts",
|
||||||
"urls": [
|
"urls": ["https://fonts.googleapis.com/**", "https://fonts.gstatic.com/**"],
|
||||||
"https://fonts.googleapis.com/**",
|
|
||||||
"https://fonts.gstatic.com/**"
|
|
||||||
],
|
|
||||||
"cacheConfig": {
|
"cacheConfig": {
|
||||||
"maxSize": 20,
|
"maxSize": 20,
|
||||||
"maxAge": "30d",
|
"maxAge": "30d",
|
||||||
|
|||||||
@@ -3,5 +3,10 @@
|
|||||||
"target": "https://gorodar.ru",
|
"target": "https://gorodar.ru",
|
||||||
"secure": true,
|
"secure": true,
|
||||||
"changeOrigin": true
|
"changeOrigin": true
|
||||||
|
},
|
||||||
|
"/api": {
|
||||||
|
"target": "https://gorodar.ru",
|
||||||
|
"secure": true,
|
||||||
|
"changeOrigin": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 1.6 MiB |
|
Before Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 1.5 MiB |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 172 KiB |
@@ -0,0 +1,15 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" fill="none">
|
||||||
|
<rect x="7" y="7" width="86" height="86" fill="rgba(255,255,255,0.02)" stroke="#4B453B" stroke-width="1.6" stroke-dasharray="3 3"/>
|
||||||
|
<g transform="translate(34.4 34.4) scale(1.3)" stroke="#8A8172" stroke-width="1.6" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M6 11 H18 V20 H6 Z"/>
|
||||||
|
<path d="M8.5 11 V8 A3.5 3.5 0 0 1 15.5 8 V11"/>
|
||||||
|
</g>
|
||||||
|
<rect x="3.5" y="3.5" width="7" height="7" fill="#14120F" stroke="#4B453B" stroke-width="1"/>
|
||||||
|
<rect x="89.5" y="3.5" width="7" height="7" fill="#14120F" stroke="#4B453B" stroke-width="1"/>
|
||||||
|
<rect x="3.5" y="89.5" width="7" height="7" fill="#14120F" stroke="#4B453B" stroke-width="1"/>
|
||||||
|
<rect x="89.5" y="89.5" width="7" height="7" fill="#14120F" stroke="#4B453B" stroke-width="1"/>
|
||||||
|
<path d="M50 3.5 L53.5 7 L50 10.5 L46.5 7 Z" fill="#14120F" stroke="#4B453B" stroke-width="1"/>
|
||||||
|
<path d="M50 89.5 L53.5 93 L50 96.5 L46.5 93 Z" fill="#14120F" stroke="#4B453B" stroke-width="1"/>
|
||||||
|
<path d="M3.5 50 L7 46.5 L10.5 50 L7 53.5 Z" fill="#14120F" stroke="#4B453B" stroke-width="1"/>
|
||||||
|
<path d="M89.5 50 L93 46.5 L96.5 50 L93 53.5 Z" fill="#14120F" stroke="#4B453B" stroke-width="1"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 112 112" fill="none">
|
||||||
|
<circle cx="56" cy="56" r="52" fill="#F0876A"/>
|
||||||
|
<path d="M40 40 L72 72 M72 40 L40 72" stroke="#1A1508" stroke-width="7" stroke-linecap="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 231 B |
@@ -0,0 +1,6 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-2 -2 28 28" fill="none">
|
||||||
|
<path d="M7 4.5 H14 L18.5 9 V19.5 a1.5 1.5 0 0 1 -1.5 1.5 H7 a1.5 1.5 0 0 1 -1.5 -1.5 V6 a1.5 1.5 0 0 1 1.5 -1.5 Z" stroke="#fff" stroke-width="1.8" stroke-linejoin="round"/>
|
||||||
|
<path d="M14 4.5 V9 H18.5" stroke="#fff" stroke-width="1.8" stroke-linejoin="round"/>
|
||||||
|
<path d="M8.5 13 H15.5" stroke="#fff" stroke-width="1.8" stroke-linecap="round"/>
|
||||||
|
<path d="M8.5 16.5 H13" stroke="#fff" stroke-width="1.8" stroke-linecap="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 515 B |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="390" height="320" viewBox="0 0 390 320"><defs><linearGradient id="nn1" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#161B38"></stop><stop offset="0.55" stop-color="#4A3A63"></stop><stop offset="1" stop-color="#C9764C"></stop></linearGradient></defs><rect width="390" height="320" fill="url(#nn1)"></rect><circle cx="46.8" cy="20.5" r="1.1" fill="#FFFFFF" opacity="0.65"></circle><circle cx="117.0" cy="35.8" r="1.1" fill="#FFFFFF" opacity="0.65"></circle><circle cx="280.8" cy="17.9" r="1.1" fill="#FFFFFF" opacity="0.65"></circle><circle cx="335.4" cy="43.5" r="1.1" fill="#FFFFFF" opacity="0.65"></circle><circle cx="78.0" cy="66.6" r="1.1" fill="#FFFFFF" opacity="0.65"></circle><circle cx="358.8" cy="76.8" r="1.1" fill="#FFFFFF" opacity="0.65"></circle><circle cx="31.2" cy="92.2" r="1.1" fill="#FFFFFF" opacity="0.65"></circle><circle cx="304.2" cy="102.4" r="1.1" fill="#FFFFFF" opacity="0.65"></circle><rect x="113.8" y="203.4" width="162.4" height="98.6" fill="#0C0B0A"></rect><rect x="73.2" y="244.0" width="40.6" height="58.0" fill="#0C0B0A"></rect><rect x="276.2" y="244.0" width="40.6" height="58.0" fill="#0C0B0A"></rect><rect x="166.0" y="168.6" width="58.0" height="34.8" fill="#0C0B0A"></rect><path d="M160.2 168.6 C144.9 143.0 183.9 126.4 195.0 93.2 C206.1 126.4 245.1 143.0 229.8 168.6 Z" fill="#0C0B0A"></path><path d="M195.0 64.2 V93.2 M186.3 73.8 H203.7" stroke="#0C0B0A" stroke-width="2.9" fill="none"></path><path d="M76.1 244.0 C68.4 231.2 87.9 222.9 93.5 206.3 C99.1 222.9 118.6 231.2 110.9 244.0 Z" fill="#0C0B0A"></path><path d="M93.5 186.0 V206.3 M87.4 192.7 H99.6" stroke="#0C0B0A" stroke-width="2.0" fill="none"></path><path d="M279.1 244.0 C271.4 231.2 290.9 222.9 296.5 206.3 C302.1 222.9 321.6 231.2 313.9 244.0 Z" fill="#0C0B0A"></path><path d="M296.5 186.0 V206.3 M290.4 192.7 H302.6" stroke="#0C0B0A" stroke-width="2.0" fill="none"></path><ellipse cx="0.0" cy="318.0" rx="29.3" ry="14.4" fill="#0C0B0A"></ellipse><ellipse cx="48.8" cy="318.0" rx="29.3" ry="20.5" fill="#0C0B0A"></ellipse><ellipse cx="97.5" cy="318.0" rx="29.3" ry="26.4" fill="#0C0B0A"></ellipse><ellipse cx="146.2" cy="318.0" rx="29.3" ry="14.4" fill="#0C0B0A"></ellipse><ellipse cx="195.0" cy="318.0" rx="29.3" ry="20.5" fill="#0C0B0A"></ellipse><ellipse cx="243.8" cy="318.0" rx="29.3" ry="26.4" fill="#0C0B0A"></ellipse><ellipse cx="292.5" cy="318.0" rx="29.3" ry="14.4" fill="#0C0B0A"></ellipse><ellipse cx="341.2" cy="318.0" rx="29.3" ry="20.5" fill="#0C0B0A"></ellipse><ellipse cx="390.0" cy="318.0" rx="29.3" ry="26.4" fill="#0C0B0A"></ellipse><rect x="0" y="310.0" width="390" height="10" fill="#0C0B0A"></rect></svg>
|
|
||||||
|
Before Width: | Height: | Size: 2.6 KiB |
|
After Width: | Height: | Size: 9.0 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 65 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 7.4 KiB |
@@ -1,25 +1,133 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<rect width="100" height="100" rx="18" fill="#12110F"/>
|
<svg
|
||||||
<rect x="7" y="7" width="86" height="86" fill="rgba(224,184,79,0.07)" stroke="#E0B84F" stroke-width="2.2"/>
|
viewBox="0 0 1920 1920"
|
||||||
<rect x="11.5" y="11.5" width="77" height="77" stroke="#E0B84F" stroke-width="0.6" opacity="0.6"/>
|
version="1.1"
|
||||||
<g transform="translate(18 18)" stroke="#F2D98E" stroke-width="1.7" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
id="svg10"
|
||||||
<path d="M8 56 H56"/>
|
sodipodi:docname="logo_color_transparent — копия.svg"
|
||||||
<path d="M26 56 V34 M38 56 V34"/>
|
inkscape:version="1.3.2 (091e20e, 2023-11-25)"
|
||||||
<path d="M25 34 L32 12 L39 34 Z"/>
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
<path d="M32 12 V5 M30 8 H34"/>
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
<path d="M10 56 V42 M18 56 V42"/>
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
<path d="M10 42 C8 34 14 32 14 26 C14 32 20 34 18 42 Z"/>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<path d="M14 26 V22"/>
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
<path d="M46 56 V42 M54 56 V42"/>
|
<sodipodi:namedview
|
||||||
<path d="M46 42 C44 34 50 32 50 26 C50 32 56 34 54 42 Z"/>
|
id="namedview10"
|
||||||
<path d="M50 26 V22"/>
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#000000"
|
||||||
|
borderopacity="0.25"
|
||||||
|
inkscape:showpageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
inkscape:deskcolor="#d1d1d1"
|
||||||
|
inkscape:zoom="0.12291667"
|
||||||
|
inkscape:cx="951.86441"
|
||||||
|
inkscape:cy="825.76271"
|
||||||
|
inkscape:window-width="1616"
|
||||||
|
inkscape:window-height="932"
|
||||||
|
inkscape:window-x="0"
|
||||||
|
inkscape:window-y="33"
|
||||||
|
inkscape:window-maximized="0"
|
||||||
|
inkscape:current-layer="g9" />
|
||||||
|
<defs
|
||||||
|
id="defs1">
|
||||||
|
<clipPath
|
||||||
|
id="logo">
|
||||||
|
<rect
|
||||||
|
x="0"
|
||||||
|
y="0"
|
||||||
|
width="1920"
|
||||||
|
height="1920"
|
||||||
|
id="rect1" />
|
||||||
|
</clipPath>
|
||||||
|
<linearGradient
|
||||||
|
inkscape:collect="always"
|
||||||
|
xlink:href="#color-1"
|
||||||
|
id="linearGradient10"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
x1="200"
|
||||||
|
y1="296.11"
|
||||||
|
x2="200"
|
||||||
|
y2="30"
|
||||||
|
gradientTransform="translate(0.00312153,36.940864)" />
|
||||||
|
</defs>
|
||||||
|
<g
|
||||||
|
clip-path="url(#logo)"
|
||||||
|
id="g10">
|
||||||
|
<rect
|
||||||
|
fill="none"
|
||||||
|
width="1920"
|
||||||
|
height="1920"
|
||||||
|
id="rect2" />
|
||||||
|
<g
|
||||||
|
transform="scale(4.8)"
|
||||||
|
id="g9">
|
||||||
|
<defs
|
||||||
|
id="defs3">
|
||||||
|
<linearGradient
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
id="color-1"
|
||||||
|
x1="200"
|
||||||
|
x2="200"
|
||||||
|
y1="296.11"
|
||||||
|
y2="30">
|
||||||
|
<stop
|
||||||
|
offset="0"
|
||||||
|
stop-color="#852614"
|
||||||
|
id="stop2" />
|
||||||
|
<stop
|
||||||
|
offset="1"
|
||||||
|
stop-color="#c3b218"
|
||||||
|
id="stop3" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<g
|
||||||
|
fill="none"
|
||||||
|
font-family="none"
|
||||||
|
font-size="none"
|
||||||
|
font-weight="none"
|
||||||
|
stroke-miterlimit="10"
|
||||||
|
style="mix-blend-mode:normal"
|
||||||
|
text-anchor="none"
|
||||||
|
id="g8">
|
||||||
|
<rect
|
||||||
|
fill="none"
|
||||||
|
height="400"
|
||||||
|
width="400"
|
||||||
|
id="rect3" />
|
||||||
|
<rect
|
||||||
|
fill="none"
|
||||||
|
height="400"
|
||||||
|
width="400"
|
||||||
|
id="rect4" />
|
||||||
|
<rect
|
||||||
|
fill="none"
|
||||||
|
height="400"
|
||||||
|
width="400"
|
||||||
|
id="rect5" />
|
||||||
|
<rect
|
||||||
|
fill="none"
|
||||||
|
height="400"
|
||||||
|
width="400"
|
||||||
|
id="rect6" />
|
||||||
|
<rect
|
||||||
|
fill="none"
|
||||||
|
height="400"
|
||||||
|
width="400"
|
||||||
|
id="rect7" />
|
||||||
|
<rect
|
||||||
|
fill="none"
|
||||||
|
height="400"
|
||||||
|
width="400"
|
||||||
|
id="rect8" />
|
||||||
|
<g
|
||||||
|
fill="url(#color-1)"
|
||||||
|
id="symbol">
|
||||||
|
<path
|
||||||
|
d="m 126.18312,95.762864 c 3.034,-2.9021 6.134,-5.7383 9.278,-8.4865 8.0908,11.323 15.104,23.349006 22.689,35.001006 13.565,21.128 28.384,41.531 39.816,63.935 0.79147,3.1 4.1553,-0.17589 4.7489,-1.7149 9.7617,-16.511 20.513,-32.407 30.802,-48.589 10.509,-15.764 19.128,-32.759 30.45,-47.995006 3.4737,2.7043 6.9035,5.5184 10.333,8.3326 -24.052,31.879006 -45.752,65.518006 -65.43,100.260006 21.238,0.022 42.477,0.24186 63.737,0.21985 13.609,-0.50567 26.603,5.4305 37.178,13.609 12.686,10.026 16.335,30.362 6.3759,43.466 -8.0248,10.993 -23.481,15.456 -36.145,10.399 -13.961,-4.1993 -24.052,-19.633 -20.381,-34.1 1.8688,-10.135 10.751,-16.291 17.633,-23.063 -22.865,-0.17589 -45.73,-0.24186 -68.596,-0.7695 19.194,32.561 40.52,63.825 63.715,93.66 -2.9021,2.3085 -5.7823,4.639 -8.6404,6.9915 -24.954,-28.977 -42.806,-63.055 -63.737,-94.825 -7.9369,12.114 -14.379,25.152 -22.601,37.112 -13.345,19.809 -25.108,40.938 -41.465,58.504 -2.9461,-2.8801 -5.7383,-5.8482 -8.3766,-8.9702 12.026,-13.279 22.14,-28.142 32.231,-42.916 10.289,-15.984 21.15,-31.616 30.099,-48.391 -21.7,-0.79147 -43.466,-0.96737 -65.144,0.19785 5.7383,7.6511 14.181,14.577 15.104,24.756 0.85744,14.533 -8.8603,29.901 -23.503,33.243 -11.828,2.2865 -25.722998,-1.2752 -33.000998,-11.411 -9.6958,-13.983 -5.7603,-35.111 7.9369,-45.027 11.190998,-7.783 24.469998,-13.477 38.364998,-12.994 20.557,0.15389 41.135,0.13192 61.714,0.6156 -5.6723,-12.136 -12.488,-23.701 -20.073,-34.716 -15.038,-22.118 -29.461,-44.653 -45.115,-66.331006 z m -19.765,119.870006 c -13.564998,2.6383 -22.886998,21.612 -12.399998,32.429 8.596398,10.663 28.822998,8.1567 32.472998,-5.7383 5.1667,-12.488 -6.0241,-29.725 -20.073,-26.691 z m 178.2,0.21986 c -11.894,4.5071 -19.04,21.37 -9.8496,31.66 7.739,10.179 24.734,9.5418 31.791,-1.0773 9.8277,-13.741 -5.6284,-35.969 -21.942,-30.582 z m -187.079998,-86.096 c 18.841998,-7.9588 41.574998,7.805 42.542998,27.724 1.627,17.721 -14.467,34.979 -32.385,33.748 -16.862998,-0.9234 -30.537998,-17.149 -29.570998,-33.814 -0.37376,-12.158 8.1128,-23.613 19.413,-27.658 z m 6.661698,11.103 c -15.785998,2.3305 -19.368998,24.8 -7.145398,33.66 9.849598,8.3766 25.832998,2.4624 29.614998,-9.3879 6.112,-13.301 -9.0142,-28.362 -22.47,-24.272 z m 89.922,-72.861006 c 18.6,-5.4965 37.552,11.389 37.596,29.989 2.0667,19.172006 -17.083,37.310006 -36.101,33.616006 -15.676,-2.3305 -29.527,-17.237 -28.12,-33.506006 0.52766,-14.599 12.554,-27.24 26.625,-30.099 z m -1.9348,15.522 c -6.134,3.122 -12.048,9.1461 -11.477,16.555006 0.63758,9.8057 8.9482,19.721 19.304,19.523 14.225,0.28582 23.591,-18.908 15.126,-30.143006 -4.7929,-7.4312 -15.17,-10.399 -22.953,-5.9362 z m 87.789,46.104006 c 20.403,-8.6404 44.433,10.663 41.839,32.231 -0.17589,18.842 -20.381,32.671 -38.145,28.713 -16.489,-4.0894 -27.944,-22.491 -23.745,-39.069 2.2425,-10.179 10.311,-18.468 20.051,-21.876 z m 6.5078,10.839 c -5.7603,1.3851 -11.081,5.0567 -13.917,10.311 -4.4411,8.8163 -0.37376,20.161 8.1567,24.866 8.9262,5.8922 22.162,2.1986 26.713,-7.4972 6.9915,-13.126 -5.6943,-32.385 -20.952,-27.68 z m -94.451,130.2 c 15.874,-4.2213 33.484,5.8922 38.079,21.59 7.1674,20.469 -13.148,43.136 -34.056,40.608 -16.16,-2.5723 -29.923,-17.918 -28.538,-34.65 -0.32978,-13.829 11.828,-24.646 24.514,-27.548 z m 2.1106,12.642 c -12.84,3.078 -17.852,20.007 -9.0142,29.725 7.9809,11.367 26.603,6.9915 31.396,-5.1447 6.5957,-13.17 -8.4206,-30.318 -22.382,-24.58 z"
|
||||||
|
id="path8"
|
||||||
|
style="fill:url(#linearGradient10)" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
</g>
|
</g>
|
||||||
<rect x="3.5" y="3.5" width="7" height="7" fill="#14120F" stroke="#E0B84F" stroke-width="1"/>
|
|
||||||
<rect x="89.5" y="3.5" width="7" height="7" fill="#14120F" stroke="#E0B84F" stroke-width="1"/>
|
|
||||||
<rect x="3.5" y="89.5" width="7" height="7" fill="#14120F" stroke="#E0B84F" stroke-width="1"/>
|
|
||||||
<rect x="89.5" y="89.5" width="7" height="7" fill="#14120F" stroke="#E0B84F" stroke-width="1"/>
|
|
||||||
<path d="M50 3.5 L53.5 7 L50 10.5 L46.5 7 Z" fill="#14120F" stroke="#E0B84F" stroke-width="1"/>
|
|
||||||
<path d="M50 89.5 L53.5 93 L50 96.5 L46.5 93 Z" fill="#14120F" stroke="#E0B84F" stroke-width="1"/>
|
|
||||||
<path d="M3.5 50 L7 46.5 L10.5 50 L7 53.5 Z" fill="#14120F" stroke="#E0B84F" stroke-width="1"/>
|
|
||||||
<path d="M89.5 50 L93 46.5 L96.5 50 L93 53.5 Z" fill="#14120F" stroke="#E0B84F" stroke-width="1"/>
|
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 1007 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Городар",
|
"name": "Городар",
|
||||||
"short_name": "Городар",
|
"short_name": "Городар",
|
||||||
"description": "Коллекция городских объектов. Приезжайте на место, снимайте — объект попадёт в вашу коллекцию.",
|
"description": "Открывайте города с Городаром: находите достопримечательности на карте, посещайте их и фотографируйте, чтобы пополнять личную коллекцию.",
|
||||||
"lang": "ru",
|
"lang": "ru",
|
||||||
"dir": "ltr",
|
"dir": "ltr",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
@@ -12,61 +12,73 @@
|
|||||||
"theme_color": "#12110F",
|
"theme_color": "#12110F",
|
||||||
"icons": [
|
"icons": [
|
||||||
{
|
{
|
||||||
"src": "icons/icon-72x72.png",
|
"src": "assets/logo/32.png",
|
||||||
|
"sizes": "32x32",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "assets/logo/64.png",
|
||||||
|
"sizes": "64x64",
|
||||||
|
"type": "image/png",
|
||||||
|
"purpose": "any"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"src": "assets/logo/72.png",
|
||||||
"sizes": "72x72",
|
"sizes": "72x72",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "any"
|
"purpose": "any"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "icons/icon-96x96.png",
|
"src": "assets/logo/96.png",
|
||||||
"sizes": "96x96",
|
"sizes": "96x96",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "any"
|
"purpose": "any"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "icons/icon-128x128.png",
|
"src": "assets/logo/128.png",
|
||||||
"sizes": "128x128",
|
"sizes": "128x128",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "any"
|
"purpose": "any"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "icons/icon-144x144.png",
|
"src": "assets/logo/144.png",
|
||||||
"sizes": "144x144",
|
"sizes": "144x144",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "any"
|
"purpose": "any"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "icons/icon-152x152.png",
|
"src": "assets/logo/152.png",
|
||||||
"sizes": "152x152",
|
"sizes": "152x152",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "any"
|
"purpose": "any"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "icons/icon-192x192.png",
|
"src": "assets/logo/196.png",
|
||||||
"sizes": "192x192",
|
"sizes": "196x196",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "any"
|
"purpose": "any"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "icons/icon-384x384.png",
|
"src": "assets/logo/384.png",
|
||||||
"sizes": "384x384",
|
"sizes": "384x384",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "any"
|
"purpose": "any"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "icons/icon-512x512.png",
|
"src": "assets/logo/512.png",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "any"
|
"purpose": "any"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "icons/icon-192x192.png",
|
"src": "assets/logo/196.png",
|
||||||
"sizes": "192x192",
|
"sizes": "196x196",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "maskable"
|
"purpose": "maskable"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"src": "icons/icon-512x512.png",
|
"src": "assets/logo/512.png",
|
||||||
"sizes": "512x512",
|
"sizes": "512x512",
|
||||||
"type": "image/png",
|
"type": "image/png",
|
||||||
"purpose": "maskable"
|
"purpose": "maskable"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ApplicationConfig, isDevMode, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
|
import { ApplicationConfig, isDevMode, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
|
||||||
import { provideHttpClient } from '@angular/common/http';
|
import { provideHttpClient, withInterceptors } from '@angular/common/http';
|
||||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||||
import { provideRouter, withComponentInputBinding } from '@angular/router';
|
import { provideRouter, withComponentInputBinding } from '@angular/router';
|
||||||
import { provideServiceWorker } from '@angular/service-worker';
|
import { provideServiceWorker } from '@angular/service-worker';
|
||||||
@@ -7,19 +7,20 @@ import { provideEffects } from '@ngrx/effects';
|
|||||||
import { provideState, provideStore } from '@ngrx/store';
|
import { provideState, provideStore } from '@ngrx/store';
|
||||||
import { provideStoreDevtools } from '@ngrx/store-devtools';
|
import { provideStoreDevtools } from '@ngrx/store-devtools';
|
||||||
|
|
||||||
|
import { authInterceptor } from './auth/auth.interceptor';
|
||||||
import { routes } from './app.routes';
|
import { routes } from './app.routes';
|
||||||
import { AuthEffects, GorodarEffects, gorodarFeature } from './state';
|
import { AreasEffects, AuthEffects, GorodarEffects, gorodarFeature } from './state';
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [
|
providers: [
|
||||||
provideBrowserGlobalErrorListeners(),
|
provideBrowserGlobalErrorListeners(),
|
||||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
provideZoneChangeDetection({ eventCoalescing: true }),
|
||||||
provideHttpClient(),
|
provideHttpClient(withInterceptors([authInterceptor])),
|
||||||
provideRouter(routes, withComponentInputBinding()),
|
provideRouter(routes, withComponentInputBinding()),
|
||||||
provideAnimationsAsync(),
|
provideAnimationsAsync(),
|
||||||
provideStore(),
|
provideStore(),
|
||||||
provideState(gorodarFeature),
|
provideState(gorodarFeature),
|
||||||
provideEffects(GorodarEffects, AuthEffects),
|
provideEffects(GorodarEffects, AuthEffects, AreasEffects),
|
||||||
provideStoreDevtools({ maxAge: 25, logOnly: !isDevMode() }),
|
provideStoreDevtools({ maxAge: 25, logOnly: !isDevMode() }),
|
||||||
provideServiceWorker('ngsw-worker.js', {
|
provideServiceWorker('ngsw-worker.js', {
|
||||||
enabled: !isDevMode(),
|
enabled: !isDevMode(),
|
||||||
|
|||||||
@@ -5,16 +5,16 @@ import { CityPage } from './pages/city-page/city-page';
|
|||||||
import { CollectionsPage } from './pages/collections-page/collections-page';
|
import { CollectionsPage } from './pages/collections-page/collections-page';
|
||||||
import { IconPreviewPage } from './pages/icon-preview-page/icon-preview-page';
|
import { IconPreviewPage } from './pages/icon-preview-page/icon-preview-page';
|
||||||
import { MapItemPage } from './pages/map-item-page/map-item-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';
|
import { MapPage } from './pages/map-page/map-page';
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{ path: '', component: CitiesPage },
|
{ path: '', component: CitiesPage },
|
||||||
{ path: 'map', component: MapPage },
|
{ path: 'map', component: MapPage },
|
||||||
{ path: 'collections', component: CollectionsPage },
|
{ path: 'collections', component: CollectionsPage },
|
||||||
{ path: 'city', component: CityPage },
|
{ path: 'collection', pathMatch: 'full', redirectTo: '' },
|
||||||
{ path: 'collection', pathMatch: 'full', redirectTo: '/city' },
|
{ path: 'city/:areaId/:id/icon', component: IconPreviewPage },
|
||||||
{ path: 'city/:id/icon', component: IconPreviewPage },
|
{ path: 'city/:areaId/:id', component: MapItemPage, canActivate: [visitedItemGuard] },
|
||||||
{ path: 'city/:id', component: MapItemPage },
|
{ path: 'city/:areaId', component: CityPage },
|
||||||
{ path: 'objects/:id', redirectTo: 'city/:id' },
|
|
||||||
{ path: '**', redirectTo: '' },
|
{ path: '**', redirectTo: '' },
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -11,6 +11,12 @@
|
|||||||
background: var(--color-bg);
|
background: var(--color-bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (display-mode: standalone) {
|
||||||
|
.app {
|
||||||
|
padding-top: env(safe-area-inset-top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.app__main {
|
.app__main {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import { Component, computed, inject } from '@angular/core';
|
|||||||
import { toSignal } from '@angular/core/rxjs-interop';
|
import { toSignal } from '@angular/core/rxjs-interop';
|
||||||
import { NavigationEnd, Router, RouterOutlet } from '@angular/router';
|
import { NavigationEnd, Router, RouterOutlet } from '@angular/router';
|
||||||
import { filter, map, startWith } from 'rxjs';
|
import { filter, map, startWith } from 'rxjs';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
import { AuthSheet } from './auth/ui/auth-sheet/auth-sheet';
|
import { AuthSheet } from './auth/ui/auth-sheet/auth-sheet';
|
||||||
import { BottomNav } from './layout/bottom-nav/bottom-nav';
|
import { BottomNav } from './layout/bottom-nav/bottom-nav';
|
||||||
|
import { GorodarActions } from './state';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@@ -14,6 +16,11 @@ import { BottomNav } from './layout/bottom-nav/bottom-nav';
|
|||||||
})
|
})
|
||||||
export class App {
|
export class App {
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
|
private readonly store = inject(Store);
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.store.dispatch(GorodarActions.areasRequested());
|
||||||
|
}
|
||||||
|
|
||||||
private readonly url = toSignal(
|
private readonly url = toSignal(
|
||||||
this.router.events.pipe(
|
this.router.events.pipe(
|
||||||
@@ -24,5 +31,7 @@ export class App {
|
|||||||
{ initialValue: this.router.url },
|
{ initialValue: this.router.url },
|
||||||
);
|
);
|
||||||
|
|
||||||
protected readonly hideNav = computed(() => this.url().startsWith('/city/'));
|
protected readonly hideNav = computed(() =>
|
||||||
|
/^\/city\/[^/]+\/[^/]+/.test(this.url().split('?')[0]),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
export interface Attraction {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
about: string;
|
||||||
|
iconUrl: string;
|
||||||
|
backgroundUrl: string;
|
||||||
|
audioUrl: string;
|
||||||
|
modelUrl: string;
|
||||||
|
latitude: number;
|
||||||
|
longitude: number;
|
||||||
|
visited: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AttractionDetails extends Attraction {
|
||||||
|
address: string;
|
||||||
|
facts: string[];
|
||||||
|
photoUrl: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AreaProgress {
|
||||||
|
visited: number;
|
||||||
|
total: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type VisitStatus = 'VISITED' | 'ALREADY_VISITED' | 'NOT_MATCHED' | 'UNCERTAIN';
|
||||||
|
|
||||||
|
export interface VisitResult {
|
||||||
|
status: VisitStatus;
|
||||||
|
confidence: number;
|
||||||
|
progress: AreaProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Area {
|
||||||
|
id: string;
|
||||||
|
parentId: string | null;
|
||||||
|
name: string;
|
||||||
|
attractions: Attraction[];
|
||||||
|
progress: AreaProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AreaDetails extends Area {
|
||||||
|
children: Area[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AreasPage {
|
||||||
|
content: Area[];
|
||||||
|
page: {
|
||||||
|
size: number;
|
||||||
|
number: number;
|
||||||
|
totalElements: number;
|
||||||
|
totalPages: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AreasStatus = 'idle' | 'loading' | 'ready' | 'error';
|
||||||
|
|
||||||
|
export function areaAttractions(area: Area | AreaDetails): Attraction[] {
|
||||||
|
const own = area.attractions ?? [];
|
||||||
|
const children = 'children' in area ? area.children : [];
|
||||||
|
|
||||||
|
return [...own, ...children.flatMap((child) => child.attractions ?? [])];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function findAttraction(area: Area | AreaDetails, id: string): Attraction | null {
|
||||||
|
return areaAttractions(area).find((item) => item.id === id) ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function areaOpenedCount(area: Area | AreaDetails): number {
|
||||||
|
const attractions = areaAttractions(area);
|
||||||
|
|
||||||
|
if (attractions.length > 0) {
|
||||||
|
return attractions.filter((item) => item.visited).length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return area.progress?.visited ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function areaTotalCount(area: Area | AreaDetails): number {
|
||||||
|
const attractions = areaAttractions(area);
|
||||||
|
|
||||||
|
if (attractions.length > 0) {
|
||||||
|
return attractions.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return area.progress?.total ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function areaProgress(area: Area | AreaDetails): number {
|
||||||
|
const total = areaTotalCount(area);
|
||||||
|
|
||||||
|
if (!total) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.round((areaOpenedCount(area) / total) * 100);
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable, inject } from '@angular/core';
|
||||||
|
import { Observable, map } from 'rxjs';
|
||||||
|
|
||||||
|
import { endpoints } from '../../environments/api';
|
||||||
|
import type { Area, AreaDetails, AreasPage, AttractionDetails, VisitResult } from './area.models';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class AreasApiService {
|
||||||
|
private readonly http = inject(HttpClient);
|
||||||
|
|
||||||
|
getAreas(): Observable<Area[]> {
|
||||||
|
return this.http
|
||||||
|
.get<AreasPage>(endpoints.areas, {
|
||||||
|
params: { page: '0', size: '100' },
|
||||||
|
})
|
||||||
|
.pipe(map((page) => page.content));
|
||||||
|
}
|
||||||
|
|
||||||
|
getArea(id: string): Observable<AreaDetails> {
|
||||||
|
return this.http.get<AreaDetails>(endpoints.area(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
getAttraction(id: string): Observable<AttractionDetails> {
|
||||||
|
return this.http.get<AttractionDetails>(endpoints.attraction(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
visit(id: string, photo: Blob): Observable<VisitResult> {
|
||||||
|
const body = new FormData();
|
||||||
|
body.append('photo', photo, 'photo.jpg');
|
||||||
|
return this.http.post<VisitResult>(endpoints.visit(id), body);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
const PHOTO_SIZE = 512;
|
||||||
|
const JPEG_QUALITY = 0.8;
|
||||||
|
|
||||||
|
export function resizePhoto(dataUrl: string): Promise<Blob> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const image = new Image();
|
||||||
|
|
||||||
|
image.onload = () => {
|
||||||
|
const canvas = document.createElement('canvas');
|
||||||
|
canvas.width = PHOTO_SIZE;
|
||||||
|
canvas.height = PHOTO_SIZE;
|
||||||
|
|
||||||
|
const context = canvas.getContext('2d');
|
||||||
|
if (!context || image.width === 0 || image.height === 0) {
|
||||||
|
reject(new Error('Photo compression failed'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scale = Math.max(PHOTO_SIZE / image.width, PHOTO_SIZE / image.height);
|
||||||
|
const width = image.width * scale;
|
||||||
|
const height = image.height * scale;
|
||||||
|
|
||||||
|
context.imageSmoothingQuality = 'high';
|
||||||
|
context.drawImage(image, (PHOTO_SIZE - width) / 2, (PHOTO_SIZE - height) / 2, width, height);
|
||||||
|
|
||||||
|
canvas.toBlob(
|
||||||
|
(blob) => (blob ? resolve(blob) : reject(new Error('Photo compression failed'))),
|
||||||
|
'image/jpeg',
|
||||||
|
JPEG_QUALITY,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
image.onerror = () => reject(new Error('Photo is unreadable'));
|
||||||
|
image.src = dataUrl;
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ import type { AuthSession } from './auth.models';
|
|||||||
const SESSION_KEY = 'gorodar.session';
|
const SESSION_KEY = 'gorodar.session';
|
||||||
|
|
||||||
export function readAuthSession(): AuthSession | null {
|
export function readAuthSession(): AuthSession | null {
|
||||||
const raw = sessionStorage.getItem(SESSION_KEY);
|
const raw = localStorage.getItem(SESSION_KEY);
|
||||||
|
|
||||||
if (!raw) {
|
if (!raw) {
|
||||||
return null;
|
return null;
|
||||||
@@ -13,7 +13,7 @@ export function readAuthSession(): AuthSession | null {
|
|||||||
const expired = !!session && typeof session.expiresAt === 'number' && session.expiresAt <= Date.now();
|
const expired = !!session && typeof session.expiresAt === 'number' && session.expiresAt <= Date.now();
|
||||||
|
|
||||||
if (!session || !isEmail(session.email) || !session.accessToken || expired) {
|
if (!session || !isEmail(session.email) || !session.accessToken || expired) {
|
||||||
sessionStorage.removeItem(SESSION_KEY);
|
localStorage.removeItem(SESSION_KEY);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,11 +21,11 @@ export function readAuthSession(): AuthSession | null {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function writeAuthSession(session: AuthSession): void {
|
export function writeAuthSession(session: AuthSession): void {
|
||||||
sessionStorage.setItem(SESSION_KEY, JSON.stringify(session));
|
localStorage.setItem(SESSION_KEY, JSON.stringify(session));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clearAuthSession(): void {
|
export function clearAuthSession(): void {
|
||||||
sessionStorage.removeItem(SESSION_KEY);
|
localStorage.removeItem(SESSION_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSession(raw: string): AuthSession | null {
|
function parseSession(raw: string): AuthSession | null {
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { HttpInterceptorFn } from '@angular/common/http';
|
||||||
|
import { Injectable, inject } from '@angular/core';
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
|
import { selectAuth } from '../state/gorodar.selectors';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
class AccessTokenReader {
|
||||||
|
private readonly auth = inject(Store).selectSignal(selectAuth);
|
||||||
|
|
||||||
|
token(): string | null {
|
||||||
|
return this.auth().accessToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const authInterceptor: HttpInterceptorFn = (req, next) => {
|
||||||
|
if (req.url.includes('/oauth2/')) {
|
||||||
|
return next(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = inject(AccessTokenReader).token();
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
return next(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
return next(
|
||||||
|
req.clone({
|
||||||
|
setHeaders: { Authorization: `Bearer ${token}` },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
@if (sheetVisible()) {
|
@if (sheetVisible()) {
|
||||||
<div class="sheet-root">
|
<div class="sheet-root" [style.--drag-y.px]="dragY()">
|
||||||
<button
|
<button
|
||||||
class="sheet-root__backdrop"
|
class="sheet-root__backdrop"
|
||||||
type="button"
|
type="button"
|
||||||
@@ -7,7 +7,18 @@
|
|||||||
(click)="dismiss()"
|
(click)="dismiss()"
|
||||||
></button>
|
></button>
|
||||||
|
|
||||||
<section class="sheet" role="dialog" aria-modal="true" aria-labelledby="auth-sheet-title">
|
<div class="sheet-pop">
|
||||||
|
<section
|
||||||
|
class="sheet"
|
||||||
|
[class.sheet--dragging]="dragging()"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="auth-sheet-title"
|
||||||
|
(pointerdown)="onDragStart($event)"
|
||||||
|
(pointermove)="onDragMove($event)"
|
||||||
|
(pointerup)="onDragEnd($event)"
|
||||||
|
(pointercancel)="onDragEnd($event)"
|
||||||
|
>
|
||||||
<button
|
<button
|
||||||
class="sheet__handle"
|
class="sheet__handle"
|
||||||
type="button"
|
type="button"
|
||||||
@@ -42,7 +53,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="sheet__submit"
|
class="btn sheet__submit"
|
||||||
type="button"
|
type="button"
|
||||||
[disabled]="!emailValid() || pending()"
|
[disabled]="!emailValid() || pending()"
|
||||||
(click)="requestCode()"
|
(click)="requestCode()"
|
||||||
@@ -50,6 +61,12 @@
|
|||||||
{{ pending() ? 'Отправляем…' : 'Получить код' }}
|
{{ pending() ? 'Отправляем…' : 'Получить код' }}
|
||||||
</button>
|
</button>
|
||||||
<button class="sheet__ghost" type="button" (click)="dismiss()">Пока просто посмотрю</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 {
|
} @else {
|
||||||
<h2 id="auth-sheet-title">{{ title() }}</h2>
|
<h2 id="auth-sheet-title">{{ title() }}</h2>
|
||||||
<p class="sheet__lead">
|
<p class="sheet__lead">
|
||||||
@@ -76,7 +93,7 @@
|
|||||||
<button
|
<button
|
||||||
class="sheet__resend"
|
class="sheet__resend"
|
||||||
type="button"
|
type="button"
|
||||||
[disabled]="resendSeconds() > 0 || pending()"
|
[disabled]="secondsLeft() > 0 || pending()"
|
||||||
(click)="resend()"
|
(click)="resend()"
|
||||||
>
|
>
|
||||||
{{ resendLabel() }}
|
{{ resendLabel() }}
|
||||||
@@ -87,7 +104,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="sheet__submit"
|
class="btn sheet__submit"
|
||||||
type="button"
|
type="button"
|
||||||
[disabled]="!codeReady() || pending()"
|
[disabled]="!codeReady() || pending()"
|
||||||
(click)="confirm()"
|
(click)="confirm()"
|
||||||
@@ -97,5 +114,6 @@
|
|||||||
<button class="sheet__ghost" type="button" (click)="changeEmail()">Изменить почту</button>
|
<button class="sheet__ghost" type="button" (click)="changeEmail()">Изменить почту</button>
|
||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
:host {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
|
|
||||||
.sheet-root {
|
.sheet-root {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 70;
|
z-index: 70;
|
||||||
@@ -13,42 +17,63 @@
|
|||||||
border: 0;
|
border: 0;
|
||||||
background: rgb(8 7 6 / 64%);
|
background: rgb(8 7 6 / 64%);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
opacity: calc(1 - min(var(--drag-y, 0px), 280px) / 280px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sheet {
|
.sheet-pop {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
width: min(100%, 480px);
|
width: min(100%, 480px);
|
||||||
max-height: min(92dvh, 760px);
|
max-height: min(92dvh, 760px);
|
||||||
overflow: auto;
|
animation: sheet-in 0.28s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sheet {
|
||||||
|
width: 100%;
|
||||||
|
max-height: min(92dvh, 760px);
|
||||||
|
overflow: hidden auto;
|
||||||
padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
|
padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
|
||||||
border: 1px solid var(--color-border);
|
border: 1px solid var(--color-border);
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
border-radius: 28px 28px 0 0;
|
border-radius: 28px 28px 0 0;
|
||||||
background: #1a1815;
|
background: #1a1815;
|
||||||
animation: sheet-in 0.28s ease-out;
|
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 {
|
.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;
|
display: block;
|
||||||
width: 42px;
|
width: 42px;
|
||||||
height: 4px;
|
height: 4px;
|
||||||
margin: 6px auto 12px;
|
margin: 0 auto;
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
background: #4a453c;
|
background: #4a453c;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sheet__lock {
|
.sheet__lock {
|
||||||
display: grid;
|
display: grid;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
width: 68px;
|
|
||||||
height: 68px;
|
|
||||||
margin: 8px auto 16px;
|
margin: 8px auto 16px;
|
||||||
border: 1.5px solid var(--color-accent);
|
|
||||||
border-radius: 18px;
|
|
||||||
color: var(--color-accent);
|
color: var(--color-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,14 +154,19 @@
|
|||||||
.sheet__resend {
|
.sheet__resend {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
min-height: 20px;
|
||||||
margin-top: 14px;
|
margin-top: 14px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
border: 0;
|
border: 0;
|
||||||
background: none;
|
background: none;
|
||||||
color: var(--color-muted);
|
color: var(--color-muted);
|
||||||
font: inherit;
|
font: inherit;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,22 +183,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sheet__submit {
|
.sheet__submit {
|
||||||
width: 100%;
|
|
||||||
min-height: 52px;
|
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
border: 0;
|
|
||||||
border-radius: 16px;
|
|
||||||
background: var(--color-accent);
|
|
||||||
color: var(--color-on-accent);
|
|
||||||
font: inherit;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sheet__submit:disabled {
|
|
||||||
opacity: 0.45;
|
|
||||||
cursor: default;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sheet__ghost {
|
.sheet__ghost {
|
||||||
@@ -186,6 +201,20 @@
|
|||||||
cursor: pointer;
|
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 {
|
@keyframes sheet-in {
|
||||||
from {
|
from {
|
||||||
transform: translateY(24px);
|
transform: translateY(24px);
|
||||||
@@ -196,7 +225,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.sheet {
|
.sheet-pop {
|
||||||
animation: none;
|
animation: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sheet {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
|
DestroyRef,
|
||||||
ElementRef,
|
ElementRef,
|
||||||
HostListener,
|
HostListener,
|
||||||
computed,
|
computed,
|
||||||
@@ -13,6 +14,8 @@ import {
|
|||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
import { Icon } from '../../../shared/icon/icon';
|
import { Icon } from '../../../shared/icon/icon';
|
||||||
|
import { privacyDocumentUrl, termsDocumentUrl } from '../../../shared/legal-documents';
|
||||||
|
import { RESEND_SECONDS } from '../../../state/gorodar.models';
|
||||||
import {
|
import {
|
||||||
GorodarActions,
|
GorodarActions,
|
||||||
selectAuthCodeRequestId,
|
selectAuthCodeRequestId,
|
||||||
@@ -20,12 +23,13 @@ import {
|
|||||||
selectAuthError,
|
selectAuthError,
|
||||||
selectAuthIntent,
|
selectAuthIntent,
|
||||||
selectAuthPending,
|
selectAuthPending,
|
||||||
selectAuthResendSeconds,
|
|
||||||
selectAuthSheetVisible,
|
selectAuthSheetVisible,
|
||||||
selectAuthStep,
|
selectAuthStep,
|
||||||
} from '../../../state';
|
} from '../../../state';
|
||||||
|
|
||||||
const CODE_LENGTH = 6;
|
const CODE_LENGTH = 6;
|
||||||
|
const DISMISS_DISTANCE = 120;
|
||||||
|
const DISMISS_VELOCITY = 0.55;
|
||||||
|
|
||||||
function emptyDigits(): string[] {
|
function emptyDigits(): string[] {
|
||||||
return Array.from({ length: CODE_LENGTH }, () => '');
|
return Array.from({ length: CODE_LENGTH }, () => '');
|
||||||
@@ -40,17 +44,33 @@ function emptyDigits(): string[] {
|
|||||||
})
|
})
|
||||||
export class AuthSheet {
|
export class AuthSheet {
|
||||||
private readonly store = inject(Store);
|
private readonly store = inject(Store);
|
||||||
|
private readonly destroyRef = inject(DestroyRef);
|
||||||
private readonly digitFields = viewChildren<ElementRef<HTMLInputElement>>('digit');
|
private readonly digitFields = viewChildren<ElementRef<HTMLInputElement>>('digit');
|
||||||
|
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 termsUrl = termsDocumentUrl;
|
||||||
|
protected readonly privacyUrl = privacyDocumentUrl;
|
||||||
protected readonly emailDraft = signal('');
|
protected readonly emailDraft = signal('');
|
||||||
protected readonly digits = signal<string[]>(emptyDigits());
|
protected readonly digits = signal<string[]>(emptyDigits());
|
||||||
|
protected readonly secondsLeft = signal(0);
|
||||||
|
protected readonly dragY = signal(0);
|
||||||
|
protected readonly dragging = signal(false);
|
||||||
|
|
||||||
protected readonly sheetVisible = this.store.selectSignal(selectAuthSheetVisible);
|
protected readonly sheetVisible = this.store.selectSignal(selectAuthSheetVisible);
|
||||||
protected readonly step = this.store.selectSignal(selectAuthStep);
|
protected readonly step = this.store.selectSignal(selectAuthStep);
|
||||||
protected readonly email = this.store.selectSignal(selectAuthEmail);
|
protected readonly email = this.store.selectSignal(selectAuthEmail);
|
||||||
protected readonly error = this.store.selectSignal(selectAuthError);
|
protected readonly error = this.store.selectSignal(selectAuthError);
|
||||||
protected readonly pending = this.store.selectSignal(selectAuthPending);
|
protected readonly pending = this.store.selectSignal(selectAuthPending);
|
||||||
protected readonly resendSeconds = this.store.selectSignal(selectAuthResendSeconds);
|
|
||||||
protected readonly intent = this.store.selectSignal(selectAuthIntent);
|
protected readonly intent = this.store.selectSignal(selectAuthIntent);
|
||||||
private readonly codeRequestId = this.store.selectSignal(selectAuthCodeRequestId);
|
private readonly codeRequestId = this.store.selectSignal(selectAuthCodeRequestId);
|
||||||
|
|
||||||
@@ -71,7 +91,7 @@ export class AuthSheet {
|
|||||||
});
|
});
|
||||||
|
|
||||||
protected readonly resendLabel = computed(() => {
|
protected readonly resendLabel = computed(() => {
|
||||||
const seconds = this.resendSeconds();
|
const seconds = this.secondsLeft();
|
||||||
|
|
||||||
if (seconds <= 0) {
|
if (seconds <= 0) {
|
||||||
return 'Отправить код ещё раз';
|
return 'Отправить код ещё раз';
|
||||||
@@ -106,8 +126,35 @@ export class AuthSheet {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
requestAnimationFrame(() => this.digitFields()[0]?.nativeElement.focus());
|
requestAnimationFrame(() =>
|
||||||
|
this.digitFields()[0]?.nativeElement.focus({ preventScroll: true }),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
effect((onCleanup) => {
|
||||||
|
const requestId = this.codeRequestId();
|
||||||
|
|
||||||
|
if (requestId === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let left = RESEND_SECONDS;
|
||||||
|
untracked(() => this.secondsLeft.set(left));
|
||||||
|
|
||||||
|
const timerId = window.setInterval(() => {
|
||||||
|
left -= 1;
|
||||||
|
const next = Math.max(left, 0);
|
||||||
|
this.secondsLeft.set(next);
|
||||||
|
|
||||||
|
if (next === 0) {
|
||||||
|
window.clearInterval(timerId);
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
onCleanup(() => window.clearInterval(timerId));
|
||||||
|
});
|
||||||
|
|
||||||
|
this.destroyRef.onDestroy(() => window.clearTimeout(this.closeTimer));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onEmail(event: Event): void {
|
protected onEmail(event: Event): void {
|
||||||
@@ -125,7 +172,7 @@ export class AuthSheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected resend(): void {
|
protected resend(): void {
|
||||||
if (this.resendSeconds() > 0 || this.pending()) {
|
if (this.secondsLeft() > 0 || this.pending()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,9 +184,121 @@ export class AuthSheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected dismiss(): void {
|
protected dismiss(): void {
|
||||||
|
window.clearTimeout(this.closeTimer);
|
||||||
|
this.closeTimer = 0;
|
||||||
|
this.dragY.set(0);
|
||||||
|
this.dragging.set(false);
|
||||||
this.store.dispatch(GorodarActions.authSheetDismissed());
|
this.store.dispatch(GorodarActions.authSheetDismissed());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private canDragFrom(target: EventTarget | null): boolean {
|
||||||
|
if (!(target instanceof Element)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isHandle(target)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return target.closest('input, textarea, button, a, label') == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private isHandle(target: EventTarget | null): boolean {
|
||||||
|
return target instanceof Element && target.closest('.sheet__handle') != null;
|
||||||
|
}
|
||||||
|
|
||||||
protected onDigit(index: number, event: Event): void {
|
protected onDigit(index: number, event: Event): void {
|
||||||
const input = event.target as HTMLInputElement;
|
const input = event.target as HTMLInputElement;
|
||||||
const value = input.value.replace(/\D/g, '').slice(-1);
|
const value = input.value.replace(/\D/g, '').slice(-1);
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
@if (stage() === 'check' && photo(); as image) {
|
@if (claim().stage === 'check' && claim().photo; as image) {
|
||||||
<app-photo-check [photo]="image" [title]="landmark().title" [step]="step()" />
|
<app-photo-check [photo]="image" [title]="landmark().name" [step]="claim().step" />
|
||||||
} @else if (stage() === 'success') {
|
} @else if (claim().stage === 'failed') {
|
||||||
|
<app-photo-fail
|
||||||
|
[uncertain]="claim().failure === 'uncertain'"
|
||||||
|
[confidence]="claim().confidence"
|
||||||
|
(retake)="retake()"
|
||||||
|
(back)="leave()"
|
||||||
|
/>
|
||||||
|
} @else if (claim().stage === 'success') {
|
||||||
<app-collect-success
|
<app-collect-success
|
||||||
[title]="landmark().title"
|
[title]="landmark().name"
|
||||||
[image]="landmark().achievement"
|
[image]="landmark().iconUrl"
|
||||||
[model]="landmark().model"
|
[model]="landmark().modelUrl || undefined"
|
||||||
[cityName]="city.name"
|
[alreadyVisited]="claim().alreadyVisited"
|
||||||
[opened]="openedCount()"
|
[cityName]="cityName()"
|
||||||
[total]="totalCount"
|
[opened]="opened()"
|
||||||
|
[total]="total()"
|
||||||
|
[areaId]="areaId()"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,34 @@
|
|||||||
import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
import type { Landmark } from '../../data/nizhny-novgorod';
|
import type { Attraction } from '../../areas/area.models';
|
||||||
import { CityCatalogService } from '../../root/services/city-catalog.service';
|
import { GorodarActions, selectClaim } from '../../state';
|
||||||
import {
|
|
||||||
selectClaimPhoto,
|
|
||||||
selectClaimStage,
|
|
||||||
selectClaimStep,
|
|
||||||
selectOpenedCount,
|
|
||||||
} from '../../state';
|
|
||||||
import { CollectSuccess } from '../collect-success/collect-success';
|
import { CollectSuccess } from '../collect-success/collect-success';
|
||||||
import { PhotoCheck } from '../photo-check/photo-check';
|
import { PhotoCheck } from '../photo-check/photo-check';
|
||||||
|
import { PhotoFail } from '../photo-fail/photo-fail';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-claim-flow',
|
selector: 'app-claim-flow',
|
||||||
imports: [PhotoCheck, CollectSuccess],
|
imports: [PhotoCheck, PhotoFail, CollectSuccess],
|
||||||
templateUrl: './claim-flow.html',
|
templateUrl: './claim-flow.html',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class ClaimFlow {
|
export class ClaimFlow {
|
||||||
private readonly store = inject(Store);
|
private readonly store = inject(Store);
|
||||||
private readonly catalog = inject(CityCatalogService);
|
|
||||||
|
|
||||||
readonly landmark = input.required<Landmark>();
|
readonly landmark = input.required<Attraction>();
|
||||||
|
readonly cityName = input('');
|
||||||
|
readonly opened = input(0);
|
||||||
|
readonly total = input(1);
|
||||||
|
readonly areaId = input('');
|
||||||
|
|
||||||
protected readonly city = this.catalog.city;
|
protected readonly claim = this.store.selectSignal(selectClaim);
|
||||||
protected readonly totalCount = this.city.objects.length;
|
|
||||||
protected readonly photo = this.store.selectSignal(selectClaimPhoto);
|
protected retake(): void {
|
||||||
protected readonly stage = this.store.selectSignal(selectClaimStage);
|
this.store.dispatch(GorodarActions.takePhoto({ landmarkId: this.landmark().id }));
|
||||||
protected readonly step = this.store.selectSignal(selectClaimStep);
|
}
|
||||||
protected readonly openedCount = this.store.selectSignal(selectOpenedCount);
|
|
||||||
|
protected leave(): void {
|
||||||
|
this.store.dispatch(GorodarActions.claimReset());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,6 @@
|
|||||||
|
|
||||||
@if (model()) {
|
@if (model()) {
|
||||||
<div class="success__switch" role="group" aria-label="Вид объекта">
|
<div class="success__switch" role="group" aria-label="Вид объекта">
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
[class.is-active]="view() === 'model'"
|
|
||||||
[attr.aria-pressed]="view() === 'model'"
|
|
||||||
(click)="showModel()"
|
|
||||||
>
|
|
||||||
3D
|
|
||||||
</button>
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
[class.is-active]="view() === 'image'"
|
[class.is-active]="view() === 'image'"
|
||||||
@@ -27,6 +19,14 @@
|
|||||||
>
|
>
|
||||||
Картинка
|
Картинка
|
||||||
</button>
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
[class.is-active]="view() === 'model'"
|
||||||
|
[attr.aria-pressed]="view() === 'model'"
|
||||||
|
(click)="showModel()"
|
||||||
|
>
|
||||||
|
3D
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,27 +84,40 @@
|
|||||||
@if (mode() === 'preview') {
|
@if (mode() === 'preview') {
|
||||||
<h1 class="success__title">{{ title() }}</h1>
|
<h1 class="success__title">{{ title() }}</h1>
|
||||||
} @else {
|
} @else {
|
||||||
<div class="success__copy">
|
<div class="success__copy">
|
||||||
<p class="success__eyebrow">Новое в коллекции</p>
|
<p class="success__eyebrow">
|
||||||
<h1>{{ title() }}</h1>
|
{{ alreadyVisited() ? 'Уже в коллекции' : 'Новое в коллекции' }}
|
||||||
<p>Добавлено в коллекцию «{{ cityName() }}»</p>
|
</p>
|
||||||
</div>
|
<h1>{{ title() }}</h1>
|
||||||
|
<p>
|
||||||
<div class="success__card anim-rise">
|
{{
|
||||||
<div class="success__row">
|
alreadyVisited()
|
||||||
<span>{{ cityName() }}</span>
|
? 'Этот объект уже был в коллекции «' + cityName() + '»'
|
||||||
<span>
|
: 'Добавлено в коллекцию «' + cityName() + '»'
|
||||||
<b>{{ opened() }} из {{ total() }}</b>
|
}}
|
||||||
</span>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="success__bar">
|
|
||||||
<span class="anim-grow" [style.--from]="from() + '%'" [style.--to]="to() + '%'"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="success__actions">
|
<div class="success__card anim-rise">
|
||||||
<a matButton="filled" routerLink="/collections" (click)="leave()">Открыть коллекцию</a>
|
<div class="success__row">
|
||||||
<a class="success__ghost" routerLink="/city" (click)="leave()">Назад</a>
|
<span>{{ cityName() }}</span>
|
||||||
</div>
|
<span>
|
||||||
|
<b>{{ opened() }} из {{ total() }}</b>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="success__bar">
|
||||||
|
<span class="anim-grow" [style.--from]="from() + '%'" [style.--to]="to() + '%'"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="success__actions">
|
||||||
|
<a class="btn" routerLink="/collections" (click)="leave()">Открыть коллекцию</a>
|
||||||
|
<a
|
||||||
|
class="success__ghost"
|
||||||
|
[routerLink]="areaId() ? ['/city', areaId()] : ['/']"
|
||||||
|
(click)="leave()"
|
||||||
|
>Назад</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -309,15 +309,6 @@
|
|||||||
margin-top: 24px;
|
margin-top: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.success__actions a[matButton='filled'] {
|
|
||||||
width: 100%;
|
|
||||||
min-height: 56px;
|
|
||||||
--mat-button-filled-container-color: #d4143f;
|
|
||||||
--mat-button-filled-label-text-color: #fff;
|
|
||||||
background-color: #d4143f;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.success__ghost {
|
.success__ghost {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import {
|
|||||||
untracked,
|
untracked,
|
||||||
viewChild,
|
viewChild,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { MatButton } from '@angular/material/button';
|
|
||||||
import { Router, RouterLink } from '@angular/router';
|
import { Router, RouterLink } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
@@ -22,7 +21,7 @@ import { GorodarActions } from '../../state';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-collect-success',
|
selector: 'app-collect-success',
|
||||||
imports: [Icon, RouterLink, MatButton],
|
imports: [Icon, RouterLink],
|
||||||
templateUrl: './collect-success.html',
|
templateUrl: './collect-success.html',
|
||||||
styleUrl: './collect-success.scss',
|
styleUrl: './collect-success.scss',
|
||||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||||
@@ -42,8 +41,10 @@ export class CollectSuccess {
|
|||||||
readonly cityName = input('');
|
readonly cityName = input('');
|
||||||
readonly opened = input(0);
|
readonly opened = input(0);
|
||||||
readonly total = input(1);
|
readonly total = input(1);
|
||||||
|
readonly areaId = input('');
|
||||||
|
readonly alreadyVisited = input(false);
|
||||||
|
|
||||||
protected readonly view = signal<'model' | 'image'>('model');
|
protected readonly view = signal<'model' | 'image'>('image');
|
||||||
protected readonly modelLoaded = signal(false);
|
protected readonly modelLoaded = signal(false);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -51,7 +52,7 @@ export class CollectSuccess {
|
|||||||
const src = this.model();
|
const src = this.model();
|
||||||
|
|
||||||
untracked(() => {
|
untracked(() => {
|
||||||
this.view.set('model');
|
this.view.set('image');
|
||||||
this.modelLoaded.set(false);
|
this.modelLoaded.set(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -129,7 +130,8 @@ export class CollectSuccess {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void this.router.navigateByUrl('/city');
|
const areaId = this.areaId();
|
||||||
|
void this.router.navigate(areaId ? ['/city', areaId] : ['/']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,47 +5,25 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1>Проверяем фото</h1>
|
<h1>Проверяем фото</h1>
|
||||||
<p>Обычно это занимает несколько секунд</p>
|
<p>Сверяем снимок с эталоном</p>
|
||||||
|
|
||||||
<ol class="steps">
|
<ol class="steps">
|
||||||
<li [class.steps__item--done]="step() >= 1">
|
@for (item of items(); track item.title) {
|
||||||
<span class="steps__mark steps__mark--done">
|
<li [class.steps__item--done]="item.state === 'done'" [class.steps__item--active]="item.state === 'active'">
|
||||||
<app-icon name="check" [size]="18" />
|
@if (item.state === 'done') {
|
||||||
</span>
|
<span class="steps__mark steps__mark--done">
|
||||||
<div>
|
<app-icon name="check" [size]="18" />
|
||||||
<b>Фото отправлено</b>
|
</span>
|
||||||
<span>Снимок получен сервисом</span>
|
} @else if (item.state === 'active') {
|
||||||
</div>
|
<span class="steps__mark steps__mark--spin anim-spinner"></span>
|
||||||
</li>
|
} @else {
|
||||||
|
<span class="steps__mark"></span>
|
||||||
<li [class.steps__item--done]="step() >= 2" [class.steps__item--active]="step() === 1">
|
}
|
||||||
@if (step() >= 2) {
|
<div>
|
||||||
<span class="steps__mark steps__mark--done">
|
<b>{{ item.title }}</b>
|
||||||
<app-icon name="check" [size]="18" />
|
<span>{{ item.text }}</span>
|
||||||
</span>
|
</div>
|
||||||
} @else {
|
</li>
|
||||||
<span class="steps__mark steps__mark--spin anim-spinner"></span>
|
}
|
||||||
}
|
|
||||||
<div>
|
|
||||||
<b>Сравниваем с эталонами</b>
|
|
||||||
<span>Ищем совпадение с {{ title() }}</span>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li [class.steps__item--done]="step() >= 3" [class.steps__item--active]="step() === 2">
|
|
||||||
@if (step() >= 3) {
|
|
||||||
<span class="steps__mark steps__mark--done">
|
|
||||||
<app-icon name="check" [size]="18" />
|
|
||||||
</span>
|
|
||||||
} @else if (step() === 2) {
|
|
||||||
<span class="steps__mark steps__mark--spin anim-spinner"></span>
|
|
||||||
} @else {
|
|
||||||
<span class="steps__mark"></span>
|
|
||||||
}
|
|
||||||
<div>
|
|
||||||
<b>Добавляем в коллекцию</b>
|
|
||||||
<span>Объект появится в вашей коллекции</span>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -99,6 +99,13 @@
|
|||||||
border: 0;
|
border: 0;
|
||||||
background: var(--color-accent);
|
background: var(--color-accent);
|
||||||
color: var(--color-on-accent);
|
color: var(--color-on-accent);
|
||||||
|
animation: step-pop 0.35s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes step-pop {
|
||||||
|
from {
|
||||||
|
transform: scale(0.4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.steps b,
|
.steps b,
|
||||||
@@ -121,3 +128,9 @@
|
|||||||
.steps__item--active b {
|
.steps__item--active b {
|
||||||
color: var(--color-text);
|
color: var(--color-text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.steps__mark--done {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core';
|
||||||
|
|
||||||
import { Icon } from '../../shared/icon/icon';
|
import { Icon } from '../../shared/icon/icon';
|
||||||
|
|
||||||
|
type StepState = 'done' | 'active' | 'wait';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-photo-check',
|
selector: 'app-photo-check',
|
||||||
imports: [Icon],
|
imports: [Icon],
|
||||||
@@ -12,5 +14,35 @@ import { Icon } from '../../shared/icon/icon';
|
|||||||
export class PhotoCheck {
|
export class PhotoCheck {
|
||||||
readonly photo = input.required<string>();
|
readonly photo = input.required<string>();
|
||||||
readonly title = input.required<string>();
|
readonly title = input.required<string>();
|
||||||
readonly step = input(1);
|
readonly step = input(0);
|
||||||
|
|
||||||
|
protected readonly items = computed(() => {
|
||||||
|
const step = this.step();
|
||||||
|
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: 'Фото отправлено',
|
||||||
|
text: step >= 1 ? 'Снимок получен сервисом' : 'Готовим снимок',
|
||||||
|
state: stepState(step, 0),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Сравниваем с эталонами',
|
||||||
|
text: `Ищем совпадение с ${this.title()}`,
|
||||||
|
state: stepState(step, 1),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Добавляем в коллекцию',
|
||||||
|
text: 'Объект появится в вашей коллекции',
|
||||||
|
state: stepState(step, 2),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function stepState(step: number, index: number): StepState {
|
||||||
|
if (step > index) {
|
||||||
|
return 'done';
|
||||||
|
}
|
||||||
|
|
||||||
|
return step === index ? 'active' : 'wait';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<section class="fail">
|
||||||
|
<header class="fail__top">
|
||||||
|
<button class="fail__back" type="button" aria-label="К карточке объекта" (click)="back.emit()">
|
||||||
|
<app-icon name="chevron-left" [size]="22" />
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="fail__body">
|
||||||
|
<div class="fail__cross">
|
||||||
|
<img src="/assets/icons/cross.svg" alt="" width="80" height="80" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1>{{ uncertain() ? 'Снимок неоднозначный' : 'Не получилось подтвердить' }}</h1>
|
||||||
|
|
||||||
|
@if (confidence() !== null) {
|
||||||
|
<div class="match">
|
||||||
|
<div class="match__head">
|
||||||
|
<span>Совпадение с эталонами</span>
|
||||||
|
<b class="match__value" [class.match__value--met]="shownPercent() >= requiredPercent">{{ shownPercent() }}%</b>
|
||||||
|
</div>
|
||||||
|
<div class="match__track">
|
||||||
|
<div class="match__fill" [style.width.%]="shownPercent()"></div>
|
||||||
|
<span class="match__mark" [style.left.%]="requiredPercent"></span>
|
||||||
|
<span class="match__need" [style.left.%]="requiredPercent">нужно от {{ requiredPercent }}%</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<ul class="fail__tips">
|
||||||
|
@for (tip of tips; track tip) {
|
||||||
|
<li>
|
||||||
|
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||||
|
<path d="M3 12 a9 9 0 1 0 18 0 a9 9 0 1 0 -18 0" stroke="currentColor" stroke-width="1.8" />
|
||||||
|
<path d="M12 11 V17 M12 7.5 V7.6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" />
|
||||||
|
</svg>
|
||||||
|
<span>{{ tip }}</span>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="fail__actions">
|
||||||
|
<button class="btn" type="button" (click)="retake.emit()">
|
||||||
|
<app-icon name="camera" [size]="24" />
|
||||||
|
Сделать новое фото
|
||||||
|
</button>
|
||||||
|
<button class="fail__leave" type="button" (click)="back.emit()">Вернуться к карточке</button>
|
||||||
|
</footer>
|
||||||
|
</section>
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
:host {
|
||||||
|
display: block;
|
||||||
|
min-height: 100%;
|
||||||
|
background: var(--color-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 100dvh;
|
||||||
|
box-sizing: border-box;
|
||||||
|
padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail__top {
|
||||||
|
padding: 0 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail__back {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
padding: 0;
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: 14px;
|
||||||
|
background: rgb(28 26 23 / 86%);
|
||||||
|
color: var(--color-text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail__body {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 8px 8px 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail__cross {
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
min-height: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail h1 {
|
||||||
|
margin: 28px 0 0;
|
||||||
|
font-family: var(--font-display);
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.2;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.match {
|
||||||
|
align-self: stretch;
|
||||||
|
margin-top: 22px;
|
||||||
|
padding: 16px 16px 14px;
|
||||||
|
border: 1px solid rgb(255 255 255 / 8%);
|
||||||
|
border-radius: 16px;
|
||||||
|
background: #161513;
|
||||||
|
animation: match-in 0.45s ease both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.match__head {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.match__value {
|
||||||
|
color: #f0876a;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.match__value--met {
|
||||||
|
color: var(--color-accent-soft);
|
||||||
|
}
|
||||||
|
|
||||||
|
.match__track {
|
||||||
|
position: relative;
|
||||||
|
height: 8px;
|
||||||
|
margin: 14px 0 26px;
|
||||||
|
border-radius: 99px;
|
||||||
|
background: #3a342e;
|
||||||
|
}
|
||||||
|
|
||||||
|
.match__fill {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: inherit;
|
||||||
|
background: #efb0a0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes match-in {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(10px);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.match__mark {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
z-index: 1;
|
||||||
|
width: 2px;
|
||||||
|
height: 18px;
|
||||||
|
background: #fff;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.match__need {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% + 6px);
|
||||||
|
color: #9c958a;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.2;
|
||||||
|
white-space: nowrap;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.match {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail__tips {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-self: stretch;
|
||||||
|
gap: 10px;
|
||||||
|
margin: 28px 0 0;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
color: #ddd6c8;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail__tips li {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail__tips svg {
|
||||||
|
flex: none;
|
||||||
|
margin-top: 2px;
|
||||||
|
color: var(--color-accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail__actions {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fail__leave {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 48px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 16px;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--color-muted);
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import {
|
||||||
|
afterNextRender,
|
||||||
|
ChangeDetectionStrategy,
|
||||||
|
Component,
|
||||||
|
computed,
|
||||||
|
input,
|
||||||
|
output,
|
||||||
|
signal,
|
||||||
|
} from '@angular/core';
|
||||||
|
|
||||||
|
import { Icon } from '../../shared/icon/icon';
|
||||||
|
|
||||||
|
const COUNTER_MS = 1200;
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-photo-fail',
|
||||||
|
imports: [Icon],
|
||||||
|
templateUrl: './photo-fail.html',
|
||||||
|
styleUrl: './photo-fail.scss',
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
|
})
|
||||||
|
export class PhotoFail {
|
||||||
|
readonly uncertain = input(false);
|
||||||
|
readonly confidence = input.required<number | null>();
|
||||||
|
readonly retake = output<void>();
|
||||||
|
readonly back = output<void>();
|
||||||
|
|
||||||
|
protected readonly requiredPercent = 55;
|
||||||
|
protected readonly percent = computed(() => confidencePercent(this.confidence()));
|
||||||
|
protected readonly shownPercent = signal(0);
|
||||||
|
|
||||||
|
protected readonly tips = [
|
||||||
|
'Фотографируйте из точки указанной карте.',
|
||||||
|
'Постарайтесь чтобы объект попал в кадр полностью.',
|
||||||
|
'Снимайте при хорошем свете, без пальце в кадре.',
|
||||||
|
];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
afterNextRender(() => this.playCounter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private playCounter(): void {
|
||||||
|
const target = this.percent();
|
||||||
|
const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||||
|
|
||||||
|
if (target === 0 || reduceMotion) {
|
||||||
|
this.shownPercent.set(target);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const started = performance.now();
|
||||||
|
const tick = (now: number) => {
|
||||||
|
const progress = Math.min(1, (now - started) / COUNTER_MS);
|
||||||
|
this.shownPercent.set(Math.round(target * progress));
|
||||||
|
|
||||||
|
if (progress < 1) {
|
||||||
|
requestAnimationFrame(tick);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
requestAnimationFrame(tick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function confidencePercent(confidence: number | null): number {
|
||||||
|
if (confidence === null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = confidence <= 1 ? confidence * 100 : confidence;
|
||||||
|
return Math.max(0, Math.min(100, Math.round(value)));
|
||||||
|
}
|
||||||
@@ -1,142 +0,0 @@
|
|||||||
export interface Landmark {
|
|
||||||
id: string;
|
|
||||||
title: string;
|
|
||||||
description: string;
|
|
||||||
address: string;
|
|
||||||
addressHint: string;
|
|
||||||
coordinates: [number, number];
|
|
||||||
collected: boolean;
|
|
||||||
geoCheckEnabled: boolean;
|
|
||||||
geoRadiusMeters: number;
|
|
||||||
facts: string[];
|
|
||||||
photoHint: string;
|
|
||||||
background: string;
|
|
||||||
audio: string;
|
|
||||||
achievement: string;
|
|
||||||
model?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface City {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
center: [number, number];
|
|
||||||
objects: Landmark[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const NIZHNY_NOVGOROD: City = {
|
|
||||||
id: 'nizhny-novgorod',
|
|
||||||
name: 'Нижний Новгород',
|
|
||||||
center: [43.99934, 56.329399],
|
|
||||||
objects: [
|
|
||||||
{
|
|
||||||
id: 'chkalov-stairs',
|
|
||||||
title: 'Чкаловская лестница',
|
|
||||||
description:
|
|
||||||
'Главная лестница-серпантин города: она спускается пологими зигзагами от площади Минина и Пожарского к Волге, а на верхней площадке стоит памятник лётчику Валерию Чкалову, чьё имя лестница носит.',
|
|
||||||
address: 'Верхне-Волжская набережная, Нижний Новгород',
|
|
||||||
addressHint: 'От площади Минина и Пожарского к Волге',
|
|
||||||
coordinates: [44.009444, 56.330833],
|
|
||||||
collected: false,
|
|
||||||
geoCheckEnabled: true,
|
|
||||||
geoRadiusMeters: 300,
|
|
||||||
facts: [
|
|
||||||
'Построена в 1943–1949 годах в честь победы в Сталинградской битве.',
|
|
||||||
'560 ступеней по внешнему контуру — одна из самых длинных лестниц в России.',
|
|
||||||
'Форма — цифра «8» с двумя смотровыми площадками с видом на Волгу и Стрелку.',
|
|
||||||
],
|
|
||||||
photoHint: 'Снимайте так, чтобы лестница читалась целиком.',
|
|
||||||
background: '/assets/background/nn-bg-chkalov-stairs.svg',
|
|
||||||
audio: '/assets/audio/chkalov-stairs.mp3',
|
|
||||||
achievement: '/assets/achivments/chkalov-stairs.png',
|
|
||||||
model: '/assets/models/chkalov-stairs.glb',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'kremlin',
|
|
||||||
title: 'Нижегородский кремль',
|
|
||||||
description:
|
|
||||||
'Каменная крепость на высоком берегу Волги и Оки — исторический центр и главный символ Нижнего Новгорода.',
|
|
||||||
address: 'Кремль, Нижний Новгород',
|
|
||||||
addressHint: 'Высокий берег Волги и Оки',
|
|
||||||
coordinates: [44.00235, 56.327244],
|
|
||||||
collected: false,
|
|
||||||
geoCheckEnabled: true,
|
|
||||||
geoRadiusMeters: 300,
|
|
||||||
facts: [
|
|
||||||
'Построен в 1508–1515 годах.',
|
|
||||||
'13 башен (5 проездных, 8 глухих), общая длина стен — около 2045 метров.',
|
|
||||||
'Ни разу не был взят неприятелем за всю свою историю.',
|
|
||||||
],
|
|
||||||
photoHint: 'Снимайте так, чтобы были видны стены и башни кремля.',
|
|
||||||
background: '/assets/background/nn-bg-kremlin.svg',
|
|
||||||
audio: '/assets/audio/kremlin.mp3',
|
|
||||||
achievement: '/assets/achivments/kremlin.png',
|
|
||||||
model: '/assets/models/kremlin.glb',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'iron-deer',
|
|
||||||
title: 'Железный олень',
|
|
||||||
description:
|
|
||||||
'Пятиметровая скульптура оленя на Нижневолжской набережной — подарок городу от почётного консула Венгрии и одна из самых фотографируемых точек в городе.',
|
|
||||||
address: 'Нижне-Волжская набережная, Нижний Новгород',
|
|
||||||
addressHint: 'На набережной Волги',
|
|
||||||
coordinates: [44.012083, 56.332055],
|
|
||||||
collected: false,
|
|
||||||
geoCheckEnabled: true,
|
|
||||||
geoRadiusMeters: 300,
|
|
||||||
facts: [
|
|
||||||
'Установлен в 2014 году к 793-летию основания Нижнего Новгорода.',
|
|
||||||
'Автор — венгерский скульптор Габор Миклош Жоке; фигура собрана из металлических пластин.',
|
|
||||||
'Олень — древний символ, изображён на гербе Нижегородской области.',
|
|
||||||
],
|
|
||||||
photoHint: 'Снимайте так, чтобы олень был виден целиком.',
|
|
||||||
background: '/assets/background/nn-bg-iron-deer.svg',
|
|
||||||
audio: '/assets/audio/iron-deer.mp3',
|
|
||||||
achievement: '/assets/achivments/iron-deer.png',
|
|
||||||
model: '/assets/models/iron-deer.glb',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'rozhdestvenskaya',
|
|
||||||
title: 'Рождественская церковь',
|
|
||||||
description:
|
|
||||||
'Пятиглавый нарядный храм в стиле строгановского барокко на улице Рождественской — один из самых декоративных храмов города.',
|
|
||||||
address: 'ул. Рождественская, Нижний Новгород',
|
|
||||||
addressHint: 'Строгановское барокко',
|
|
||||||
coordinates: [43.985, 56.327222],
|
|
||||||
collected: false,
|
|
||||||
geoCheckEnabled: true,
|
|
||||||
geoRadiusMeters: 300,
|
|
||||||
facts: [
|
|
||||||
'Построена в 1696–1719 годах на средства купца Григория Строганова.',
|
|
||||||
'Украшена белокаменной резьбой и восьмигранной колокольней с часами.',
|
|
||||||
'Памятник архитектуры федерального значения; вновь освящена в 1993 году.',
|
|
||||||
],
|
|
||||||
photoHint: 'Снимайте так, чтобы храм был виден целиком.',
|
|
||||||
background: '/assets/background/nn-bg-rozhdestvenskaya.png',
|
|
||||||
audio: '/assets/audio/rozhdestvenskaya.mp3',
|
|
||||||
achievement: '/assets/achivments/rozhdestvenskaya.png',
|
|
||||||
model: '/assets/models/rozhdestvenskaya.glb',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'river-station',
|
|
||||||
title: 'Речной вокзал',
|
|
||||||
description:
|
|
||||||
'Здание речного вокзала на площади Маркина, на самом слиянии Волги и Оки — когда-то главные «водные ворота» города для пассажирских рейсов.',
|
|
||||||
address: 'пл. Маркина, Нижний Новгород',
|
|
||||||
addressHint: 'Слияние Волги и Оки',
|
|
||||||
coordinates: [43.987823, 56.329641],
|
|
||||||
collected: false,
|
|
||||||
geoCheckEnabled: true,
|
|
||||||
geoRadiusMeters: 300,
|
|
||||||
facts: [
|
|
||||||
'Построен в 1964 году по проекту архитектора Чурилина.',
|
|
||||||
'Полностью застеклённый фасад напоминает аквариум; силуэт здания похож на корабль со шпилем вместо мачты.',
|
|
||||||
'Сегодня в здании работает выставочное пространство «Река-Река», вход свободный.',
|
|
||||||
],
|
|
||||||
photoHint: 'Снимайте так, чтобы силуэт вокзала читался целиком.',
|
|
||||||
background: '/assets/background/nn-bg-rechnoy-vokzal.svg',
|
|
||||||
audio: '/assets/audio/river-station.mp3',
|
|
||||||
achievement: '/assets/achivments/river-station.png',
|
|
||||||
model: '/assets/models/river-station.glb',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
@@ -36,3 +36,16 @@
|
|||||||
.nav__item--active {
|
.nav__item--active {
|
||||||
color: var(--color-accent);
|
color: var(--color-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (display-mode: standalone), (display-mode: fullscreen) {
|
||||||
|
.nav {
|
||||||
|
align-items: center;
|
||||||
|
min-height: 0;
|
||||||
|
padding: 4px 12px max(8px, calc(env(safe-area-inset-bottom) - 10px));
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav__item {
|
||||||
|
gap: 2px;
|
||||||
|
padding: 4px 2px 6px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export class BottomNav {
|
|||||||
protected isActive(path: string, exact: boolean): boolean {
|
protected isActive(path: string, exact: boolean): boolean {
|
||||||
const url = this.url();
|
const url = this.url();
|
||||||
if (path === '/') {
|
if (path === '/') {
|
||||||
return url === '/' || url === '/city';
|
return url === '/' || /^\/city\/[^/]+$/.test(url);
|
||||||
}
|
}
|
||||||
if (exact) {
|
if (exact) {
|
||||||
return url === path;
|
return url === path;
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
<button
|
<button
|
||||||
class="city-map__chip"
|
class="city-map__chip"
|
||||||
type="button"
|
type="button"
|
||||||
[attr.aria-label]="'Показать центр: ' + city.name"
|
[attr.aria-label]="'Показать центр: ' + (cityName() || 'Город')"
|
||||||
(click)="focusCity()"
|
(click)="focusCity()"
|
||||||
>
|
>
|
||||||
<app-icon name="pin" [size]="18" />
|
<app-icon name="pin" [size]="18" />
|
||||||
<span>{{ city.name }}</span>
|
<span>{{ cityName() || 'Город' }}</span>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
@if (selected(); as landmark) {
|
@if (selected(); as landmark) {
|
||||||
<div class="city-map__sheet">
|
<div class="city-map__sheet">
|
||||||
<app-map-item-sheet [landmark]="landmark" />
|
<app-map-item-sheet [attraction]="landmark" [areaId]="areaId()" />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -13,15 +13,13 @@ import {
|
|||||||
signal,
|
signal,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { Geolocation, type Position } from '@capacitor/geolocation';
|
import { Geolocation, type Position } from '@capacitor/geolocation';
|
||||||
import { Store } from '@ngrx/store';
|
|
||||||
|
|
||||||
import { MapItemSheet } from '../map-item-sheet/map-item-sheet';
|
import type { Attraction } from '../../areas/area.models';
|
||||||
import { CityCatalogService } from '../../root/services/city-catalog.service';
|
|
||||||
import type { Landmark } from '../../data/nizhny-novgorod';
|
|
||||||
import { Icon } from '../../shared/icon/icon';
|
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';
|
const MAP_KEY = '35e12bfe-922e-4ec1-bb89-ad404cbf8378';
|
||||||
|
const CITY_CENTER: [number, number] = [43.99934, 56.329399];
|
||||||
const CITY_ZOOM = 16;
|
const CITY_ZOOM = 16;
|
||||||
const USER_ZOOM = 20;
|
const USER_ZOOM = 20;
|
||||||
const LANDMARK_SIZE = 40;
|
const LANDMARK_SIZE = 40;
|
||||||
@@ -34,6 +32,7 @@ interface DgPoint {
|
|||||||
|
|
||||||
interface DgMarker {
|
interface DgMarker {
|
||||||
addTo(map: DgMap): this;
|
addTo(map: DgMap): this;
|
||||||
|
remove(): void;
|
||||||
setLatLng(latLng: [number, number]): this;
|
setLatLng(latLng: [number, number]): this;
|
||||||
setZIndexOffset(offset: number): this;
|
setZIndexOffset(offset: number): this;
|
||||||
getElement(): HTMLElement | undefined;
|
getElement(): HTMLElement | undefined;
|
||||||
@@ -135,8 +134,6 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
@ViewChild('map', { static: true })
|
@ViewChild('map', { static: true })
|
||||||
private mapElement!: ElementRef<HTMLElement>;
|
private mapElement!: ElementRef<HTMLElement>;
|
||||||
|
|
||||||
private readonly catalog = inject(CityCatalogService);
|
|
||||||
private readonly store = inject(Store);
|
|
||||||
private readonly zone = inject(NgZone);
|
private readonly zone = inject(NgZone);
|
||||||
private raster: DgApi | null = null;
|
private raster: DgApi | null = null;
|
||||||
private map: DgMap | null = null;
|
private map: DgMap | null = null;
|
||||||
@@ -152,7 +149,8 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
private readonly clippedAncestors: HTMLElement[] = [];
|
private readonly clippedAncestors: HTMLElement[] = [];
|
||||||
private readonly markerElements = new Map<string, HTMLElement>();
|
private readonly markerElements = new Map<string, HTMLElement>();
|
||||||
private readonly markers = new Map<string, DgMarker>();
|
private readonly markers = new Map<string, DgMarker>();
|
||||||
private readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
private readonly mapReady = signal(false);
|
||||||
|
private placedKey = '';
|
||||||
private readonly stopFollowing = (): void => {
|
private readonly stopFollowing = (): void => {
|
||||||
this.programmaticMove = false;
|
this.programmaticMove = false;
|
||||||
this.zone.run(() => this.following.set(false));
|
this.zone.run(() => this.following.set(false));
|
||||||
@@ -169,19 +167,23 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
};
|
};
|
||||||
|
|
||||||
readonly embedded = input(false);
|
readonly embedded = input(false);
|
||||||
|
readonly cityName = input('');
|
||||||
|
readonly areaId = input('');
|
||||||
|
readonly attractions = input<Attraction[]>([]);
|
||||||
|
|
||||||
protected readonly city = this.catalog.city;
|
protected readonly selected = signal<Attraction | null>(null);
|
||||||
protected readonly selected = signal<Landmark | null>(null);
|
|
||||||
protected readonly following = signal(false);
|
protected readonly following = signal(false);
|
||||||
protected readonly fullscreen = signal(false);
|
protected readonly fullscreen = signal(false);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
const ids = this.collectedIds();
|
const items = this.attractions();
|
||||||
|
|
||||||
for (const [id, element] of this.markerElements) {
|
if (!this.mapReady()) {
|
||||||
this.setMarkerIcon(element, ids.has(id));
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.placeMarkers(items);
|
||||||
});
|
});
|
||||||
|
|
||||||
effect(() => {
|
effect(() => {
|
||||||
@@ -210,7 +212,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const map = raster.map(this.mapElement.nativeElement, {
|
const map = raster.map(this.mapElement.nativeElement, {
|
||||||
center: this.toLatLng(this.city.center),
|
center: this.toLatLng(this.focusCenter(this.attractions())),
|
||||||
zoom: CITY_ZOOM,
|
zoom: CITY_ZOOM,
|
||||||
key: MAP_KEY,
|
key: MAP_KEY,
|
||||||
currentLang: 'ru',
|
currentLang: 'ru',
|
||||||
@@ -228,14 +230,9 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
this.map = map;
|
this.map = map;
|
||||||
map.on('dragstart', this.stopFollowing);
|
map.on('dragstart', this.stopFollowing);
|
||||||
map.on('zoomstart', this.onZoomStart);
|
map.on('zoomstart', this.onZoomStart);
|
||||||
map.on('zoom', () => this.syncRadiusSize());
|
|
||||||
map.on('move', () => this.syncRadiusSize());
|
|
||||||
map.on('moveend', this.onMoveEnd);
|
map.on('moveend', this.onMoveEnd);
|
||||||
|
|
||||||
for (const landmark of this.city.objects) {
|
this.zone.run(() => this.mapReady.set(true));
|
||||||
this.markers.set(landmark.id, this.createMarker(raster, map, landmark));
|
|
||||||
}
|
|
||||||
|
|
||||||
requestAnimationFrame(() => this.resizeMap());
|
requestAnimationFrame(() => this.resizeMap());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -268,7 +265,7 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
protected focusCity(): void {
|
protected focusCity(): void {
|
||||||
this.following.set(false);
|
this.following.set(false);
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
this.moveMap(this.city.center, CITY_ZOOM, 500);
|
this.moveMap(this.focusCenter(this.attractions()), CITY_ZOOM, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async locate(): Promise<void> {
|
protected async locate(): Promise<void> {
|
||||||
@@ -364,25 +361,72 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
this.watchId = null;
|
this.watchId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private createMarker(api: DgApi, map: DgMap, landmark: Landmark): DgMarker {
|
private placeMarkers(items: Attraction[]): void {
|
||||||
|
const map = this.map;
|
||||||
|
const api = this.raster;
|
||||||
|
|
||||||
|
if (!map || !api) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = items.map((item) => `${item.id}:${item.latitude}:${item.longitude}`).join('|');
|
||||||
|
|
||||||
|
if (key === this.placedKey) {
|
||||||
|
for (const item of items) {
|
||||||
|
const element = this.markerElements.get(item.id);
|
||||||
|
|
||||||
|
if (element) {
|
||||||
|
this.setMarkerIcon(element, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const marker of this.markers.values()) {
|
||||||
|
marker.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.markers.clear();
|
||||||
|
this.markerElements.clear();
|
||||||
|
this.placedKey = key;
|
||||||
|
|
||||||
|
for (const item of items) {
|
||||||
|
if (typeof item.latitude !== 'number' || typeof item.longitude !== 'number') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.markers.set(item.id, this.createMarker(api, map, item));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.markers.size > 0) {
|
||||||
|
this.moveMap(this.focusCenter(items), CITY_ZOOM, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private createMarker(api: DgApi, map: DgMap, item: Attraction): DgMarker {
|
||||||
const markerElement = document.createElement('button');
|
const markerElement = document.createElement('button');
|
||||||
markerElement.type = 'button';
|
markerElement.type = 'button';
|
||||||
markerElement.className = 'city-map__marker';
|
markerElement.className = 'city-map__marker';
|
||||||
markerElement.setAttribute('aria-label', landmark.title);
|
markerElement.setAttribute('aria-label', item.name);
|
||||||
markerElement.innerHTML = `<span class="city-map__radius"></span><img width="40" height="40" alt="" /><span class="city-map__label"></span>`;
|
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');
|
const label = markerElement.querySelector('.city-map__label');
|
||||||
|
|
||||||
if (label) {
|
if (label) {
|
||||||
label.textContent = landmark.title;
|
label.textContent = item.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.markerElements.set(landmark.id, markerElement);
|
this.markerElements.set(item.id, markerElement);
|
||||||
this.setMarkerIcon(markerElement, this.collectedIds().has(landmark.id));
|
this.setMarkerIcon(markerElement, item);
|
||||||
|
|
||||||
const marker = this.addHtmlMarker(
|
const marker = this.addHtmlMarker(
|
||||||
api,
|
api,
|
||||||
map,
|
map,
|
||||||
landmark.coordinates,
|
[item.longitude, item.latitude],
|
||||||
markerElement,
|
markerElement,
|
||||||
LANDMARK_SIZE,
|
LANDMARK_SIZE,
|
||||||
1,
|
1,
|
||||||
@@ -390,12 +434,27 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
|
|
||||||
marker.on('click', () => {
|
marker.on('click', () => {
|
||||||
this.zone.run(() => this.selectLandmark(landmark));
|
this.zone.run(() => this.selectLandmark(item));
|
||||||
});
|
});
|
||||||
|
|
||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private focusCenter(items: Attraction[]): [number, number] {
|
||||||
|
const points = items.filter(
|
||||||
|
(item) => typeof item.latitude === 'number' && typeof item.longitude === 'number',
|
||||||
|
);
|
||||||
|
|
||||||
|
if (points.length === 0) {
|
||||||
|
return CITY_CENTER;
|
||||||
|
}
|
||||||
|
|
||||||
|
const longitude = points.reduce((sum, item) => sum + item.longitude, 0) / points.length;
|
||||||
|
const latitude = points.reduce((sum, item) => sum + item.latitude, 0) / points.length;
|
||||||
|
|
||||||
|
return [longitude, latitude];
|
||||||
|
}
|
||||||
|
|
||||||
private addHtmlMarker(
|
private addHtmlMarker(
|
||||||
api: DgApi,
|
api: DgApi,
|
||||||
map: DgMap,
|
map: DgMap,
|
||||||
@@ -427,27 +486,26 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
private setMarkerIcon(element: HTMLElement, collected: boolean): void {
|
private setMarkerIcon(element: HTMLElement, item: Attraction): void {
|
||||||
const img = element.querySelector('img');
|
const img = element.querySelector('img');
|
||||||
|
|
||||||
if (!img) {
|
if (!img) {
|
||||||
return;
|
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) {
|
if (img.getAttribute('src') !== src) {
|
||||||
img.setAttribute('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: Landmark): void {
|
private selectLandmark(landmark: Attraction): void {
|
||||||
const alreadySelected = this.selected()?.id === landmark.id;
|
const alreadySelected = this.selected()?.id === landmark.id;
|
||||||
this.selected.set(alreadySelected ? null : landmark);
|
this.selected.set(alreadySelected ? null : landmark);
|
||||||
this.syncSelection();
|
this.syncSelection();
|
||||||
this.syncRadiusSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private clearSelection(): void {
|
private clearSelection(): void {
|
||||||
@@ -465,36 +523,6 @@ export class CityMap implements AfterViewInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private syncRadiusSize(): void {
|
|
||||||
const selected = this.selected();
|
|
||||||
const map = this.map;
|
|
||||||
|
|
||||||
if (!selected || !map) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const element = this.markerElements.get(selected.id);
|
|
||||||
|
|
||||||
if (!element) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const diameter = this.metersToPixels(map, selected.geoRadiusMeters, selected.coordinates) * 2;
|
|
||||||
element.style.setProperty('--radius-px', `${diameter}px`);
|
|
||||||
}
|
|
||||||
|
|
||||||
private metersToPixels(map: DgMap, meters: number, coordinates: [number, number]): number {
|
|
||||||
const [longitude, latitude] = coordinates;
|
|
||||||
const origin = map.latLngToContainerPoint(this.toLatLng(coordinates));
|
|
||||||
const metersPerDegree = 111_320 * Math.cos((latitude * Math.PI) / 180);
|
|
||||||
const shifted = map.latLngToContainerPoint([
|
|
||||||
latitude,
|
|
||||||
longitude + meters / Math.max(metersPerDegree, 1),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return Math.hypot(shifted.x - origin.x, shifted.y - origin.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
private moveMap(center: [number, number], zoom: number | null, durationMs: number): void {
|
private moveMap(center: [number, number], zoom: number | null, durationMs: number): void {
|
||||||
const map = this.map;
|
const map = this.map;
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,25 @@
|
|||||||
<article class="card">
|
<article class="card">
|
||||||
<div class="card__row">
|
@let lockIcon = '/assets/icons/cell-lock.svg';
|
||||||
<img class="card__stamp" src="/assets/icons/cell-lock.svg" alt="" width="72" height="72" />
|
<div class="card__row" [style.margin-bottom]="attraction().visited ? '0' : '16px'">
|
||||||
|
<img
|
||||||
|
class="card__stamp"
|
||||||
|
[src]="!attraction().visited ? lockIcon : attraction().iconUrl || lockIcon"
|
||||||
|
alt="icon"
|
||||||
|
width="72"
|
||||||
|
height="72"
|
||||||
|
/>
|
||||||
|
|
||||||
<div class="card__info">
|
<div class="card__info">
|
||||||
<h2>{{ landmark().title }}</h2>
|
<h2>{{ attraction().name }}</h2>
|
||||||
|
|
||||||
<p class="card__status">
|
<p class="card__status">
|
||||||
<app-icon name="lock" [size]="16" />
|
<app-icon [name]="attraction().visited ? 'check' : 'lock'" [size]="16" />
|
||||||
Не получен
|
{{ attraction().visited ? 'Получен' : 'Не получен' }}
|
||||||
</p>
|
|
||||||
|
|
||||||
<p class="card__geo">
|
|
||||||
<app-icon name="check" [size]="16" />
|
|
||||||
Вы в радиусе {{ landmark().geoRadiusMeters }} м — можно забирать
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a class="card__action" matButton="filled" [routerLink]="['/items', landmark().id]">
|
@if (!attraction().visited) {
|
||||||
Открыть карточку
|
<a class="btn" [routerLink]="['/city', areaId(), attraction().id]">Открыть карточку</a>
|
||||||
</a>
|
}
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
margin-bottom: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.card__stamp {
|
.card__stamp {
|
||||||
@@ -51,9 +50,3 @@
|
|||||||
color: var(--color-success);
|
color: var(--color-success);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card__action {
|
|
||||||
width: 100%;
|
|
||||||
min-height: 52px;
|
|
||||||
--mat-button-filled-container-shape: 16px;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
||||||
import { MatButton } from '@angular/material/button';
|
|
||||||
import { RouterLink } from '@angular/router';
|
import { RouterLink } from '@angular/router';
|
||||||
|
|
||||||
import type { Landmark } from '../../data/nizhny-novgorod';
|
import type { Attraction } from '../../areas/area.models';
|
||||||
import { Icon } from '../../shared/icon/icon';
|
import { Icon } from '../../shared/icon/icon';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-map-item-sheet',
|
selector: 'app-map-item-sheet',
|
||||||
imports: [MatButton, Icon, RouterLink],
|
imports: [Icon, RouterLink],
|
||||||
templateUrl: './map-item-sheet.html',
|
templateUrl: './map-item-sheet.html',
|
||||||
styleUrl: './map-item-sheet.scss',
|
styleUrl: './map-item-sheet.scss',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class MapItemSheet {
|
export class MapItemSheet {
|
||||||
readonly landmark = input.required<Landmark>();
|
readonly attraction = input.required<Attraction>();
|
||||||
|
readonly areaId = input('');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,50 +4,79 @@
|
|||||||
<p>Приезжайте на место, снимайте — объект попадёт в вашу коллекцию.</p>
|
<p>Приезжайте на место, снимайте — объект попадёт в вашу коллекцию.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if (status() === 'loading' && areas().length === 0) {
|
||||||
|
<p class="cities__status">Загружаем города…</p>
|
||||||
|
} @else if (status() === 'error' && areas().length === 0) {
|
||||||
|
<p class="cities__status">{{ error() }}</p>
|
||||||
|
<button type="button" (click)="reload()">Повторить</button>
|
||||||
|
}
|
||||||
|
|
||||||
<div class="cities">
|
<div class="cities">
|
||||||
<a class="city-card" routerLink="/city" [attr.aria-label]="city.name">
|
@for (area of areas(); track area.id) {
|
||||||
<div class="city-card__top">
|
@if (area.attractions.length === 0) {
|
||||||
<div>
|
<article class="city-card city-card--soon">
|
||||||
<h2>{{ city.name }}</h2>
|
<h2>{{ area.name }}</h2>
|
||||||
<p>
|
<p>Скоро появится</p>
|
||||||
Открыто
|
</article>
|
||||||
<strong>{{ openedCount() }} из {{ totalCount }}</strong>
|
} @else {
|
||||||
объектов
|
<a class="city-card" [routerLink]="['/city', area.id]" [attr.aria-label]="area.name">
|
||||||
</p>
|
<div class="city-card__top">
|
||||||
</div>
|
<div>
|
||||||
|
<h2>{{ area.name }}</h2>
|
||||||
|
<p>
|
||||||
|
Открыто
|
||||||
|
<strong>{{ openedCount(area) }} из {{ totalCount(area) }}</strong>
|
||||||
|
объектов
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="city-card__percent" aria-hidden="true">{{ progress() }}%</div>
|
<div
|
||||||
</div>
|
class="pack__percent anim-percent"
|
||||||
|
[style.--to-p]="progress(area)"
|
||||||
|
aria-hidden="true"
|
||||||
|
>
|
||||||
|
<span>{{ progress(area) }}%</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<mat-progress-bar mode="determinate" [value]="progress()" />
|
<div class="pack__bar" aria-hidden="true">
|
||||||
|
<span
|
||||||
|
class="anim-grow"
|
||||||
|
[style.--from]="'0%'"
|
||||||
|
[style.--to]="progress(area) + '%'"
|
||||||
|
></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="city-card__cells">
|
<div class="city-card__cells">
|
||||||
@for (landmark of city.objects; track landmark.id) {
|
@for (attraction of area.attractions; track attraction.id) {
|
||||||
<span
|
<span
|
||||||
class="cell"
|
class="cell"
|
||||||
[class.cell--open]="collectedIds().has(landmark.id)"
|
[class.cell--open]="obtained(attraction)"
|
||||||
[attr.aria-label]="
|
[attr.aria-label]="
|
||||||
landmark.title + (collectedIds().has(landmark.id) ? ', получено' : ', не получен')
|
attraction.name + (obtained(attraction) ? ', получено' : ', не получен')
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<img
|
@if (obtained(attraction) && attraction.iconUrl) {
|
||||||
[src]="
|
<img [src]="attraction?.iconUrl" alt="" />
|
||||||
collectedIds().has(landmark.id)
|
} @else {
|
||||||
? landmark.achievement
|
<div
|
||||||
: '/assets/icons/cell-lock.svg'
|
class="icon-wrapper"
|
||||||
"
|
[class.disable-icon]="!obtained(attraction) && attraction.iconUrl"
|
||||||
[alt]=""
|
>
|
||||||
/>
|
<img
|
||||||
</span>
|
class="main-icon"
|
||||||
}
|
[src]="attraction?.iconUrl || '/assets/icons/cell-lock.svg'"
|
||||||
</div>
|
alt=""
|
||||||
</a>
|
/>
|
||||||
|
|
||||||
@for (name of upcomingCities; track name) {
|
<img class="lock-icon" src="/assets/icons/cell-lock-line.svg" alt="" />
|
||||||
<article class="city-card city-card--soon">
|
</div>
|
||||||
<h2>{{ name }}</h2>
|
}
|
||||||
<p>Скоро появится</p>
|
</span>
|
||||||
</article>
|
}
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -105,27 +105,13 @@
|
|||||||
margin-bottom: 14px;
|
margin-bottom: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.city-card strong,
|
.city-card strong {
|
||||||
.city-card__percent {
|
|
||||||
color: var(--color-text);
|
color: var(--color-text);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.city-card__percent {
|
.city-card .pack__bar {
|
||||||
display: flex;
|
margin-top: 0;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 60px;
|
|
||||||
height: 60px;
|
|
||||||
border: 5px solid var(--color-surface-2);
|
|
||||||
border-radius: 50%;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.city-card mat-progress-bar {
|
|
||||||
--mdc-linear-progress-active-indicator-color: var(--color-accent);
|
|
||||||
--mdc-linear-progress-track-color: var(--color-surface-2);
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.city-card__cells {
|
.city-card__cells {
|
||||||
@@ -143,6 +129,7 @@
|
|||||||
border: 0;
|
border: 0;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
background: #171512;
|
background: #171512;
|
||||||
|
|
||||||
color: inherit;
|
color: inherit;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -156,7 +143,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.cell--open {
|
.cell--open {
|
||||||
background: rgb(224 184 79 / 10%);
|
background: rgb(224 184 79 / 10%) !important;
|
||||||
box-shadow: inset 0 0 0 1.5px var(--color-accent);
|
box-shadow: inset 0 0 0 1.5px var(--color-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,3 +186,42 @@
|
|||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-wrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
aspect-ratio: 1;
|
||||||
|
|
||||||
|
.main-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
|
||||||
|
width: 70.833%;
|
||||||
|
height: 70.833%;
|
||||||
|
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lock-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 49%;
|
||||||
|
left: 50.4%;
|
||||||
|
width: 95%;
|
||||||
|
height: 96%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.disable-icon {
|
||||||
|
.main-icon {
|
||||||
|
filter: brightness(0);
|
||||||
|
opacity: 0.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lock-icon {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,26 +1,46 @@
|
|||||||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
||||||
import { MatProgressBar } from '@angular/material/progress-bar';
|
|
||||||
import { RouterLink } from '@angular/router';
|
import { RouterLink } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
import { CityCatalogService } from '../../root/services/city-catalog.service';
|
import {
|
||||||
import { selectCollectedIdSet, selectOpenedCount, selectProgress } from '../../state';
|
areaOpenedCount,
|
||||||
|
areaProgress,
|
||||||
|
areaTotalCount,
|
||||||
|
type Area,
|
||||||
|
type Attraction,
|
||||||
|
} from '../../areas/area.models';
|
||||||
|
import { GorodarActions, selectAreas, selectAreasError, selectAreasStatus } from '../../state';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-cities-page',
|
selector: 'app-cities-page',
|
||||||
imports: [RouterLink, MatProgressBar],
|
imports: [RouterLink],
|
||||||
templateUrl: './cities-page.html',
|
templateUrl: './cities-page.html',
|
||||||
styleUrl: './cities-page.scss',
|
styleUrl: './cities-page.scss',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class CitiesPage {
|
export class CitiesPage {
|
||||||
private readonly catalog = inject(CityCatalogService);
|
|
||||||
private readonly store = inject(Store);
|
private readonly store = inject(Store);
|
||||||
|
|
||||||
protected readonly city = this.catalog.city;
|
protected readonly areas = this.store.selectSignal(selectAreas);
|
||||||
protected readonly upcomingCities = ['Москва', 'Санкт-Петербург'];
|
protected readonly status = this.store.selectSignal(selectAreasStatus);
|
||||||
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
protected readonly error = this.store.selectSignal(selectAreasError);
|
||||||
protected readonly openedCount = this.store.selectSignal(selectOpenedCount);
|
protected openedCount(area: Area): number {
|
||||||
protected readonly totalCount = this.city.objects.length;
|
return areaOpenedCount(area);
|
||||||
protected readonly progress = this.store.selectSignal(selectProgress);
|
}
|
||||||
|
|
||||||
|
protected totalCount(area: Area): number {
|
||||||
|
return areaTotalCount(area);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected progress(area: Area): number {
|
||||||
|
return areaProgress(area);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected obtained(attraction: Attraction): boolean {
|
||||||
|
return attraction.visited;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected reload(): void {
|
||||||
|
this.store.dispatch(GorodarActions.areasRequested());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,118 +5,141 @@
|
|||||||
</a>
|
</a>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="page__city">
|
@if (area(); as city) {
|
||||||
<img src="/assets/icons/gorodar-mark.svg" alt="" width="96" height="96" />
|
<div class="page__city">
|
||||||
<div>
|
<img src="/assets/icons/gorodar-mark.svg" alt="" width="96" height="96" />
|
||||||
<h1>{{ city.name }}</h1>
|
<div>
|
||||||
<p>
|
<h1>{{ city.name }}</h1>
|
||||||
<app-icon name="pin" [size]="18" />
|
<p>
|
||||||
<span>
|
<app-icon name="pin" [size]="18" />
|
||||||
<b>{{ openedCount() }}/{{ city.objects.length }}</b>
|
<span>
|
||||||
объектов
|
<b>{{ openedCount() }}/{{ totalCount() }}</b>
|
||||||
</span>
|
объектов
|
||||||
<span>·</span>
|
</span>
|
||||||
<b>{{ progress() }}%</b>
|
<span>·</span>
|
||||||
</p>
|
<b>{{ progress() }}%</b>
|
||||||
<div class="page__progress" aria-hidden="true">
|
</p>
|
||||||
<span [style.width.%]="progress()"></span>
|
<div class="page__progress" aria-hidden="true">
|
||||||
|
<span [style.width.%]="progress()"></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<nav class="tabs" aria-label="Разделы города">
|
<nav class="tabs" aria-label="Разделы города">
|
||||||
<button
|
<button
|
||||||
class="tabs__item"
|
class="tabs__item"
|
||||||
type="button"
|
type="button"
|
||||||
[class.tabs__item--active]="tab() === 'objects'"
|
[class.tabs__item--active]="tab() === 'objects'"
|
||||||
(click)="openObjects()"
|
(click)="openObjects()"
|
||||||
>
|
>
|
||||||
Объекты
|
Объекты
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="tabs__item"
|
class="tabs__item"
|
||||||
type="button"
|
type="button"
|
||||||
[class.tabs__item--active]="tab() === 'map'"
|
[class.tabs__item--active]="tab() === 'map'"
|
||||||
(click)="openMap()"
|
(click)="openMap()"
|
||||||
>
|
>
|
||||||
На карте
|
На карте
|
||||||
</button>
|
</button>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
@if (tab() === 'objects') {
|
@if (tab() === 'objects' && totalCount() === 0) {
|
||||||
<div class="filters">
|
<p class="page__status">В этом городе пока нет объектов.</p>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
[class.filters__item--active]="filter() === 'all'"
|
|
||||||
(click)="filter.set('all')"
|
|
||||||
>
|
|
||||||
Все · {{ city.objects.length }}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
[class.filters__item--active]="filter() === 'open'"
|
|
||||||
(click)="filter.set('open')"
|
|
||||||
>
|
|
||||||
Открыты · {{ openedCount() }}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
[class.filters__item--active]="filter() === 'closed'"
|
|
||||||
(click)="filter.set('closed')"
|
|
||||||
>
|
|
||||||
Закрыты · {{ closedCount() }}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid">
|
|
||||||
@for (landmark of landmarks(); track landmark.id) {
|
|
||||||
<a class="card" [routerLink]="objectRoute(landmark.id)">
|
|
||||||
<div class="card__preview" [class.card__preview--open]="collectedIds().has(landmark.id)">
|
|
||||||
@if (collectedIds().has(landmark.id)) {
|
|
||||||
<svg class="card__rays" viewBox="0 0 112 112" aria-hidden="true">
|
|
||||||
@for (ray of rays; track $index) {
|
|
||||||
<line
|
|
||||||
[attr.x1]="ray.x1"
|
|
||||||
[attr.y1]="ray.y1"
|
|
||||||
[attr.x2]="ray.x2"
|
|
||||||
[attr.y2]="ray.y2"
|
|
||||||
stroke="#E0B84F"
|
|
||||||
[attr.stroke-width]="ray.strong ? 2 : 1.2"
|
|
||||||
[attr.opacity]="ray.strong ? 0.55 : 0.28"
|
|
||||||
stroke-linecap="round"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
</svg>
|
|
||||||
<span class="card__spark card__spark--a"></span>
|
|
||||||
<span class="card__spark card__spark--b"></span>
|
|
||||||
<span class="card__spark card__spark--c"></span>
|
|
||||||
<span class="card__spark card__spark--d"></span>
|
|
||||||
}
|
|
||||||
<img
|
|
||||||
[src]="
|
|
||||||
collectedIds().has(landmark.id)
|
|
||||||
? landmark.achievement
|
|
||||||
: '/assets/icons/cell-lock.svg'
|
|
||||||
"
|
|
||||||
alt=""
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div class="card__body">
|
|
||||||
<h2>{{ landmark.title }}</h2>
|
|
||||||
<span class="card__status" [class.card__status--open]="collectedIds().has(landmark.id)">
|
|
||||||
<app-icon [name]="collectedIds().has(landmark.id) ? 'check' : 'lock'" [size]="15" />
|
|
||||||
{{ collectedIds().has(landmark.id) ? 'Получен' : 'Не получен' }}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<span class="card__bar" [class.card__bar--open]="collectedIds().has(landmark.id)"></span>
|
|
||||||
</a>
|
|
||||||
}
|
}
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (mapReady()) {
|
@if (tab() === 'objects' && totalCount() > 0) {
|
||||||
<div class="page__map" [class.page__map--off]="tab() !== 'map'">
|
<div class="filters">
|
||||||
<app-city-map [embedded]="true" />
|
<button
|
||||||
</div>
|
type="button"
|
||||||
|
[class.filters__item--active]="filter() === 'all'"
|
||||||
|
(click)="filter.set('all')"
|
||||||
|
>
|
||||||
|
Все · {{ totalCount() }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
[class.filters__item--active]="filter() === 'open'"
|
||||||
|
(click)="filter.set('open')"
|
||||||
|
>
|
||||||
|
Открыты · {{ openedCount() }}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
[class.filters__item--active]="filter() === 'closed'"
|
||||||
|
(click)="filter.set('closed')"
|
||||||
|
>
|
||||||
|
Закрыты · {{ closedCount() }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="grid">
|
||||||
|
@for (landmark of landmarks(); track landmark.id) {
|
||||||
|
<a class="card" [routerLink]="objectRoute(landmark.id)">
|
||||||
|
<div class="card__preview" [class.card__preview--open]="isOpen(landmark)">
|
||||||
|
@if (isOpen(landmark)) {
|
||||||
|
<svg class="card__rays" viewBox="0 0 112 112" aria-hidden="true">
|
||||||
|
@for (ray of rays; track $index) {
|
||||||
|
<line
|
||||||
|
[attr.x1]="ray.x1"
|
||||||
|
[attr.y1]="ray.y1"
|
||||||
|
[attr.x2]="ray.x2"
|
||||||
|
[attr.y2]="ray.y2"
|
||||||
|
stroke="#E0B84F"
|
||||||
|
[attr.stroke-width]="ray.strong ? 2 : 1.2"
|
||||||
|
[attr.opacity]="ray.strong ? 0.55 : 0.28"
|
||||||
|
stroke-linecap="round"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
</svg>
|
||||||
|
<span class="card__spark card__spark--a"></span>
|
||||||
|
<span class="card__spark card__spark--b"></span>
|
||||||
|
<span class="card__spark card__spark--c"></span>
|
||||||
|
<span class="card__spark card__spark--d"></span>
|
||||||
|
}
|
||||||
|
@if (isOpen(landmark) && landmark?.iconUrl) {
|
||||||
|
<img [src]="landmark?.iconUrl" alt="" />
|
||||||
|
} @else {
|
||||||
|
<div
|
||||||
|
class="icon-wrapper"
|
||||||
|
[class.disable-icon]="!isOpen(landmark) && landmark?.iconUrl"
|
||||||
|
>
|
||||||
|
<img
|
||||||
|
class="main-icon"
|
||||||
|
[src]="landmark?.iconUrl || '/assets/icons/cell-lock.svg'"
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
|
||||||
|
<img class="lock-icon" src="/assets/icons/cell-lock-line.svg" alt="" />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="card__body">
|
||||||
|
<h2>{{ landmark.name }}</h2>
|
||||||
|
<span class="card__status" [class.card__status--open]="isOpen(landmark)">
|
||||||
|
<app-icon [name]="isOpen(landmark) ? 'check' : 'lock'" [size]="15" />
|
||||||
|
{{ isOpen(landmark) ? 'Получен' : 'Не получен' }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span class="card__bar" [class.card__bar--open]="isOpen(landmark)"></span>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (mapReady()) {
|
||||||
|
<div class="page__map" [class.page__map--off]="tab() !== 'map'">
|
||||||
|
<app-city-map
|
||||||
|
[embedded]="true"
|
||||||
|
[cityName]="city.name"
|
||||||
|
[areaId]="areaId()"
|
||||||
|
[attractions]="mapAttractions()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
} @else if (status() === 'loading') {
|
||||||
|
<p class="page__status">Загружаем город…</p>
|
||||||
|
} @else {
|
||||||
|
<p class="page__status">{{ error() || 'Город не найден.' }}</p>
|
||||||
}
|
}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -175,9 +175,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.filters button.filters__item--active {
|
.filters button.filters__item--active {
|
||||||
border-color: var(--color-accent);
|
border-color: var(--color-primary);
|
||||||
background: var(--color-accent);
|
background: var(--color-primary);
|
||||||
color: var(--color-on-accent);
|
color: var(--color-label);
|
||||||
}
|
}
|
||||||
|
|
||||||
.grid {
|
.grid {
|
||||||
@@ -205,8 +205,6 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
height: 112px;
|
height: 112px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background:
|
|
||||||
radial-gradient(circle at 50% 42%, rgb(255 255 255 / 5%), rgb(255 255 255 / 0%) 70%), #1a1815;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.card__preview img {
|
.card__preview img {
|
||||||
@@ -215,6 +213,7 @@
|
|||||||
width: 96px;
|
width: 96px;
|
||||||
height: 96px;
|
height: 96px;
|
||||||
object-fit: contain;
|
object-fit: contain;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card__rays {
|
.card__rays {
|
||||||
@@ -273,21 +272,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (hover: none) {
|
|
||||||
.card:active .card__preview--open .card__rays {
|
|
||||||
opacity: 1;
|
|
||||||
animation: spin 12s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card:active .card__preview--open img {
|
|
||||||
animation: pop 0.9s cubic-bezier(0.2, 0.9, 0.3, 1.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.card:active .card__preview--open .card__spark {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.card__body {
|
.card__body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@@ -329,3 +313,50 @@
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.icon-wrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 112px;
|
||||||
|
height: 112px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
|
.main-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lock-icon {
|
||||||
|
position: absolute;
|
||||||
|
top: 47%;
|
||||||
|
left: 48%;
|
||||||
|
|
||||||
|
width: 103px;
|
||||||
|
height: 108px;
|
||||||
|
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.disable-icon {
|
||||||
|
.main-icon {
|
||||||
|
filter: brightness(0);
|
||||||
|
opacity: 0.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lock-icon {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&:not(.disable-icon) .main-icon {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,11 +1,31 @@
|
|||||||
import { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';
|
import {
|
||||||
|
ChangeDetectionStrategy,
|
||||||
|
Component,
|
||||||
|
computed,
|
||||||
|
effect,
|
||||||
|
inject,
|
||||||
|
input,
|
||||||
|
signal,
|
||||||
|
} from '@angular/core';
|
||||||
import { RouterLink } from '@angular/router';
|
import { RouterLink } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
|
import {
|
||||||
|
areaAttractions,
|
||||||
|
areaOpenedCount,
|
||||||
|
areaProgress,
|
||||||
|
areaTotalCount,
|
||||||
|
findAttraction,
|
||||||
|
type Attraction,
|
||||||
|
} from '../../areas/area.models';
|
||||||
import { CityMap } from '../../map/city-map/city-map';
|
import { CityMap } from '../../map/city-map/city-map';
|
||||||
import { CityCatalogService } from '../../root/services/city-catalog.service';
|
|
||||||
import { Icon } from '../../shared/icon/icon';
|
import { Icon } from '../../shared/icon/icon';
|
||||||
import { selectCollectedIdSet, selectOpenedCount, selectProgress } from '../../state';
|
import {
|
||||||
|
GorodarActions,
|
||||||
|
selectAreaDetailError,
|
||||||
|
selectAreaDetails,
|
||||||
|
selectAreaDetailStatus,
|
||||||
|
} from '../../state';
|
||||||
|
|
||||||
type CollectionFilter = 'all' | 'open' | 'closed';
|
type CollectionFilter = 'all' | 'open' | 'closed';
|
||||||
type CityTab = 'objects' | 'map';
|
type CityTab = 'objects' | 'map';
|
||||||
@@ -18,26 +38,45 @@ type CityTab = 'objects' | 'map';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class CityPage {
|
export class CityPage {
|
||||||
private readonly catalog = inject(CityCatalogService);
|
|
||||||
private readonly store = inject(Store);
|
private readonly store = inject(Store);
|
||||||
|
|
||||||
protected readonly city = this.catalog.city;
|
readonly areaId = input.required<string>();
|
||||||
|
|
||||||
|
private readonly details = this.store.selectSignal(selectAreaDetails);
|
||||||
|
private readonly detailStatus = this.store.selectSignal(selectAreaDetailStatus);
|
||||||
|
private readonly detailError = this.store.selectSignal(selectAreaDetailError);
|
||||||
|
protected readonly status = computed(() => this.detailStatus()[this.areaId()] ?? 'loading');
|
||||||
|
protected readonly error = computed(() => this.detailError()[this.areaId()] ?? '');
|
||||||
|
protected readonly area = computed(() => this.details()[this.areaId()] ?? null);
|
||||||
protected readonly tab = signal<CityTab>('objects');
|
protected readonly tab = signal<CityTab>('objects');
|
||||||
protected readonly mapReady = signal(false);
|
protected readonly mapReady = signal(false);
|
||||||
protected readonly filter = signal<CollectionFilter>('all');
|
protected readonly filter = signal<CollectionFilter>('all');
|
||||||
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
protected readonly openedCount = computed(() => {
|
||||||
protected readonly openedCount = this.store.selectSignal(selectOpenedCount);
|
const area = this.area();
|
||||||
protected readonly progress = this.store.selectSignal(selectProgress);
|
return area ? areaOpenedCount(area) : 0;
|
||||||
protected readonly closedCount = computed(() => this.city.objects.length - this.openedCount());
|
});
|
||||||
|
protected readonly totalCount = computed(() => {
|
||||||
|
const area = this.area();
|
||||||
|
return area ? areaTotalCount(area) : 0;
|
||||||
|
});
|
||||||
|
protected readonly progress = computed(() => {
|
||||||
|
const area = this.area();
|
||||||
|
return area ? areaProgress(area) : 0;
|
||||||
|
});
|
||||||
|
protected readonly closedCount = computed(() => this.totalCount() - this.openedCount());
|
||||||
|
protected readonly mapAttractions = computed(() => {
|
||||||
|
const area = this.area();
|
||||||
|
return area ? areaAttractions(area) : [];
|
||||||
|
});
|
||||||
protected readonly landmarks = computed(() => {
|
protected readonly landmarks = computed(() => {
|
||||||
const items = this.city.objects;
|
const current = this.area();
|
||||||
const ids = this.collectedIds();
|
const items = current ? areaAttractions(current) : [];
|
||||||
|
|
||||||
switch (this.filter()) {
|
switch (this.filter()) {
|
||||||
case 'open':
|
case 'open':
|
||||||
return items.filter((item) => ids.has(item.id));
|
return items.filter((item) => item.visited);
|
||||||
case 'closed':
|
case 'closed':
|
||||||
return items.filter((item) => !ids.has(item.id));
|
return items.filter((item) => !item.visited);
|
||||||
default:
|
default:
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
@@ -58,6 +97,12 @@ export class CityPage {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
effect(() => {
|
||||||
|
this.store.dispatch(GorodarActions.areaRequested({ id: this.areaId() }));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected openObjects(): void {
|
protected openObjects(): void {
|
||||||
this.tab.set('objects');
|
this.tab.set('objects');
|
||||||
}
|
}
|
||||||
@@ -67,7 +112,15 @@ export class CityPage {
|
|||||||
this.tab.set('map');
|
this.tab.set('map');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected isOpen(attraction: Attraction): boolean {
|
||||||
|
return attraction.visited;
|
||||||
|
}
|
||||||
|
|
||||||
protected objectRoute(id: string): string[] {
|
protected objectRoute(id: string): string[] {
|
||||||
return this.collectedIds().has(id) ? ['/city', id, 'icon'] : ['/city', id];
|
const current = this.area();
|
||||||
|
const attraction = current ? findAttraction(current, id) : null;
|
||||||
|
return attraction?.visited
|
||||||
|
? ['/city', this.areaId(), id, 'icon']
|
||||||
|
: ['/city', this.areaId(), id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,63 +1,87 @@
|
|||||||
<section class="page">
|
<section class="page">
|
||||||
<header class="account">
|
@if (authenticated()) {
|
||||||
<p class="account__email">{{ accountEmail() }}</p>
|
<header class="account">
|
||||||
<button class="account__logout" type="button" aria-label="Выйти" (click)="logout()">
|
<p class="account__email">{{ accountEmail() }}</p>
|
||||||
<app-icon name="logout" [size]="22" />
|
<div class="account__actions">
|
||||||
</button>
|
<button
|
||||||
</header>
|
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>
|
||||||
|
}
|
||||||
|
|
||||||
<div class="page__intro">
|
<div class="page__intro">
|
||||||
<h1>Вся коллекция</h1>
|
<h1>Моя коллекция</h1>
|
||||||
<p>Достопримечательности по городам и странам</p>
|
<p>Достопримечательности которые вы открыли</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section class="summary">
|
<section class="summary" style="margin-bottom: 16px">
|
||||||
<div>
|
<div>
|
||||||
<b>{{ openedCount() }}</b>
|
<b>{{ openedCount() }}</b>
|
||||||
<span>{{ objectsLabel() }}</span>
|
<span>{{ objectsLabel() }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<b>1</b>
|
<b>{{ packs().length }}</b>
|
||||||
<span>город</span>
|
<span>{{ citiesLabel() }}</span>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<p class="section-label">Мои города</p>
|
@if (packs().length > 0) {
|
||||||
|
@for (pack of packs(); track pack.area.id) {
|
||||||
|
<article class="pack">
|
||||||
|
<a
|
||||||
|
class="pack__head"
|
||||||
|
[routerLink]="['/city', pack.area.id]"
|
||||||
|
[attr.aria-label]="'Объекты: ' + pack.area.name"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<h2>{{ pack.area.name }}</h2>
|
||||||
|
<p>Собрано {{ pack.opened }} из {{ pack.total }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="pack__percent anim-percent" [style.--to-p]="pack.progress" aria-hidden="true">
|
||||||
|
<span>{{ pack.progress }}%</span>
|
||||||
|
</div>
|
||||||
|
<span class="pack__go" aria-hidden="true">
|
||||||
|
<app-icon name="chevron-right" [size]="20" />
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
@if (collectedLandmarks().length > 0) {
|
<div class="pack__bar" aria-hidden="true">
|
||||||
<article class="pack">
|
<span class="anim-grow" [style.--from]="'0%'" [style.--to]="pack.progress + '%'"></span>
|
||||||
<a class="pack__head" routerLink="/city" [attr.aria-label]="'Объекты: ' + city.name">
|
|
||||||
<div>
|
|
||||||
<h2>{{ city.name }}</h2>
|
|
||||||
<p>Собрано {{ openedCount() }} из {{ totalCount }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="pack__percent anim-percent" [style.--to-p]="progress()" aria-hidden="true">
|
|
||||||
<span>{{ progress() }}%</span>
|
<div class="picked">
|
||||||
|
@for (landmark of pack.items; track landmark.id) {
|
||||||
|
<a class="picked__card" [routerLink]="objectRoute(pack.area.id, landmark)">
|
||||||
|
<div class="picked__preview">
|
||||||
|
<img [src]="landmark.iconUrl" alt="" />
|
||||||
|
</div>
|
||||||
|
<div class="picked__body">
|
||||||
|
<h3>{{ landmark.name }}</h3>
|
||||||
|
</div>
|
||||||
|
<span class="picked__bar" aria-hidden="true"></span>
|
||||||
|
</a>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
<span class="pack__go" aria-hidden="true">
|
</article>
|
||||||
<app-icon name="chevron-right" [size]="20" />
|
}
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div class="pack__bar" aria-hidden="true">
|
|
||||||
<span class="anim-grow" [style.--from]="'0%'" [style.--to]="progress() + '%'"></span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="picked">
|
|
||||||
@for (landmark of collectedLandmarks(); track landmark.id) {
|
|
||||||
<a class="picked__card" [routerLink]="objectRoute(landmark.id)">
|
|
||||||
<div class="picked__preview">
|
|
||||||
<img [src]="landmark.achievement" alt="" />
|
|
||||||
</div>
|
|
||||||
<div class="picked__body">
|
|
||||||
<h3>{{ landmark.title }}</h3>
|
|
||||||
</div>
|
|
||||||
<span class="picked__bar" aria-hidden="true"></span>
|
|
||||||
</a>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
} @else {
|
} @else {
|
||||||
<p class="empty">Пока нет полученных объектов.</p>
|
<p class="empty">Пока нет полученных объектов.</p>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@if (documentsOpen()) {
|
||||||
|
<app-documents-sheet (dismissed)="closeDocuments()" />
|
||||||
|
}
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -27,7 +27,13 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.account__logout {
|
.account__actions {
|
||||||
|
display: flex;
|
||||||
|
flex: none;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account__action {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: none;
|
flex: none;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -35,13 +41,27 @@
|
|||||||
width: 44px;
|
width: 44px;
|
||||||
height: 44px;
|
height: 44px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 1px solid var(--color-border);
|
border: 0;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
background: var(--color-surface);
|
background: transparent;
|
||||||
color: var(--color-text);
|
color: var(--color-text);
|
||||||
cursor: pointer;
|
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 {
|
.page__intro {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +1,61 @@
|
|||||||
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 { RouterLink } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
import { CityCatalogService } from '../../root/services/city-catalog.service';
|
import {
|
||||||
|
areaAttractions,
|
||||||
|
areaOpenedCount,
|
||||||
|
areaProgress,
|
||||||
|
areaTotalCount,
|
||||||
|
type Attraction,
|
||||||
|
} from '../../areas/area.models';
|
||||||
|
import { DocumentsSheet } from '../../shared/documents-sheet/documents-sheet';
|
||||||
import { Icon } from '../../shared/icon/icon';
|
import { Icon } from '../../shared/icon/icon';
|
||||||
import {
|
import {
|
||||||
GorodarActions,
|
GorodarActions,
|
||||||
|
selectAreas,
|
||||||
selectAuthEmail,
|
selectAuthEmail,
|
||||||
selectAuthenticated,
|
selectAuthenticated,
|
||||||
selectCollectedIdSet,
|
|
||||||
selectOpenedCount,
|
selectOpenedCount,
|
||||||
selectProfile,
|
selectProfile,
|
||||||
selectProgress,
|
|
||||||
} from '../../state';
|
} from '../../state';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-collections-page',
|
selector: 'app-collections-page',
|
||||||
imports: [Icon, RouterLink],
|
imports: [Icon, RouterLink, DocumentsSheet],
|
||||||
templateUrl: './collections-page.html',
|
templateUrl: './collections-page.html',
|
||||||
styleUrl: './collections-page.scss',
|
styleUrl: './collections-page.scss',
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class CollectionsPage {
|
export class CollectionsPage {
|
||||||
private readonly catalog = inject(CityCatalogService);
|
|
||||||
private readonly store = inject(Store);
|
private readonly store = inject(Store);
|
||||||
|
|
||||||
protected readonly city = this.catalog.city;
|
private readonly areas = this.store.selectSignal(selectAreas);
|
||||||
protected readonly profile = this.store.selectSignal(selectProfile);
|
protected readonly profile = this.store.selectSignal(selectProfile);
|
||||||
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
|
||||||
protected readonly openedCount = this.store.selectSignal(selectOpenedCount);
|
protected readonly openedCount = this.store.selectSignal(selectOpenedCount);
|
||||||
protected readonly totalCount = this.city.objects.length;
|
protected readonly authenticated = this.store.selectSignal(selectAuthenticated);
|
||||||
protected readonly progress = this.store.selectSignal(selectProgress);
|
|
||||||
private readonly authenticated = this.store.selectSignal(selectAuthenticated);
|
|
||||||
private readonly authEmail = this.store.selectSignal(selectAuthEmail);
|
private readonly authEmail = this.store.selectSignal(selectAuthEmail);
|
||||||
protected readonly accountEmail = computed(() =>
|
protected readonly accountEmail = computed(() =>
|
||||||
this.authenticated() ? this.authEmail() : this.profile().email,
|
this.authenticated() ? this.authEmail() : this.profile().email,
|
||||||
);
|
);
|
||||||
protected readonly collectedLandmarks = computed(() =>
|
protected readonly documentsOpen = signal(false);
|
||||||
this.city.objects.filter((item) => this.collectedIds().has(item.id)),
|
protected readonly packs = computed(() =>
|
||||||
|
this.areas()
|
||||||
|
.map((area) => ({
|
||||||
|
area,
|
||||||
|
items: areaAttractions(area).filter((item) => item.visited),
|
||||||
|
opened: areaOpenedCount(area),
|
||||||
|
total: areaTotalCount(area),
|
||||||
|
progress: areaProgress(area),
|
||||||
|
}))
|
||||||
|
.filter((pack) => pack.items.length > 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -50,11 +68,30 @@ export class CollectionsPage {
|
|||||||
this.plural(this.openedCount(), ['объект', 'объекта', 'объектов']),
|
this.plural(this.openedCount(), ['объект', 'объекта', 'объектов']),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected objectRoute(id: string): string[] {
|
protected readonly citiesLabel = computed(() =>
|
||||||
return this.collectedIds().has(id) ? ['/city', id, 'icon'] : ['/city', id];
|
this.plural(this.packs().length, ['город', 'города', 'городов']),
|
||||||
|
);
|
||||||
|
|
||||||
|
protected objectRoute(areaId: string, attraction: Attraction): string[] {
|
||||||
|
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 {
|
protected logout(): void {
|
||||||
|
this.documentsOpen.set(false);
|
||||||
this.store.dispatch(GorodarActions.logout());
|
this.store.dispatch(GorodarActions.logout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,19 @@
|
|||||||
@if (collected()) {
|
@if (collected()) {
|
||||||
<app-collect-success
|
<app-collect-success
|
||||||
mode="preview"
|
mode="preview"
|
||||||
[title]="item.title"
|
[title]="item.name"
|
||||||
[image]="item.achievement"
|
[image]="item.iconUrl"
|
||||||
[model]="item.model"
|
[model]="item.modelUrl || undefined"
|
||||||
|
[areaId]="areaId()"
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
} @else if (status() === 'loading') {
|
||||||
|
<section class="missing">
|
||||||
|
<p>Загружаем…</p>
|
||||||
|
</section>
|
||||||
} @else {
|
} @else {
|
||||||
<section class="missing">
|
<section class="missing">
|
||||||
<p>Объект не найден.</p>
|
<p>Объект не найден.</p>
|
||||||
<a routerLink="/city">К списку объектов</a>
|
<a [routerLink]="['/city', areaId()]">К списку объектов</a>
|
||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import { ChangeDetectionStrategy, Component, computed, effect, inject, input } f
|
|||||||
import { Router, RouterLink } from '@angular/router';
|
import { Router, RouterLink } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
|
import { findAttraction } from '../../areas/area.models';
|
||||||
import { CollectSuccess } from '../../claim/collect-success/collect-success';
|
import { CollectSuccess } from '../../claim/collect-success/collect-success';
|
||||||
import { CityCatalogService } from '../../root/services/city-catalog.service';
|
import { GorodarActions, selectAreaDetails, selectAreaDetailStatus } from '../../state';
|
||||||
import { selectCollectedIdSet } from '../../state';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-icon-preview-page',
|
selector: 'app-icon-preview-page',
|
||||||
@@ -14,28 +14,41 @@ import { selectCollectedIdSet } from '../../state';
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class IconPreviewPage {
|
export class IconPreviewPage {
|
||||||
private readonly catalog = inject(CityCatalogService);
|
|
||||||
private readonly store = inject(Store);
|
private readonly store = inject(Store);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
private readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
private readonly details = this.store.selectSignal(selectAreaDetails);
|
||||||
|
private readonly detailStatus = this.store.selectSignal(selectAreaDetailStatus);
|
||||||
|
protected readonly status = computed(() => this.detailStatus()[this.areaId()] ?? 'loading');
|
||||||
|
|
||||||
|
readonly areaId = input.required<string>();
|
||||||
readonly id = input.required<string>();
|
readonly id = input.required<string>();
|
||||||
|
|
||||||
protected readonly landmark = computed(() => this.catalog.landmarkById(this.id()));
|
protected readonly landmark = computed(() => {
|
||||||
protected readonly collected = computed(() => {
|
const area = this.details()[this.areaId()];
|
||||||
const item = this.landmark();
|
return area ? findAttraction(area, this.id()) : null;
|
||||||
return item ? this.collectedIds().has(item.id) : false;
|
|
||||||
});
|
});
|
||||||
|
protected readonly collected = computed(() => this.landmark()?.visited ?? false);
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
const item = this.landmark();
|
const areaId = this.areaId();
|
||||||
|
const status = this.detailStatus()[areaId];
|
||||||
|
|
||||||
if (!item || this.collectedIds().has(item.id)) {
|
if (this.details()[areaId] || status === 'loading' || status === 'ready') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void this.router.navigate(['/city', item.id], { replaceUrl: true });
|
this.store.dispatch(GorodarActions.areaRequested({ id: areaId }));
|
||||||
|
});
|
||||||
|
|
||||||
|
effect(() => {
|
||||||
|
const item = this.landmark();
|
||||||
|
|
||||||
|
if (this.status() !== 'ready' || !item || item.visited) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void this.router.navigate(['/city', this.areaId(), item.id], { replaceUrl: true });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,26 @@
|
|||||||
@if (landmark(); as item) {
|
@if (landmark(); as item) {
|
||||||
@if (claiming()) {
|
@if (claiming()) {
|
||||||
<app-claim-flow [landmark]="item" />
|
<app-claim-flow
|
||||||
|
[landmark]="item"
|
||||||
|
[cityName]="area()?.name ?? ''"
|
||||||
|
[opened]="openedCount()"
|
||||||
|
[total]="totalCount()"
|
||||||
|
[areaId]="areaId()"
|
||||||
|
/>
|
||||||
} @else {
|
} @else {
|
||||||
<article class="object" [class.object--owned]="collected()">
|
<article class="object" [class.object--owned]="collected()">
|
||||||
<header class="object__hero">
|
<header class="object__hero">
|
||||||
<img class="object__hero-img" [src]="item.background" alt="" />
|
@if (item.backgroundUrl || item.photoUrl) {
|
||||||
|
<img class="object__hero-img" [src]="item.backgroundUrl || item.photoUrl" alt="" />
|
||||||
|
}
|
||||||
<button class="object__back" type="button" aria-label="Назад" (click)="goBack()">
|
<button class="object__back" type="button" aria-label="Назад" (click)="goBack()">
|
||||||
<app-icon name="chevron-left" [size]="22" />
|
<app-icon name="chevron-left" [size]="22" />
|
||||||
</button>
|
</button>
|
||||||
<span class="object__city">{{ city.name }}</span>
|
<span class="object__city">{{ area()?.name }}</span>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="object__intro">
|
<div class="object__intro">
|
||||||
<h1>{{ item.title }}</h1>
|
<h1>{{ item.name }}</h1>
|
||||||
|
|
||||||
<div class="object__chips">
|
<div class="object__chips">
|
||||||
<span class="chip" [class.chip--open]="collected()">
|
<span class="chip" [class.chip--open]="collected()">
|
||||||
@@ -21,72 +29,59 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="object__address">
|
@if (item.address) {
|
||||||
<app-icon name="pin" [size]="18" />
|
<div class="object__address">
|
||||||
<div>
|
<app-icon name="pin" [size]="18" />
|
||||||
<p>{{ item.address }}</p>
|
<div>
|
||||||
<span>{{ item.addressHint }}</span>
|
<p>{{ item.address }}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="object__body">
|
<div class="object__body">
|
||||||
<section>
|
@if (item.about) {
|
||||||
<h2>О месте</h2>
|
|
||||||
<p>{{ item.description }}</p>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<h2>Аудиогид</h2>
|
|
||||||
<app-audio-guide [src]="item.audio" />
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<h2>Интересные факты</h2>
|
|
||||||
<ol class="facts">
|
|
||||||
@for (fact of item.facts; track fact; let index = $index) {
|
|
||||||
<li>
|
|
||||||
<span class="facts__number">{{ index + 1 }}</span>
|
|
||||||
<span class="facts__value">
|
|
||||||
{{ fact }}
|
|
||||||
</span>
|
|
||||||
</li>
|
|
||||||
}
|
|
||||||
</ol>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
@if (collected()) {
|
|
||||||
<section>
|
<section>
|
||||||
<h2>Ваше фото</h2>
|
<h2>О месте</h2>
|
||||||
<button class="owned-photo" type="button" (click)="openPhoto()">
|
<p>{{ item.about }}</p>
|
||||||
<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>
|
</section>
|
||||||
} @else {
|
}
|
||||||
|
|
||||||
|
@if (item.facts.length > 0) {
|
||||||
<section>
|
<section>
|
||||||
<h2>Как забрать</h2>
|
<h2>Интересные факты</h2>
|
||||||
<ol class="steps">
|
<ol class="facts">
|
||||||
<li>Приезжайте на место и найдите объект</li>
|
@for (fact of item.facts; track fact; let index = $index) {
|
||||||
<li>Нажмите «Забрать» и сфотографируйте объект</li>
|
<li>
|
||||||
<li>Получите объект в свою коллекцию</li>
|
<span class="facts__number">{{ index + 1 }}</span>
|
||||||
|
<span class="facts__value">{{ fact }}</span>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
</ol>
|
</ol>
|
||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@if (item.audioUrl) {
|
||||||
|
<section>
|
||||||
|
<h2>Аудиогид</h2>
|
||||||
|
<app-audio-guide [src]="item.audioUrl" />
|
||||||
|
</section>
|
||||||
|
}
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Как забрать</h2>
|
||||||
|
<ol class="steps">
|
||||||
|
<li>Приезжайте на место и найдите объект.</li>
|
||||||
|
<li>Встаньте на точку отмеченную на карте.</li>
|
||||||
|
<li>Нажмите «Забрать» и сфотографируйте объект.</li>
|
||||||
|
<li>Получите объект в свою коллекцию.</li>
|
||||||
|
</ol>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (!collected()) {
|
@if (!collected()) {
|
||||||
<footer class="object__bar">
|
<footer class="object__bar">
|
||||||
<button class="object__claim" matButton="filled" type="button" (click)="claimItem()">
|
<button class="btn" type="button" (click)="claimItem()">
|
||||||
<app-icon name="camera" [size]="22" />
|
<app-icon name="camera" [size]="22" />
|
||||||
Забрать
|
Забрать
|
||||||
</button>
|
</button>
|
||||||
@@ -95,25 +90,13 @@
|
|||||||
}
|
}
|
||||||
</article>
|
</article>
|
||||||
}
|
}
|
||||||
|
} @else if (status() === 'loading') {
|
||||||
@if (photoOpen()) {
|
<section class="object object--empty">
|
||||||
@if (userPhoto(); as image) {
|
<p>Загружаем…</p>
|
||||||
<div class="photo-viewer" (click)="closePhoto()">
|
</section>
|
||||||
<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 {
|
} @else {
|
||||||
<section class="object object--empty">
|
<section class="object object--empty">
|
||||||
<p>Объект не найден.</p>
|
<p>{{ error() || 'Объект не найден.' }}</p>
|
||||||
<button matButton="outlined" type="button" (click)="goBack()">Назад</button>
|
<button matButton="outlined" type="button" (click)="goBack()">Назад</button>
|
||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,17 +274,6 @@
|
|||||||
background: linear-gradient(to bottom, transparent, rgb(18 17 15 / 96%) 30%);
|
background: linear-gradient(to bottom, transparent, rgb(18 17 15 / 96%) 30%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.object__claim {
|
|
||||||
width: 100%;
|
|
||||||
min-height: 56px;
|
|
||||||
overflow: visible;
|
|
||||||
--mat-button-filled-container-color: #d4143f;
|
|
||||||
--mat-button-filled-label-text-color: #fff;
|
|
||||||
--mat-button-filled-container-shape: 16px;
|
|
||||||
background-color: #d4143f;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.object__bar p {
|
.object__bar p {
|
||||||
margin: 8px 0 0;
|
margin: 8px 0 0;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
Component,
|
Component,
|
||||||
computed,
|
computed,
|
||||||
|
effect,
|
||||||
HostListener,
|
HostListener,
|
||||||
inject,
|
inject,
|
||||||
input,
|
input,
|
||||||
@@ -12,16 +13,20 @@ import { MatButton } from '@angular/material/button';
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
|
import { areaOpenedCount, areaTotalCount, type AreaDetails } from '../../areas/area.models';
|
||||||
import { ClaimFlow } from '../../claim/claim-flow/claim-flow';
|
import { ClaimFlow } from '../../claim/claim-flow/claim-flow';
|
||||||
import { CityCatalogService } from '../../root/services/city-catalog.service';
|
|
||||||
import { AudioGuide } from '../../shared/audio-guide/audio-guide';
|
import { AudioGuide } from '../../shared/audio-guide/audio-guide';
|
||||||
import { Icon } from '../../shared/icon/icon';
|
import { Icon } from '../../shared/icon/icon';
|
||||||
import {
|
import {
|
||||||
GorodarActions,
|
GorodarActions,
|
||||||
|
selectAreaDetails,
|
||||||
|
selectAreaDetailStatus,
|
||||||
|
selectAttractionError,
|
||||||
|
selectAttractions,
|
||||||
|
selectAttractionStatus,
|
||||||
selectAuthenticated,
|
selectAuthenticated,
|
||||||
selectClaim,
|
selectClaim,
|
||||||
selectCollectedAt,
|
selectCollectedAt,
|
||||||
selectCollectedIdSet,
|
|
||||||
selectPhotos,
|
selectPhotos,
|
||||||
} from '../../state';
|
} from '../../state';
|
||||||
|
|
||||||
@@ -33,30 +38,38 @@ import {
|
|||||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
})
|
})
|
||||||
export class MapItemPage {
|
export class MapItemPage {
|
||||||
private readonly catalog = inject(CityCatalogService);
|
|
||||||
private readonly store = inject(Store);
|
private readonly store = inject(Store);
|
||||||
private readonly location = inject(Location);
|
private readonly location = inject(Location);
|
||||||
private readonly router = inject(Router);
|
private readonly router = inject(Router);
|
||||||
private readonly authenticated = this.store.selectSignal(selectAuthenticated);
|
private readonly authenticated = this.store.selectSignal(selectAuthenticated);
|
||||||
|
private readonly details = this.store.selectSignal(selectAreaDetails);
|
||||||
|
private readonly detailStatus = this.store.selectSignal(selectAreaDetailStatus);
|
||||||
|
private readonly attractions = this.store.selectSignal(selectAttractions);
|
||||||
|
private readonly attractionStatuses = this.store.selectSignal(selectAttractionStatus);
|
||||||
|
private readonly attractionErrors = this.store.selectSignal(selectAttractionError);
|
||||||
|
|
||||||
|
readonly areaId = input.required<string>();
|
||||||
readonly id = input.required<string>();
|
readonly id = input.required<string>();
|
||||||
|
|
||||||
protected readonly city = this.catalog.city;
|
protected readonly status = computed(() => this.attractionStatuses()[this.id()] ?? 'loading');
|
||||||
protected readonly landmark = computed(() => this.catalog.landmarkById(this.id()));
|
protected readonly error = computed(() => this.attractionErrors()[this.id()] ?? '');
|
||||||
protected readonly collectedIds = this.store.selectSignal(selectCollectedIdSet);
|
protected readonly area = computed(
|
||||||
|
(): AreaDetails | null => this.details()[this.areaId()] ?? null,
|
||||||
|
);
|
||||||
|
protected readonly landmark = computed(() => this.attractions()[this.id()] ?? null);
|
||||||
protected readonly photos = this.store.selectSignal(selectPhotos);
|
protected readonly photos = this.store.selectSignal(selectPhotos);
|
||||||
protected readonly collectedAtMap = this.store.selectSignal(selectCollectedAt);
|
protected readonly collectedAtMap = this.store.selectSignal(selectCollectedAt);
|
||||||
protected readonly claim = this.store.selectSignal(selectClaim);
|
protected readonly claim = this.store.selectSignal(selectClaim);
|
||||||
|
protected readonly openedCount = computed(() => {
|
||||||
protected readonly collected = computed(() => {
|
const area = this.area();
|
||||||
const item = this.landmark();
|
return area ? areaOpenedCount(area) : 0;
|
||||||
return item ? this.collectedIds().has(item.id) || item.collected : false;
|
});
|
||||||
|
protected readonly totalCount = computed(() => {
|
||||||
|
const area = this.area();
|
||||||
|
return area ? areaTotalCount(area) : 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
protected readonly userPhoto = computed(() => {
|
protected readonly collected = computed(() => this.landmark()?.visited ?? false);
|
||||||
const item = this.landmark();
|
|
||||||
return item ? (this.photos()[item.id] ?? null) : null;
|
|
||||||
});
|
|
||||||
|
|
||||||
protected readonly collectedLabel = computed(() => {
|
protected readonly collectedLabel = computed(() => {
|
||||||
if (!this.collected()) {
|
if (!this.collected()) {
|
||||||
@@ -83,7 +96,22 @@ export class MapItemPage {
|
|||||||
return claim.landmarkId === this.id() && claim.stage !== 'idle';
|
return claim.landmarkId === this.id() && claim.stage !== 'idle';
|
||||||
});
|
});
|
||||||
|
|
||||||
protected readonly photoOpen = signal(false);
|
constructor() {
|
||||||
|
effect(() => {
|
||||||
|
const areaId = this.areaId();
|
||||||
|
const status = this.detailStatus()[areaId];
|
||||||
|
|
||||||
|
if (this.details()[areaId] || status === 'loading' || status === 'ready') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.store.dispatch(GorodarActions.areaRequested({ id: areaId }));
|
||||||
|
});
|
||||||
|
|
||||||
|
effect(() => {
|
||||||
|
this.store.dispatch(GorodarActions.attractionRequested({ id: this.id() }));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected goBack(): void {
|
protected goBack(): void {
|
||||||
if (window.history.length > 1) {
|
if (window.history.length > 1) {
|
||||||
@@ -91,7 +119,7 @@ export class MapItemPage {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void this.router.navigateByUrl('/city');
|
void this.router.navigate(['/city', this.areaId()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected claimItem(): void {
|
protected claimItem(): void {
|
||||||
@@ -100,23 +128,6 @@ export class MapItemPage {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.store.dispatch(
|
this.store.dispatch(GorodarActions.authSheetOpened({ intent: 'claim', landmarkId: this.id() }));
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||