Skip to content

Commit

Permalink
⚡️ Reset exposure offset when update exposure point.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Jan 28, 2021
1 parent fc645bc commit 796447f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/src/widget/camera_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,9 @@ class CameraPickerState extends State<CameraPicker>

/// Use the [details] point to set exposure and focus.
/// 通过点击点的 [details] 设置曝光和对焦。
void setExposureAndFocusPoint(TapUpDetails details) {
Future<void> setExposureAndFocusPoint(TapUpDetails details) async {
assert(controller != null);
_isExposureModeDisplays.value = false;
// Ignore point update when the new point is less than 8% and higher than
// 92% of the screen's height.
if (details.globalPosition.dy < Screens.height / 12 ||
Expand All @@ -593,6 +594,13 @@ class CameraPickerState extends State<CameraPicker>
);
_restartPointDisplayTimer();
_currentExposureOffset.value = 0;
if (_exposureMode.value == ExposureMode.locked) {
_exposureMode.value = ExposureMode.auto;
await Future.wait(<Future<void>>[
controller.setExposureOffset(0),
controller.setExposureMode(ExposureMode.auto),
]);
}
controller.setExposurePoint(
_lastExposurePoint.value.scale(1 / Screens.width, 1 / Screens.height),
);
Expand All @@ -601,10 +609,6 @@ class CameraPickerState extends State<CameraPicker>
_lastExposurePoint.value.scale(1 / Screens.width, 1 / Screens.height),
);
}
if (_exposureMode.value == ExposureMode.locked) {
_exposureMode.value = ExposureMode.auto;
}
_isExposureModeDisplays.value = false;
}

/// Update the exposure offset using the exposure controller.
Expand Down

0 comments on commit 796447f

Please sign in to comment.