Page - AR Measure

Screen: AppRoute.arMeasure File: Utiliship/Features/ARMeasure/ARMeasureView.swift ViewModel: Utiliship/Features/ARMeasure/ARMeasureViewModel.swift Use Case: Utiliship/Features/ARMeasure/ARMeasureUseCase.swift

Purpose

AR-powered distance and surface measurement using ARKit. Two modes: Walk (place start/end points by walking the physical path; device tracks cumulative distance) and Visual (detect horizontal planes in AR scene, estimate width × height). Results show cm or m depending on magnitude. Users can capture a screenshot and save the measurement.

Component Tree

ARMeasureView
└── ZStack
    ├── ARVisualView          — wraps ARView (RealityKit); full screen
    │   └── ARViewContainer   — UIViewRepresentable bridging ARView
    ├── trackingStatusBanner  — state.trackingStatusText (shown when not ready)
    ├── modePicker            — state.selectedMode (.walk / .visual)
    ├── distanceDisplay       — state.formattedDistance
    ├── planeInfoCard         — state.bestPlane (visual mode only)
    ├── controlRow
    │   ├── startStopButton   — enabled when state.isReadyToStart or state.canStop
    │   ├── resetButton       — enabled when state.canReset
    │   └── captureButton     — enabled when state.canCapture (visual mode)
    └── screenshotConfirmation — shown when state.screenshotSaved

ViewModel State

FieldTypeDescription
isARSupportedBoolFalse on devices without ARKit
selectedModeMeasurementMode.walk or .visual
isSessionActiveBoolARSession is running
isRecordingBoolActively accumulating distance (walk mode)
trackingStateTrackingState.notAvailable, .limited, .normal
currentDistanceDoubleMetres accumulated or measured
detectedPlanes[DetectedPlane]All planes detected in current AR scene
bestPlaneDetectedPlane?Largest / most confident plane (visual mode)
lastResultMeasurementResult?Completed measurement record
errorMessageString?AR session or device error
screenshotSavedBoolTriggers confirmation banner

Computed display helpers: formattedDistance (cm / m), formattedWidth, isReadyToStart, canStop, canReset, canCapture.

Data Flow