Basic structure for recording UI

This commit is contained in:
Eric van der Vlist 2022-12-13 16:16:30 +01:00
parent 3d2db84235
commit 1d648a2187
6 changed files with 151 additions and 2 deletions

View File

@ -0,0 +1,7 @@
.control {
opacity: 1;
position: fixed !important;
top: 0px;
margin-left: calc(100% - 190px) !important;
z-index: 1;
}

View File

@ -0,0 +1,120 @@
import {
Box,
Button,
DialogActions,
IconButton,
Typography,
} from '@suid/material';
import FiberManualRecordIcon from '@suid/icons-material/FiberManualRecord';
import { Component, createEffect, createSignal, Show } from 'solid-js';
import style from './GpxRecord.module.css';
import Dialog from '../dialog';
import { useI18n } from '@solid-primitives/i18n';
import GpxChooser from '../gpx-chooser';
import { currentGpxId } from '../gpx-dialog';
const GpxRecord: Component<{}> = (props) => {
const [t] = useI18n();
const [state, setState] = createSignal('stopped');
const [open, setOpen] = createSignal(false);
const [gpxId, setGpxId] = createSignal<string>('');
const [trkId, setTrkId] = createSignal<string>('');
const handleClickOpen = () => {
if (state() === 'stopped') {
setGpxId(currentGpxId());
}
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};
const startRecordingHandler = () => {
setState('recording');
setOpen(false);
};
const pauseRecordingHandler = () => {
setState('paused');
setOpen(false);
};
const resumeRecordingHandler = () => {
setState('recording');
setOpen(false);
};
const stopRecordingHandler = () => {
setState('stopped');
setOpen(false);
};
return (
<>
<div class={style.control}>
<IconButton onClick={handleClickOpen}>
<FiberManualRecordIcon
color={state() === 'recording' ? 'error' : 'inherit'}
/>
</IconButton>
</div>
<Dialog open={open()} title={t('gpxRecord')} closeHandler={handleClose}>
<Box
sx={{
width: '100%',
}}
>
<GpxChooser
gpxId={gpxId}
setGpxId={setGpxId}
disabled={state() !== 'stopped'}
/>
<Typography sx={{ paddingTop: '20px' }} variant='h6'>
{t(`gpx_${state()}`)}
</Typography>
</Box>
<DialogActions>
<Show when={state() === 'stopped'}>
<Button
color='primary'
variant='contained'
onClick={startRecordingHandler}
>
{t('gpxStartRecording')}
</Button>
</Show>
<Show when={state() === 'recording'}>
<Button
color='primary'
variant='contained'
onClick={pauseRecordingHandler}
>
{t('gpxPauseRecording')}
</Button>
<Button
color='warning'
variant='contained'
onClick={stopRecordingHandler}
>
{t('gpxStopRecording')}
</Button>
</Show>
<Show when={state() === 'paused'}>
<Button
color='primary'
variant='contained'
onClick={resumeRecordingHandler}
>
{t('gpxResumeRecording')}
</Button>
<Button
color='warning'
variant='contained'
onClick={stopRecordingHandler}
>
{t('gpxStopRecording')}
</Button>
</Show>
</DialogActions>
</Dialog>
</>
);
};
export default GpxRecord;

View File

@ -0,0 +1 @@
export { default } from './GpxRecord';

View File

@ -35,6 +35,7 @@ import MouseWheelZoom from 'ol/interaction/MouseWheelZoom';
import DragZoom from 'ol/interaction/DragZoom';
import Infos, { clickHandler } from '../infos';
import GpxDialog from '../gpx-dialog';
import GpxRecord from '../gpx-record';
const [getState, setState] = createSignal({
lon: 0,
@ -202,6 +203,7 @@ const Map: Component = () => {
<GetLocation />
<Forward />
<Back />
<GpxRecord />
<GpxImport />
<MapTileProvider />
<GpxDialog />

View File

@ -22,6 +22,7 @@ const dict = {
cancel: 'CANCEL',
gpxImport: 'GPX import',
import: 'Import',
file: 'File: ',
gpxStats:
'This file has been created with "{{creator}}" and includes {{nbWpts}} place(s), {{nbRte}} routes(s) et {{nbTrks}} track(s).',
@ -37,11 +38,20 @@ const dict = {
gpxDialog: 'Current journey',
gpxChooser: 'Journey',
gpxName: 'Name',
gpxNoName:'No name',
gpxNoName: 'No name',
gpxDesc: 'Description',
gpxTime: 'Start date',
gpxSave: 'Save',
newGpx: '-- new journey --',
gpxRecord: 'Track recording',
gpx_stopped: 'Not recording',
gpx_paused: 'Recording paused',
gpx_recording: 'Recording',
gpxStartRecording: 'Start recording',
gpxPauseRecording: 'Suspend recording',
ResumeRecording: 'Resume recording',
StopRecording: 'Stop recording',
};
export default dict;

View File

@ -43,11 +43,20 @@ const dict = {
gpxDialog: 'Voyage en cours',
gpxChooser: 'Voyage',
gpxName: 'Nom',
gpxNoName:'Pas de nom',
gpxNoName: 'Pas de nom',
gpxDesc: 'Description',
gpxTime: 'Date de début',
gpxSave: 'Sauvegarder',
newGpx: '-- nouveau voyage --',
gpxRecord: 'Enregistrement de trace',
gpx_stopped: "Pas d'enregistrement en cours",
gpx_paused: 'Enregistrement en pause',
gpx_recording: 'Enregistrement en cours',
gpxStartRecording: "Démarrer l'enregistrement",
gpxPauseRecording: "Mettre l'enregistrement en pause",
gpxResumeRecording: "Reprendre l'enregistrement",
gpxStopRecording: "Arrêter l'enregistrement",
};
export default dict;