intro, map, layout, permissions
This commit is contained in:
1 parent
efdbbdfc76
commit
d9387f464f
16 files changed
+204
-131
No files matched your search
File renamed without changes.
File renamed without changes.
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M560-200v-560h160v560H560Zm-320 0v-560h160v560H240Z"/></svg>
|
||||||
|
After Width: | Height: | Size: 176 B |
File renamed without changes.
+1
-1
@@ -50,5 +50,5 @@ a {
|
|||||||
|
|
||||||
.screen-container {
|
.screen-container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100dvh;
|
||||||
}
|
}
|
||||||
+6
-6
@@ -7,19 +7,19 @@ export default function manifest(): MetadataRoute.Manifest {
|
|||||||
name: 'Next.js PWA',
|
name: 'Next.js PWA',
|
||||||
short_name: 'NextPWA',
|
short_name: 'NextPWA',
|
||||||
description: 'A Progressive Web App built with Next.js',
|
description: 'A Progressive Web App built with Next.js',
|
||||||
start_url: '/',
|
//start_url: '/', Disables the default website install popup
|
||||||
display: 'standalone',
|
display: 'fullscreen',
|
||||||
orientation: "portrait-primary",
|
orientation: "portrait-primary",
|
||||||
background_color: '#ffffff',
|
background_color: '#000000',
|
||||||
theme_color: '#000000',
|
theme_color: '#ffffff',
|
||||||
icons: [
|
icons: [
|
||||||
{
|
{
|
||||||
src: '/icon-192x192.png',
|
src: '/icons/icon-192x192.png',
|
||||||
sizes: '192x192',
|
sizes: '192x192',
|
||||||
type: 'image/png',
|
type: 'image/png',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
src: '/icon-512x512.png',
|
src: '/icons/icon-512x512.png',
|
||||||
sizes: '512x512',
|
sizes: '512x512',
|
||||||
type: 'image/png',
|
type: 'image/png',
|
||||||
},
|
},
|
||||||
|
|||||||
+4
-71
@@ -16,6 +16,10 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
font-family: var(--font-geist-sans);
|
font-family: var(--font-geist-sans);
|
||||||
background-color: var(--background);
|
background-color: var(--background);
|
||||||
|
|
||||||
|
&.pad {
|
||||||
|
padding: 48px 24px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.main {
|
.main {
|
||||||
@@ -27,61 +31,6 @@
|
|||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
background-color: var(--foreground);
|
background-color: var(--foreground);
|
||||||
padding: 120px 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.intro {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-start;
|
|
||||||
text-align: left;
|
|
||||||
gap: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.intro h1 {
|
|
||||||
max-width: 320px;
|
|
||||||
font-size: 40px;
|
|
||||||
font-weight: 600;
|
|
||||||
line-height: 48px;
|
|
||||||
letter-spacing: -2.4px;
|
|
||||||
text-wrap: balance;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.intro p {
|
|
||||||
max-width: 440px;
|
|
||||||
font-size: 18px;
|
|
||||||
line-height: 32px;
|
|
||||||
text-wrap: balance;
|
|
||||||
color: var(--text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.intro a {
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--text-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ctas {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
width: 100%;
|
|
||||||
max-width: 440px;
|
|
||||||
gap: 16px;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ctas a {
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
height: 40px;
|
|
||||||
padding: 0 16px;
|
|
||||||
border-radius: 128px;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
transition: 0.2s;
|
|
||||||
cursor: pointer;
|
|
||||||
width: fit-content;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a.primary {
|
a.primary {
|
||||||
@@ -107,22 +56,6 @@ a.secondary {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
.main {
|
|
||||||
padding: 48px 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.intro {
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.intro h1 {
|
|
||||||
font-size: 32px;
|
|
||||||
line-height: 40px;
|
|
||||||
letter-spacing: -1.92px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
@media (prefers-color-scheme: dark) {
|
||||||
.logo {
|
.logo {
|
||||||
filter: invert();
|
filter: invert();
|
||||||
|
|||||||
+3
-1
@@ -82,8 +82,10 @@ export default function Main() {
|
|||||||
(<Tour key={2} />)
|
(<Tour key={2} />)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
console.log(styles);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.page}>
|
<div className={styles.page + ((step < 2) ? " " + styles["pad"] : "")}>
|
||||||
<main className={styles.main}>
|
<main className={styles.main}>
|
||||||
{content[step]}
|
{content[step]}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
import React, { useEffect, useRef, useState, useCallback } from 'react';
|
||||||
import * as maplibregl from 'maplibre-gl';
|
import * as maplibregl from 'maplibre-gl';
|
||||||
import 'maplibre-gl/dist/maplibre-gl.css';
|
import 'maplibre-gl/dist/maplibre-gl.css';
|
||||||
import styles from '../css/MapView.module.css';
|
import styles from '@/css/MapView.module.css';
|
||||||
|
|
||||||
export interface PlaceMarker {
|
export interface PlaceMarker {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -11,7 +11,6 @@ export interface PlaceMarker {
|
|||||||
lng: number;
|
lng: number;
|
||||||
title: string;
|
title: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
category?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MapViewProps {
|
export interface MapViewProps {
|
||||||
@@ -48,16 +47,15 @@ export default function MapView({
|
|||||||
const mapContainerRef = useRef<HTMLDivElement>(null);
|
const mapContainerRef = useRef<HTMLDivElement>(null);
|
||||||
const mapRef = useRef<maplibregl.Map | null>(null);
|
const mapRef = useRef<maplibregl.Map | null>(null);
|
||||||
const activeMarkersRef = useRef<Map<string, maplibregl.Marker>>(new Map());
|
const activeMarkersRef = useRef<Map<string, maplibregl.Marker>>(new Map());
|
||||||
|
const [ mapReady, setMapReady ] = useState(false);
|
||||||
|
|
||||||
const [isCaching, setIsCaching] = useState(false);
|
const [isCaching, setIsCaching] = useState(false);
|
||||||
const [cacheProgress, setCacheProgress] = useState<{ loaded: number; total: number } | null>(null);
|
const [cacheProgress, setCacheProgress] = useState<{ loaded: number; total: number } | null>(null);
|
||||||
|
|
||||||
// 1. Initialize Map instance
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mapContainerRef.current) return;
|
if (!mapContainerRef.current) return;
|
||||||
if (mapRef.current) return;
|
if (mapRef.current) return;
|
||||||
|
|
||||||
// Standard OpenStreetMap raster style (can be swapped for MapTiler / custom PBF vector style)
|
|
||||||
const mapStyle: maplibregl.StyleSpecification = {
|
const mapStyle: maplibregl.StyleSpecification = {
|
||||||
version: 8,
|
version: 8,
|
||||||
sources: {
|
sources: {
|
||||||
@@ -101,6 +99,7 @@ export default function MapView({
|
|||||||
map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }), 'bottom-left');
|
map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }), 'bottom-left');
|
||||||
|
|
||||||
map.on('load', async () => {
|
map.on('load', async () => {
|
||||||
|
setMapReady(true);
|
||||||
navigator.geolocation.getCurrentPosition((pos) => {
|
navigator.geolocation.getCurrentPosition((pos) => {
|
||||||
map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
map.setCenter([pos.coords.longitude, pos.coords.latitude]);
|
||||||
geolocate.trigger();
|
geolocate.trigger();
|
||||||
@@ -114,18 +113,19 @@ export default function MapView({
|
|||||||
return () => {
|
return () => {
|
||||||
map.remove();
|
map.remove();
|
||||||
mapRef.current = null;
|
mapRef.current = null;
|
||||||
|
setMapReady(false);
|
||||||
};
|
};
|
||||||
}, [/*initialCenter, initialZoom, tileUrlTemplate Create your own listeners*/]);
|
}, [/*initialCenter, initialZoom, tileUrlTemplate Create your own listeners*/]);
|
||||||
|
|
||||||
// 2. Manage Markers Sync
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const map = mapRef.current;
|
const map = mapRef.current;
|
||||||
if (!map) return;
|
if (!map || !mapReady) return;
|
||||||
|
|
||||||
const currentMarkers = activeMarkersRef.current;
|
const currentMarkers = activeMarkersRef.current;
|
||||||
const incomingMarkerIds = new Set(markers.map((m) => m.id));
|
const incomingMarkerIds = new Set(markers.map((m) => m.id));
|
||||||
|
|
||||||
// Remove obsolete markers
|
console.log(incomingMarkerIds);
|
||||||
|
|
||||||
currentMarkers.forEach((markerInstance, id) => {
|
currentMarkers.forEach((markerInstance, id) => {
|
||||||
if (!incomingMarkerIds.has(id)) {
|
if (!incomingMarkerIds.has(id)) {
|
||||||
markerInstance.remove();
|
markerInstance.remove();
|
||||||
@@ -133,10 +133,9 @@ export default function MapView({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add / Update markers
|
|
||||||
markers.forEach((markerData) => {
|
markers.forEach((markerData) => {
|
||||||
if (!currentMarkers.has(markerData.id)) {
|
if (!currentMarkers.has(markerData.id)) {
|
||||||
const popup = new maplibregl.Popup({ offset: 25 }).setHTML(
|
const popup = new maplibregl.Popup({ offset: 25, className: styles["marker"] }).setHTML(
|
||||||
`<strong>${markerData.title}</strong>${
|
`<strong>${markerData.title}</strong>${
|
||||||
markerData.description ? `<p style="margin:4px 0 0;font-size:12px;">${markerData.description}</p>` : ''
|
markerData.description ? `<p style="margin:4px 0 0;font-size:12px;">${markerData.description}</p>` : ''
|
||||||
}`
|
}`
|
||||||
@@ -154,9 +153,8 @@ export default function MapView({
|
|||||||
currentMarkers.set(markerData.id, newMarker);
|
currentMarkers.set(markerData.id, newMarker);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [markers, onMarkerClick]);
|
}, [mapReady, markers, onMarkerClick]);
|
||||||
|
|
||||||
// 3. Region Precaching Logic for Offline Woods Usage
|
|
||||||
const precacheCurrentRegion = useCallback(async () => {
|
const precacheCurrentRegion = useCallback(async () => {
|
||||||
const map = mapRef.current;
|
const map = mapRef.current;
|
||||||
if (!map) return;
|
if (!map) return;
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { usePermissions } from "@/hooks/usePermission";
|
||||||
|
import { PermissionStateResult } from "@/utils/permissions";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
export interface PermissionCheckProps {
|
||||||
|
onRefresh?: (gps: PermissionStateResult, camera: PermissionStateResult) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PermissionCheck({
|
||||||
|
onRefresh
|
||||||
|
}: PermissionCheckProps) {
|
||||||
|
const { gpsStatus, cameraStatus, refresh } = usePermissions();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (onRefresh) {
|
||||||
|
onRefresh(gpsStatus, cameraStatus);
|
||||||
|
}
|
||||||
|
}, [onRefresh, gpsStatus, cameraStatus]);
|
||||||
|
|
||||||
|
const requestGPSPermission = () => {
|
||||||
|
navigator.geolocation.getCurrentPosition(() => refresh, () => refresh);
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestCamPermission = () => {
|
||||||
|
navigator.mediaDevices.getUserMedia({
|
||||||
|
"video": { facingMode: { ideal: "environment" } },
|
||||||
|
"audio": false,
|
||||||
|
}).then((stream) => {
|
||||||
|
refresh();
|
||||||
|
stream.getTracks().forEach(track => track.stop());
|
||||||
|
alert("Keine Sorge! Die Kamera ist wieder ausgeschalten. Der Gerät zeigt Ihnen nur, dass darauf kurz zugegriffen wurde.");
|
||||||
|
}).catch((e) => refresh);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<p>Für diese Tour werden extra Berechtigungen gebraucht.</p>
|
||||||
|
<p>Kamera: {cameraStatus}</p>
|
||||||
|
<p>GPS: {gpsStatus}</p>
|
||||||
|
<br></br>
|
||||||
|
<button onClick={requestGPSPermission} style={{marginBottom: "2rem", marginRight: "3rem"}}>GPS</button>
|
||||||
|
<button onClick={requestCamPermission} style={{marginBottom: "2rem", marginRight: "3rem"}}>Cam</button>
|
||||||
|
<button onClick={refresh} style={{marginBottom: "2rem", marginRight: "3rem"}}>Refresh</button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
|
|
||||||
export default function PermissionModal() {
|
|
||||||
return (
|
|
||||||
<div className="">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -4,50 +4,38 @@ import ChargedButton from "../ChargedButton";
|
|||||||
import { usePermissions } from "@/hooks/usePermission";
|
import { usePermissions } from "@/hooks/usePermission";
|
||||||
import styles from "@/css/Intro.module.css";
|
import styles from "@/css/Intro.module.css";
|
||||||
import { InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useRef, useState } from "react";
|
import { InputEvent, MouseEvent, MouseEventHandler, PointerEvent, useRef, useState } from "react";
|
||||||
|
import Image from "next/image";
|
||||||
|
import PermissionCheck from "../PermissionCheck";
|
||||||
|
import { PermissionStateResult } from "@/utils/permissions";
|
||||||
|
|
||||||
export default function Intro() {
|
export default function Intro() {
|
||||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||||
const { gpsStatus, cameraStatus, refresh } = usePermissions();
|
|
||||||
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
const [ rewatchScreen, setRewatchScreen ] = useState(false);
|
||||||
const [ videoEnded, setVideoEnded ] = useState(false);
|
const [ videoEnded, setVideoEnded ] = useState(false);
|
||||||
|
const [ videoPaused, setVideoPaused ] = useState(false);
|
||||||
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
const introVideoRef = useRef<HTMLVideoElement | null>(null);
|
||||||
|
const [ granted, setGranted ] = useState(false);
|
||||||
const requestGPSPermission = () => {
|
|
||||||
navigator.geolocation.getCurrentPosition(() => refresh, () => refresh);
|
|
||||||
}
|
|
||||||
const requestCamPermission = () => {
|
|
||||||
navigator.mediaDevices.getUserMedia({
|
|
||||||
"video": { facingMode: { ideal: "environment" } },
|
|
||||||
"audio": false,
|
|
||||||
}).then((stream) => {
|
|
||||||
refresh();
|
|
||||||
stream.getTracks().forEach(track => track.stop());
|
|
||||||
alert("Keine Sorge! Die Kamera ist wieder ausgeschalten. Der Gerät zeigt Ihnen nur, dass darauf kurz zugegriffen wurde.");
|
|
||||||
}).catch((e) => refresh);
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleVideoClick = (e: PointerEvent<HTMLVideoElement>): boolean => {
|
const handleVideoClick = (e: PointerEvent<HTMLVideoElement>): boolean => {
|
||||||
e.currentTarget.play();
|
e.currentTarget.play();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handlePermissions = (gps: PermissionStateResult, cam: PermissionStateResult) => {
|
||||||
|
setGranted(gps === "granted" && cam === "granted");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="screen-container">
|
<div className="screen-container">
|
||||||
{ !rewatchScreen ?
|
{ !rewatchScreen ?
|
||||||
<div>
|
<div>
|
||||||
<p>CODE EINGELÖST</p>
|
<p>CODE EINGELÖST</p>
|
||||||
<p>TON AN</p>
|
<p>TON AN</p>
|
||||||
<p>Für diese Tour werden extra Berechtigungen gebraucht.</p>
|
<PermissionCheck onRefresh={handlePermissions}></PermissionCheck>
|
||||||
<p>Kamera: {cameraStatus}</p>
|
|
||||||
<p>GPS: {gpsStatus}</p>
|
|
||||||
<br></br>
|
|
||||||
<button onClick={requestGPSPermission} style={{marginBottom: "2rem", marginRight: "3rem"}}>GPS</button>
|
|
||||||
<button onClick={requestCamPermission} style={{marginBottom: "2rem", marginRight: "3rem"}}>Cam</button>
|
|
||||||
<button onClick={refresh} style={{marginBottom: "2rem", marginRight: "3rem"}}>Refresh</button>
|
|
||||||
<br></br>
|
<br></br>
|
||||||
<ChargedButton onAction={() => {
|
<ChargedButton onAction={() => {
|
||||||
setRewatchScreen(true);
|
setRewatchScreen(true);
|
||||||
}} holdDuration={500} disabled={gpsStatus !== "granted" || cameraStatus !== "granted"}>
|
}} holdDuration={500} disabled={!granted}>
|
||||||
Video ansehen
|
Video ansehen
|
||||||
</ChargedButton>
|
</ChargedButton>
|
||||||
<div className={styles["overlay-video"]}>
|
<div className={styles["overlay-video"]}>
|
||||||
@@ -66,14 +54,23 @@ export default function Intro() {
|
|||||||
onEnded={() => setVideoEnded(true)}
|
onEnded={() => setVideoEnded(true)}
|
||||||
onAbort={() => setVideoEnded(true)}
|
onAbort={() => setVideoEnded(true)}
|
||||||
onError={() => setVideoEnded(true)}
|
onError={() => setVideoEnded(true)}
|
||||||
|
onPause={() => setVideoPaused(true)}
|
||||||
|
onPlay={() => setVideoPaused(false)}
|
||||||
onClick={handleVideoClick}
|
onClick={handleVideoClick}
|
||||||
onContextMenu={(e) => {
|
onContextMenu={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<source src="/res/testvid.webm" type="video/webm"/>
|
<source src="/res/intro/testvid.webm" type="video/webm"/>
|
||||||
</video>
|
</video>
|
||||||
|
{ !videoEnded && videoPaused ?
|
||||||
|
<div className={styles["pause-screen"]}>
|
||||||
|
<Image src="/icons/pause.svg" alt="Pause Icon" width={48} height={48}/>
|
||||||
|
</div>
|
||||||
|
:
|
||||||
|
null
|
||||||
|
}
|
||||||
{ videoEnded ? <div className={styles["rewatch-controls"]}>
|
{ videoEnded ? <div className={styles["rewatch-controls"]}>
|
||||||
<ChargedButton holdDuration={500} onAction={() => {
|
<ChargedButton holdDuration={500} onAction={() => {
|
||||||
if (introVideoRef.current) {
|
if (introVideoRef.current) {
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
import { useLocalStorage } from "@/hooks/useLocalStorage"
|
import { useLocalStorage } from "@/hooks/useLocalStorage"
|
||||||
import { PREF } from "@/utils/const"
|
import { PREF } from "@/utils/const"
|
||||||
import { parsePlayerData } from "@/utils/dataparser";
|
import { parsePlayerData } from "@/utils/dataparser";
|
||||||
import ChargedButton from "../ChargedButton";
|
import ChargedButton from "../ChargedButton";
|
||||||
import styles from "@/css/Tour.module.css";
|
import styles from "@/css/Tour.module.css";
|
||||||
import MapView from "../MapView";
|
import MapView, { PlaceMarker } from "../MapView";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { usePermissions } from "@/hooks/usePermission";
|
||||||
|
import PermissionCheck from "../PermissionCheck";
|
||||||
|
|
||||||
export default function Tour() {
|
export default function Tour() {
|
||||||
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
const [ stepStr, setStep ] = useLocalStorage(PREF.step, "0");
|
||||||
@@ -11,13 +16,46 @@ export default function Tour() {
|
|||||||
const [ completedRiddlesStr, setCompletedRiddles ] = useLocalStorage(PREF.completed_riddles, "");
|
const [ completedRiddlesStr, setCompletedRiddles ] = useLocalStorage(PREF.completed_riddles, "");
|
||||||
const [ playersStr, setPlayers ] = useLocalStorage(PREF.players, "");
|
const [ playersStr, setPlayers ] = useLocalStorage(PREF.players, "");
|
||||||
const [ pointsStr, setPoints ] = useLocalStorage(PREF.points, "0");
|
const [ pointsStr, setPoints ] = useLocalStorage(PREF.points, "0");
|
||||||
|
const [ markers, setMarkers ] = useState<PlaceMarker[]>([]);
|
||||||
|
const { gpsStatus, cameraStatus } = usePermissions();
|
||||||
const step = Number.parseInt(stepStr) || 0;
|
const step = Number.parseInt(stepStr) || 0;
|
||||||
const points = Number.parseInt(pointsStr) || 0;
|
const points = Number.parseInt(pointsStr) || 0;
|
||||||
const players = parsePlayerData(playersStr);
|
const players = parsePlayerData(playersStr);
|
||||||
|
|
||||||
|
const permissionsGranted = gpsStatus === "granted" && cameraStatus === "granted";
|
||||||
|
|
||||||
|
const [ test, setTest ] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let timerId: string | number | NodeJS.Timeout | undefined;
|
||||||
|
|
||||||
|
const requestPosition = () => {
|
||||||
|
timerId = setTimeout(() => {
|
||||||
|
navigator.geolocation.getCurrentPosition(
|
||||||
|
(position) => {
|
||||||
|
setMarkers([{
|
||||||
|
id: "riddle_one",
|
||||||
|
title: "Erstes Rätsel",
|
||||||
|
description: "Test Punkt verschoben vom Standort",
|
||||||
|
lng: position.coords.longitude + 0.002,
|
||||||
|
lat: position.coords.latitude,
|
||||||
|
}]);
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
requestPosition();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, 500);
|
||||||
|
};
|
||||||
|
|
||||||
|
requestPosition();
|
||||||
|
|
||||||
|
return () => clearTimeout(timerId);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="screen-container">
|
<div className={styles["screen-container"]}>
|
||||||
<div>
|
<div className={styles["top-bar"]}>
|
||||||
<p>{"Ruf: " + points}</p>
|
<p>{"Ruf: " + points}</p>
|
||||||
<p>{"Players: " + playersStr}</p>
|
<p>{"Players: " + playersStr}</p>
|
||||||
<br></br>
|
<br></br>
|
||||||
@@ -34,11 +72,23 @@ export default function Tour() {
|
|||||||
</div>
|
</div>
|
||||||
<div className={styles["main-content"]}>
|
<div className={styles["main-content"]}>
|
||||||
<div className={styles["map"]}>
|
<div className={styles["map"]}>
|
||||||
<MapView></MapView>
|
<MapView markers={markers} onMarkerClick={(marker) => {
|
||||||
|
if (marker.id === "riddle_one") {
|
||||||
|
setTest(true);
|
||||||
|
}
|
||||||
|
}}></MapView>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["riddle-overlay"]}>
|
<div className={styles["riddle-overlay"]} style={{display: test ? "block" : "none"}} onClick={() => setTest(false)}>
|
||||||
Riddle Overlay
|
<p>Riddle Overlay</p>
|
||||||
|
<p>Idealer weise dann mit Popup Animation (Slide In oder Fade In)</p>
|
||||||
|
<p>Klicken um zu schließen</p>
|
||||||
</div>
|
</div>
|
||||||
|
{ !permissionsGranted ?
|
||||||
|
<div className={styles["permissions-overlay"]}>
|
||||||
|
<PermissionCheck></PermissionCheck>
|
||||||
|
</div>
|
||||||
|
: null
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -34,4 +34,20 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: rgba(0, 0, 0, 0.75);
|
background-color: rgba(0, 0, 0, 0.75);
|
||||||
animation: fadeIn 0.5s ease-out 0s 1 normal forwards;
|
animation: fadeIn 0.5s ease-out 0s 1 normal forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pause-screen {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
row-gap: 3rem;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.25);
|
||||||
|
animation: fadeIn 200ms ease-out 0s 1 normal forwards;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
@@ -70,4 +70,12 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
background: #10b981;
|
background: #10b981;
|
||||||
transition: width 0.2s ease;
|
transition: width 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.marker {
|
||||||
|
color: black;
|
||||||
|
|
||||||
|
button {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+31
-2
@@ -1,7 +1,22 @@
|
|||||||
.main-content {
|
.screen-container {
|
||||||
position: relative;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
height: 100dvh;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-bar {
|
||||||
|
padding: 8px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.map {
|
.map {
|
||||||
@@ -13,6 +28,20 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
/*height: 100%; TODO: fullsize when doing this*/
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
background-color: #000000AA;
|
background-color: #000000AA;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permissions-overlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
padding: 1rem;
|
||||||
|
background-color: #000000AA;
|
||||||
|
z-index: 10;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user