2023-01-29 16:57:47 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
2023-01-21 10:37:49 +00:00
|
|
|
import 'package:lightmeter/data/haptics_service.dart';
|
2023-01-29 16:57:47 +00:00
|
|
|
import 'package:lightmeter/data/light_sensor_service.dart';
|
2023-01-21 10:37:49 +00:00
|
|
|
import 'package:lightmeter/data/shared_prefs_service.dart';
|
|
|
|
|
2023-01-26 09:10:23 +00:00
|
|
|
class MeteringInteractor {
|
2023-01-21 10:37:49 +00:00
|
|
|
final UserPreferencesService _userPreferencesService;
|
|
|
|
final HapticsService _hapticsService;
|
2023-01-29 16:57:47 +00:00
|
|
|
final LightSensorService _lightSensorService;
|
2023-01-21 10:37:49 +00:00
|
|
|
|
2023-01-26 09:10:23 +00:00
|
|
|
const MeteringInteractor(
|
2023-01-21 10:37:49 +00:00
|
|
|
this._userPreferencesService,
|
|
|
|
this._hapticsService,
|
2023-01-29 16:57:47 +00:00
|
|
|
this._lightSensorService,
|
2023-01-21 10:37:49 +00:00
|
|
|
);
|
|
|
|
|
2023-01-26 09:10:23 +00:00
|
|
|
double get cameraEvCalibration => _userPreferencesService.cameraEvCalibration;
|
2023-01-29 16:57:47 +00:00
|
|
|
double get lightSensorEvCalibration => _userPreferencesService.lightSensorEvCalibration;
|
2023-01-26 09:10:23 +00:00
|
|
|
|
|
|
|
bool get isHapticsEnabled => _userPreferencesService.haptics;
|
2023-01-21 10:37:49 +00:00
|
|
|
|
|
|
|
/// Executes vibration if haptics are enabled in settings
|
|
|
|
void quickVibration() {
|
|
|
|
if (_userPreferencesService.haptics) _hapticsService.quickVibration();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Executes vibration if haptics are enabled in settings
|
|
|
|
void responseVibration() {
|
|
|
|
if (_userPreferencesService.haptics) _hapticsService.responseVibration();
|
|
|
|
}
|
|
|
|
|
|
|
|
void enableHaptics(bool enable) => _userPreferencesService.haptics = enable;
|
2023-01-29 16:57:47 +00:00
|
|
|
|
|
|
|
Future<bool> hasAmbientLightSensor() async {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
return _lightSensorService.hasSensor();
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Stream<int> luxStream() => _lightSensorService.luxStream();
|
2023-01-21 10:37:49 +00:00
|
|
|
}
|