mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2025-03-12 05:10:41 +00:00
added long press to remove metering spot
This commit is contained in:
parent
e029cea713
commit
d5b9448c89
3 changed files with 13 additions and 10 deletions
|
@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:lightmeter/res/dimens.dart';
|
||||
|
||||
class CameraSpotDetector extends StatefulWidget {
|
||||
final ValueChanged<Offset> onSpotTap;
|
||||
final ValueChanged<Offset?> onSpotTap;
|
||||
|
||||
const CameraSpotDetector({
|
||||
required this.onSpotTap,
|
||||
|
@ -22,6 +22,7 @@ class _CameraSpotDetectorState extends State<CameraSpotDetector> {
|
|||
builder: (_, constraints) => GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTapDown: (TapDownDetails details) => onViewFinderTap(details, constraints),
|
||||
onLongPress: () => onViewFinderTap(null, constraints),
|
||||
child: Stack(
|
||||
children: [
|
||||
if (spot != null)
|
||||
|
@ -39,16 +40,18 @@ class _CameraSpotDetectorState extends State<CameraSpotDetector> {
|
|||
);
|
||||
}
|
||||
|
||||
void onViewFinderTap(TapDownDetails details, BoxConstraints constraints) {
|
||||
void onViewFinderTap(TapDownDetails? details, BoxConstraints constraints) {
|
||||
setState(() {
|
||||
spot = details.localPosition;
|
||||
spot = details?.localPosition;
|
||||
});
|
||||
|
||||
widget.onSpotTap(
|
||||
Offset(
|
||||
details.localPosition.dx / constraints.maxWidth,
|
||||
details.localPosition.dy / constraints.maxHeight,
|
||||
),
|
||||
details != null
|
||||
? Offset(
|
||||
details.localPosition.dx / constraints.maxWidth,
|
||||
details.localPosition.dy / constraints.maxHeight,
|
||||
)
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import 'package:lightmeter/screens/metering/components/camera_container/models/c
|
|||
class CameraPreview extends StatefulWidget {
|
||||
final CameraController? controller;
|
||||
final CameraErrorType? error;
|
||||
final ValueChanged<Offset> onSpotTap;
|
||||
final ValueChanged<Offset?> onSpotTap;
|
||||
|
||||
const CameraPreview({
|
||||
this.controller,
|
||||
|
@ -53,7 +53,7 @@ class _CameraPreviewState extends State<CameraPreview> {
|
|||
|
||||
class _CameraPreviewBuilder extends StatefulWidget {
|
||||
final CameraController controller;
|
||||
final ValueChanged<Offset> onSpotTap;
|
||||
final ValueChanged<Offset?> onSpotTap;
|
||||
|
||||
const _CameraPreviewBuilder({
|
||||
required this.controller,
|
||||
|
|
|
@ -57,7 +57,7 @@ class ExposureOffsetResetEvent extends CameraContainerEvent {
|
|||
}
|
||||
|
||||
class ExposureSpotChangedEvent extends CameraContainerEvent {
|
||||
final Offset offset;
|
||||
final Offset? offset;
|
||||
|
||||
const ExposureSpotChangedEvent(this.offset);
|
||||
|
||||
|
|
Loading…
Reference in a new issue