@@ -5,7 +5,8 @@ import { tr } from '@/translation/Translation'
55import PlainButton from '@/PlainButton'
66import OnIcon from '@/sidebar/toggle_on.svg'
77import OffIcon from '@/sidebar/toggle_off.svg'
8- import { useContext } from 'react'
8+ import LinkIcon from '@/sidebar/link.svg'
9+ import { useContext , useState } from 'react'
910import { SettingsContext } from '@/contexts/SettingsContext'
1011import { RoutingProfile } from '@/api/graphhopper'
1112import * as config from 'config'
@@ -14,6 +15,7 @@ import { clearRecentLocations } from '@/sidebar/search/RecentLocations'
1415
1516export default function SettingsBox ( { profile } : { profile : RoutingProfile } ) {
1617 const settings = useContext ( SettingsContext )
18+ const [ showCopiedInfo , setShowCopiedInfo ] = useState ( false )
1719
1820 function setProfile ( n : string ) {
1921 Dispatcher . dispatch ( new SetVehicleProfile ( { name : profile . name === n ? 'car' : n } ) )
@@ -23,6 +25,25 @@ export default function SettingsBox({ profile }: { profile: RoutingProfile }) {
2325 const group = config . profile_group_mapping [ groupName ]
2426 return (
2527 < div className = { styles . parent } >
28+ < div
29+ className = { styles . copyLinkRow }
30+ onClick = { ( ) => {
31+ let url = window . location . href
32+ // Capacitor serves the app from https://localhost or http://localhost — rewrite to the
33+ // public URL so the shared link is openable on other devices.
34+ if ( window . location . hostname === 'localhost' )
35+ url = 'https://navi.graphhopper.org' + window . location . pathname + window . location . search
36+ navigator . clipboard . writeText ( url )
37+ if ( navigator . share ) navigator . share ( { url } )
38+ setShowCopiedInfo ( true )
39+ setTimeout ( ( ) => setShowCopiedInfo ( false ) , 2500 )
40+ } }
41+ >
42+ < PlainButton >
43+ < LinkIcon />
44+ </ PlainButton >
45+ < div > { showCopiedInfo ? tr ( 'Copied!' ) : tr ( 'Copy Link' ) } </ div >
46+ </ div >
2647 { groupName && < span className = { styles . groupProfileOptionsHeader } > { tr ( groupName + '_settings' ) } </ span > }
2748 { groupName && (
2849 < div className = { styles . settingsTable } >
0 commit comments