@@ -481,23 +481,31 @@ class CameraPickerState extends State<CameraPicker>
481
481
/// Use the [details] point to set exposure and focus.
482
482
/// 通过点击点的 [details] 设置曝光和对焦。
483
483
void setExposurePoint (TapDownDetails details) {
484
+ // Ignore point update when the new point is less than 8% and higher than
485
+ // 92% of the screen's height.
486
+ if (details.globalPosition.dy < Screens .height / 12 ||
487
+ details.globalPosition.dy > Screens .height / 12 * 11 ) {
488
+ return ;
489
+ }
490
+ realDebugPrint (
491
+ 'Setting new exposure point ('
492
+ 'x: ${details .globalPosition .dx }, '
493
+ 'y: ${details .globalPosition .dy }'
494
+ ')' ,
495
+ );
484
496
_lastExposurePoint.value = Offset (
485
- details.localPosition .dx,
486
- details.localPosition .dy,
497
+ details.globalPosition .dx,
498
+ details.globalPosition .dy,
487
499
);
488
500
_exposurePointDisplayTimer? .cancel ();
489
501
_exposurePointDisplayTimer = Timer (const Duration (seconds: 5 ), () {
490
502
_lastExposurePoint.value = null ;
491
503
});
492
- controller.setExposurePoint (
493
- _lastExposurePoint.value.scale (1 / Screens .width, 1 / Screens .height),
494
- );
495
- realDebugPrint (
496
- 'Setting new exposure point ('
497
- 'x: ${_lastExposurePoint .value .dx }, '
498
- 'y: ${_lastExposurePoint .value .dy }'
499
- ')' ,
500
- );
504
+ controller
505
+ ..setExposureMode (ExposureMode .auto)
506
+ ..setExposurePoint (
507
+ _lastExposurePoint.value.scale (1 / Screens .width, 1 / Screens .height),
508
+ );
501
509
}
502
510
503
511
/// The method to take a picture.
@@ -770,7 +778,10 @@ class CameraPickerState extends State<CameraPicker>
770
778
/// 用户手动设置的曝光点的区域显示
771
779
Widget get _focusingAreaWidget {
772
780
Widget _buildFromPoint (Offset point) {
773
- final double _width = Screens .width / 5 ;
781
+ final double _pointWidth = Screens .width / 5 ;
782
+ const double _exposureControlWidth = 20 ;
783
+ final double _width = _pointWidth + _exposureControlWidth + 2 ;
784
+ final bool _shouldReverseLayout = point.dx > Screens .width / 4 * 3 ;
774
785
775
786
final double _effectiveLeft = math.min (
776
787
Screens .width - _width,
@@ -785,8 +796,25 @@ class CameraPickerState extends State<CameraPicker>
785
796
left: _effectiveLeft,
786
797
top: _effectiveTop,
787
798
width: _width,
788
- height: _width,
789
- child: ExposurePointWidget (key: ValueKey <int >(currentTimeStamp)),
799
+ height: _pointWidth,
800
+ child: Row (
801
+ textDirection:
802
+ _shouldReverseLayout ? TextDirection .rtl : TextDirection .ltr,
803
+ children: < Widget > [
804
+ ExposurePointWidget (
805
+ key: ValueKey <int >(currentTimeStamp),
806
+ size: _pointWidth,
807
+ ),
808
+ const SizedBox (width: 2 ),
809
+ SizedBox .fromSize (
810
+ size: Size (_exposureControlWidth, _pointWidth),
811
+ child: const Icon (
812
+ Icons .wb_sunny_outlined,
813
+ size: _exposureControlWidth,
814
+ ),
815
+ ),
816
+ ],
817
+ ),
790
818
);
791
819
}
792
820
@@ -916,7 +944,8 @@ class CameraPickerState extends State<CameraPicker>
916
944
),
917
945
);
918
946
}
919
- return const SizedBox .expand ();},
947
+ return const SizedBox .expand ();
948
+ },
920
949
),
921
950
_exposureDetectorWidget (context),
922
951
SafeArea (
0 commit comments