Architecture¶
GeoQibla is a small KMP Compose library with a common public API and platform-specific service implementations.
Common API¶
The common source set contains:
GeoQiblaScreenfor the default UI.QiblaControllerandrememberQiblaController.QiblaConfigfor runtime thresholds.QiblaStateand related state models.QiblaStyle,QiblaStrings, andQiblaSlots.- Public reusable composables for dial, message, and status display.
Platform Services¶
QiblaPlatformServices is internal. It abstracts permission requests, location observation, orientation observation, settings actions, and haptics.
Android and iOS provide actual implementations for rememberQiblaPlatformServices() and currentTimeMillis().
State Resolver Priority¶
The controller reduces raw platform inputs into QiblaUiState with this priority:
- Error message.
- Not started.
- Location permission.
- Location services disabled.
- Missing location fix.
- Missing heading data.
- Tilt warning.
- Calibration warning.
- Stable alignment.
- Near Qibla.
- Ready.
Bearing and Distance Math¶
QiblaMath calculates:
- Bearing from the current location to the Kaaba.
- Distance to the Kaaba using a spherical earth radius.
- Normalized compass degrees.
- Shortest angular distance for left/right adjustment.
- Magnetic-to-true azimuth conversion.
- Smoothed heading values.
Alignment Tracker¶
QiblaAlignmentTracker separates near and aligned states. Near alignment is immediate within nearDegrees. Stable alignment requires the heading to remain within alignedDegrees for stableAlignedDurationMillis.
Tests¶
The shared tests cover Qibla math, config validation, UI state resolution, and alignment tracking.