MapComplete/src/UI/BigComponents/ThemeIntroPanel.svelte

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

107 lines
3.7 KiB
Svelte
Raw Normal View History

2023-05-18 15:44:54 +02:00
<script lang="ts">
2023-12-01 15:23:28 +01:00
import Translations from "../i18n/Translations"
import Tr from "../Base/Tr.svelte"
import NextButton from "../Base/NextButton.svelte"
import ThemeViewState from "../../Models/ThemeViewState"
2024-08-30 02:18:29 +02:00
import { Store } from "../../Logic/UIEventSource"
2023-12-01 15:23:28 +01:00
import type { GeolocationPermissionState } from "../../Logic/State/GeoLocationState"
import { GeoLocationState } from "../../Logic/State/GeoLocationState"
import If from "../Base/If.svelte"
import { ExclamationTriangleIcon } from "@babeard/svelte-heroicons/mini"
import GeolocationIndicator from "./GeolocationIndicator.svelte"
2023-05-18 15:44:54 +02:00
2023-10-30 13:44:27 +01:00
/**
* The theme introduction panel
*/
export let state: ThemeViewState
let layout = state.layout
let geolocation = state.geolocation.geolocationState
let geopermission: Store<GeolocationPermissionState> = geolocation.permission
let currentGPSLocation = geolocation.currentGPSLocation
let gpsExplanation = geolocation.gpsStateExplanation
let gpsAvailable = geolocation.gpsAvailable
2023-10-30 13:44:27 +01:00
function jumpToCurrentLocation() {
2024-08-12 10:08:23 +02:00
state.geolocationControl.handleClick()
2023-10-30 13:44:27 +01:00
const glstate = state.geolocation.geolocationState
if (glstate.currentGPSLocation.data !== undefined) {
2024-08-30 02:18:29 +02:00
const c = glstate.currentGPSLocation.data
state.guistate.pageStates.about_theme.setData(false)
2023-10-30 13:44:27 +01:00
const coor = { lon: c.longitude, lat: c.latitude }
state.mapProperties.location.setData(coor)
2023-05-18 15:44:54 +02:00
}
2023-10-30 13:44:27 +01:00
if (glstate.permission.data !== "granted") {
glstate.requestPermission()
return
}
}
2023-05-18 15:44:54 +02:00
</script>
2023-06-15 16:12:46 +02:00
<div class="flex h-full flex-col justify-between">
<div>
<!-- Intro, description, ... -->
2024-05-08 21:46:33 +02:00
2023-06-15 16:12:46 +02:00
<Tr t={layout.description} />
2024-06-27 03:39:04 +02:00
<If condition={state.featureSwitches.featureSwitchEnableLogin}>
<Tr t={Translations.t.general.welcomeExplanation.general} />
{#if layout.layers.some((l) => l.presets?.length > 0)}
<Tr t={Translations.t.general.welcomeExplanation.addNew} />
{/if}
</If>
<Tr t={layout.descriptionTail} />
2023-06-15 16:12:46 +02:00
<!-- Buttons: open map, go to location, search -->
<NextButton clss="primary w-full" on:click={() => state.guistate.pageStates.about_theme.setData(false)}>
2024-07-09 13:42:08 +02:00
<div class="flex w-full flex-col items-center">
<div class="flex w-full justify-center text-2xl">
<Tr t={Translations.t.general.openTheMap} />
</div>
<If condition={state.featureSwitches.featureSwitchEnableLogin}>
<Tr t={Translations.t.general.openTheMapReason} />
</If>
2023-06-15 16:12:46 +02:00
</div>
</NextButton>
2023-05-18 15:44:54 +02:00
2023-06-15 16:12:46 +02:00
<div class="flex w-full flex-wrap sm:flex-nowrap">
<If condition={state.featureSwitches.featureSwitchGeolocation}>
2024-08-14 13:53:56 +02:00
<button
disabled={!$gpsAvailable}
class:disabled={!$gpsAvailable}
class="flex w-full items-center gap-x-2"
on:click={jumpToCurrentLocation}
>
<GeolocationIndicator {state} />
<Tr t={$gpsExplanation} />
</button>
</If>
2023-05-18 15:44:54 +02:00
</div>
{#if $currentGPSLocation === undefined && $geopermission === "requested" && GeoLocationState.isSafari()}
2023-10-30 13:44:27 +01:00
<a
href="https://support.apple.com/en-us/HT207092"
class="button w-full"
target="_blank"
rel="noopener"
>
<div class="link-underline m-1 flex w-full">
<ExclamationTriangleIcon class="w-12 pr-2" />
<div class="flex w-full flex-col">
<Tr cls="font-normal" t={Translations.t.general.enableGeolocationForSafari} />
<Tr t={Translations.t.general.enableGeolocationForSafariLink} />
</div>
</div>
</a>
{/if}
2023-06-15 16:12:46 +02:00
</div>
<div class="link-underline flex justify-end text-sm mt-8">
<a href="https://mapcomplete.org" target="_blank">
<Tr t={Translations.t.general.poweredByMapComplete} />
</a>
</div>
2023-05-18 15:44:54 +02:00
</div>