Skip to content

Commit

Permalink
Added PhotoCapture Tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
dlymonkai committed Jul 30, 2024
1 parent fc85fc2 commit 593e3e4
Show file tree
Hide file tree
Showing 37 changed files with 828 additions and 71 deletions.
5 changes: 5 additions & 0 deletions apps/demo-app/src/local-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"id": "demo-app-dev",
"description": "Config for the dev Demo App.",
"allowSkipRetake": true,
"enableAddDamage": true,
"enableSightGuidelines": true,
Expand All @@ -11,6 +13,9 @@
},
"apiDomain": "api.preview.monk.ai/v1",
"thumbnailDomain": "europe-west1-monk-preview-321715.cloudfunctions.net/image_resize",
"enableTutorial": "enabled",
"allowSkipTutorial": true,
"enableSightTutorial": false,
"startTasksOnComplete": true,
"showCloseButton": false,
"enforceOrientation": "landscape",
Expand Down
3 changes: 3 additions & 0 deletions apps/drive-app/src/local-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
},
"apiDomain": "api.preview.monk.ai/v1",
"thumbnailDomain": "europe-west1-monk-preview-321715.cloudfunctions.net/image_resize",
"enableTutorial": "first_time_only",
"allowSkipTutorial": false,
"enableSightTutorial": false,
"startTasksOnComplete": true,
"showCloseButton": false,
"enforceOrientation": "landscape",
Expand Down
3 changes: 3 additions & 0 deletions apps/lux-demo-app/src/local-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
},
"apiDomain": "api.preview.monk.ai/v1",
"thumbnailDomain": "europe-west1-monk-preview-321715.cloudfunctions.net/image_resize",
"enableTutorial": "enabled",
"allowSkipTutorial": true,
"enableSightTutorial": false,
"startTasksOnComplete": true,
"showCloseButton": false,
"enforceOrientation": "landscape",
Expand Down
3 changes: 3 additions & 0 deletions apps/renault-demo-app/src/local-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
},
"apiDomain": "api.preview.monk.ai/v1",
"thumbnailDomain": "europe-west1-monk-preview-321715.cloudfunctions.net/image_resize",
"enableTutorial": "enabled",
"allowSkipTutorial": true,
"enableSightTutorial": false,
"startTasksOnComplete": true,
"showCloseButton": false,
"enforceOrientation": "landscape",
Expand Down
4 changes: 4 additions & 0 deletions documentation/src/utils/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CompressionFormat,
DeviceOrientation,
MonkApiPermission,
PhotoCaptureTutorialOption,
SteeringWheelPosition,
TaskName,
VehicleType,
Expand Down Expand Up @@ -272,6 +273,9 @@ export const LiveConfigSchema = z
enableAddDamage: z.boolean().optional(),
enableSightGuidelines: z.boolean().optional(),
sightGuidelines: z.array(SightGuidelineSchema).optional(),
enableTutorial: z.nativeEnum(PhotoCaptureTutorialOption).optional(),
allowSkipTutorial: z.boolean().optional(),
enableSightTutorial: z.boolean().optional(),
defaultVehicleType: z.nativeEnum(VehicleType),
allowManualLogin: z.boolean(),
allowVehicleTypeSelection: z.boolean(),
Expand Down
65 changes: 35 additions & 30 deletions packages/inspection-capture-web/README.md

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions packages/inspection-capture-web/src/PhotoCapture/PhotoCapture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ComplianceOptions,
CompressionOptions,
DeviceOrientation,
PhotoCaptureTutorialOption,
Sight,
} from '@monkvision/types';
import { useState } from 'react';
Expand All @@ -35,6 +36,7 @@ import {
useComplianceAnalytics,
usePhotoCaptureImages,
usePhotoCaptureSightState,
usePhotoCaptureTutorial,
usePictureTaken,
useStartTasksOnComplete,
useTracking,
Expand All @@ -60,6 +62,9 @@ export interface PhotoCaptureProps
| 'enableAddDamage'
| 'sightGuidelines'
| 'enableSightGuidelines'
| 'enableTutorial'
| 'allowSkipTutorial'
| 'enableSightTutorial'
>,
Partial<CompressionOptions>,
Partial<ComplianceOptions> {
Expand Down Expand Up @@ -126,6 +131,9 @@ export function PhotoCapture({
allowSkipRetake = false,
enableAddDamage = true,
sightGuidelines,
enableTutorial = PhotoCaptureTutorialOption.FIRST_TIME_ONLY,
allowSkipTutorial = true,
enableSightTutorial = true,
enableSightGuidelines = true,
useAdaptiveImageQuality = true,
lang,
Expand Down Expand Up @@ -179,6 +187,11 @@ export function PhotoCapture({
complianceOptions,
setIsInitialInspectionFetched,
});
const { currentTutorialStep, goToNextTutorialStep, closeTutorial } = usePhotoCaptureTutorial({
enableTutorial,
enableSightGuidelines,
enableSightTutorial,
});
const {
isBadConnectionWarningDialogDisplayed,
closeBadConnectionWarningDialog,
Expand Down Expand Up @@ -257,6 +270,10 @@ export function PhotoCapture({
enableAddDamage,
sightGuidelines,
enableSightGuidelines,
currentTutorialStep,
onNextTutorialStep: goToNextTutorialStep,
onCloseTutorial: closeTutorial,
allowSkipTutorial,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,24 @@ import { LoadingState } from '@monkvision/common';
import { useAnalytics } from '@monkvision/analytics';
import { PhotoCaptureHUDButtons } from './PhotoCaptureHUDButtons';
import { usePhotoCaptureHUDStyle } from './hooks';
import { PhotoCaptureMode } from '../hooks';
import { PhotoCaptureMode, TutorialSteps } from '../hooks';
import { PhotoCaptureHUDOverlay } from './PhotoCaptureHUDOverlay';
import { PhotoCaptureHUDElements } from './PhotoCaptureHUDElements';
import { PhotoCaptureHUDTutorial } from './PhotoCaptureHUDTutorial';

/**
* Props of the PhotoCaptureHUD component.
*/
export interface PhotoCaptureHUDProps
extends CameraHUDProps,
Pick<CaptureAppConfig, 'enableSightGuidelines' | 'sightGuidelines' | 'enableAddDamage'> {
Pick<
CaptureAppConfig,
| 'enableSightGuidelines'
| 'sightGuidelines'
| 'enableAddDamage'
| 'showCloseButton'
| 'allowSkipTutorial'
> {
/**
* The inspection ID.
*/
Expand Down Expand Up @@ -45,6 +53,18 @@ export interface PhotoCaptureHUDProps
* Global loading state of the PhotoCapture component.
*/
loading: LoadingState;
/**
* The current tutorial step in PhotoCapture component.
*/
currentTutorialStep: TutorialSteps | null;
/**
* Callback called when the user clicks on "Next" button in PhotoCapture tutorial.
*/
onNextTutorialStep: () => void;
/**
* Callback called when the user clicks on "Close" button in PhotoCapture tutorial.
*/
onCloseTutorial: () => void;
/**
* Callback called when the user manually select a new sight.
*/
Expand Down Expand Up @@ -74,12 +94,6 @@ export interface PhotoCaptureHUDProps
* displayed.
*/
onClose?: () => void;
/**
* Boolean indicating if the close button should be displayed in the HUD on top of the Camera preview.
*
* @default false
*/
showCloseButton?: boolean;
/**
* The current images taken by the user (ignoring retaken pictures etc.).
*/
Expand Down Expand Up @@ -113,6 +127,10 @@ export function PhotoCaptureHUD({
enableAddDamage,
sightGuidelines,
enableSightGuidelines,
currentTutorialStep,
allowSkipTutorial,
onNextTutorialStep,
onCloseTutorial,
}: PhotoCaptureHUDProps) {
const { t } = useTranslation();
const [showCloseModal, setShowCloseModal] = useState(false);
Expand Down Expand Up @@ -154,6 +172,7 @@ export function PhotoCaptureHUD({
enableAddDamage={enableAddDamage}
sightGuidelines={sightGuidelines}
enableSightGuidelines={enableSightGuidelines}
tutorialStep={currentTutorialStep}
/>
</div>
<PhotoCaptureHUDButtons
Expand Down Expand Up @@ -185,6 +204,14 @@ export function PhotoCaptureHUD({
onCancel={() => setShowCloseModal(false)}
onConfirm={handleCloseConfirm}
/>
<PhotoCaptureHUDTutorial
tutorialStep={handle.error || loading.error ? null : currentTutorialStep}
onNextTutorialStep={onNextTutorialStep}
onCloseTutorial={onCloseTutorial}
allowSkipTutorial={allowSkipTutorial}
sightId={selectedSight.id}
sightGuidelines={sightGuidelines}
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CaptureAppConfig, Image, PixelDimensions, Sight } from '@monkvision/types';
import { PhotoCaptureMode } from '../../hooks';
import { PhotoCaptureMode, TutorialSteps } from '../../hooks';
import { PhotoCaptureHUDElementsSight } from '../PhotoCaptureHUDElementsSight';
import { PhotoCaptureHUDElementsAddDamage1stShot } from '../PhotoCaptureHUDElementsAddDamage1stShot';
import { PhotoCaptureHUDElementsAddDamage2ndShot } from '../PhotoCaptureHUDElementsAddDamage2ndShot';
Expand All @@ -25,6 +25,10 @@ export interface PhotoCaptureHUDElementsProps
* The current mode of the component.
*/
mode: PhotoCaptureMode;
/**
* The current tutorial step in PhotoCapture component.
*/
tutorialStep: TutorialSteps | null;
/**
* Callback called when the user presses the Add Damage button.
*/
Expand Down Expand Up @@ -80,6 +84,7 @@ export function PhotoCaptureHUDElements(params: PhotoCaptureHUDElementsProps) {
enableAddDamage={params.enableAddDamage}
sightGuidelines={params.sightGuidelines}
enableSightGuidelines={params.enableSightGuidelines}
tutorialStep={params.tutorialStep}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const styles: Styles = {
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-between',
zIndex: 9,
},
elementsContainerPortrait: {
__media: { portrait: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { styles } from './PhotoCaptureHUDElementsSight.styles';
import { AddDamageButton } from './AddDamageButton';
import { PhotoCaptureHUDElementsSightProps, usePhotoCaptureHUDSightPreviewStyle } from './hooks';
import { PhotoCaptureHUDCounter } from '../PhotoCaptureHUDCounter';
import { PhotoCaptureMode } from '../../hooks';
import { PhotoCaptureMode, TutorialSteps } from '../../hooks';
import { SightGuideline } from './SightGuideline';

/**
Expand All @@ -23,38 +23,43 @@ export function PhotoCaptureHUDElementsSight({
enableAddDamage,
sightGuidelines,
enableSightGuidelines,
tutorialStep,
}: PhotoCaptureHUDElementsSightProps) {
const style = usePhotoCaptureHUDSightPreviewStyle({ previewDimensions });

const showSight = previewDimensions && (!tutorialStep || tutorialStep === TutorialSteps.SIGHT);

return (
<div style={styles['container']}>
{previewDimensions && <SightOverlay style={style.overlay} sight={selectedSight} />}
<div style={style.elementsContainer}>
<div style={style.top}>
<SightGuideline
sightId={selectedSight.id}
sightGuidelines={sightGuidelines}
enableSightGuidelines={enableSightGuidelines}
enableAddDamage={enableAddDamage}
/>
<AddDamageButton onAddDamage={onAddDamage} enableAddDamage={enableAddDamage} />
</div>
<div style={style.bottom}>
<PhotoCaptureHUDCounter
mode={PhotoCaptureMode.SIGHT}
totalSights={sights.length}
sightsTaken={sightsTaken.length}
/>
<SightSlider
sights={sights}
selectedSight={selectedSight}
sightsTaken={sightsTaken}
onSelectedSight={onSelectedSight}
onRetakeSight={onRetakeSight}
images={images}
/>
{showSight && <SightOverlay style={style.overlay} sight={selectedSight} />}
{!tutorialStep && (
<div style={style.elementsContainer}>
<div style={style.top}>
<SightGuideline
sightId={selectedSight.id}
sightGuidelines={sightGuidelines}
enableSightGuidelines={enableSightGuidelines}
enableAddDamage={enableAddDamage}
/>
<AddDamageButton onAddDamage={onAddDamage} enableAddDamage={enableAddDamage} />
</div>
<div style={style.bottom}>
<PhotoCaptureHUDCounter
mode={PhotoCaptureMode.SIGHT}
totalSights={sights.length}
sightsTaken={sightsTaken.length}
/>
<SightSlider
sights={sights}
selectedSight={selectedSight}
sightsTaken={sightsTaken}
onSelectedSight={onSelectedSight}
onRetakeSight={onRetakeSight}
images={images}
/>
</div>
</div>
</div>
)}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CaptureAppConfig, Image, PixelDimensions, Sight } from '@monkvision/typ
import { useResponsiveStyle } from '@monkvision/common';
import { CSSProperties } from 'react';
import { styles } from './PhotoCaptureHUDElementsSight.styles';
import { TutorialSteps } from '../../hooks';

/**
* Props of the PhotoCaptureHUDElementsSight component.
Expand All @@ -16,6 +17,10 @@ export interface PhotoCaptureHUDElementsSightProps
* The currently selected sight in the PhotoCapture component : the sight that the user needs to capture.
*/
selectedSight: Sight;
/**
* The current tutorial step in PhotoCapture component.
*/
tutorialStep: TutorialSteps | null;
/**
* Callback called when the user manually select a new sight.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './SightSlider';
export * from './AddDamageButton';
export * from './SightGuideline';
export { PhotoCaptureHUDElementsSight } from './PhotoCaptureHUDElementsSight';
export { type PhotoCaptureHUDElementsSightProps } from './hooks';
Loading

0 comments on commit 593e3e4

Please sign in to comment.