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';
|
import 'package:lightmeter/res/dimens.dart';
|
||||||
|
|
||||||
class CameraSpotDetector extends StatefulWidget {
|
class CameraSpotDetector extends StatefulWidget {
|
||||||
final ValueChanged<Offset> onSpotTap;
|
final ValueChanged<Offset?> onSpotTap;
|
||||||
|
|
||||||
const CameraSpotDetector({
|
const CameraSpotDetector({
|
||||||
required this.onSpotTap,
|
required this.onSpotTap,
|
||||||
|
@ -22,6 +22,7 @@ class _CameraSpotDetectorState extends State<CameraSpotDetector> {
|
||||||
builder: (_, constraints) => GestureDetector(
|
builder: (_, constraints) => GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTapDown: (TapDownDetails details) => onViewFinderTap(details, constraints),
|
onTapDown: (TapDownDetails details) => onViewFinderTap(details, constraints),
|
||||||
|
onLongPress: () => onViewFinderTap(null, constraints),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
if (spot != null)
|
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(() {
|
setState(() {
|
||||||
spot = details.localPosition;
|
spot = details?.localPosition;
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.onSpotTap(
|
widget.onSpotTap(
|
||||||
Offset(
|
details != null
|
||||||
details.localPosition.dx / constraints.maxWidth,
|
? Offset(
|
||||||
details.localPosition.dy / constraints.maxHeight,
|
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 {
|
class CameraPreview extends StatefulWidget {
|
||||||
final CameraController? controller;
|
final CameraController? controller;
|
||||||
final CameraErrorType? error;
|
final CameraErrorType? error;
|
||||||
final ValueChanged<Offset> onSpotTap;
|
final ValueChanged<Offset?> onSpotTap;
|
||||||
|
|
||||||
const CameraPreview({
|
const CameraPreview({
|
||||||
this.controller,
|
this.controller,
|
||||||
|
@ -53,7 +53,7 @@ class _CameraPreviewState extends State<CameraPreview> {
|
||||||
|
|
||||||
class _CameraPreviewBuilder extends StatefulWidget {
|
class _CameraPreviewBuilder extends StatefulWidget {
|
||||||
final CameraController controller;
|
final CameraController controller;
|
||||||
final ValueChanged<Offset> onSpotTap;
|
final ValueChanged<Offset?> onSpotTap;
|
||||||
|
|
||||||
const _CameraPreviewBuilder({
|
const _CameraPreviewBuilder({
|
||||||
required this.controller,
|
required this.controller,
|
||||||
|
|
|
@ -57,7 +57,7 @@ class ExposureOffsetResetEvent extends CameraContainerEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExposureSpotChangedEvent extends CameraContainerEvent {
|
class ExposureSpotChangedEvent extends CameraContainerEvent {
|
||||||
final Offset offset;
|
final Offset? offset;
|
||||||
|
|
||||||
const ExposureSpotChangedEvent(this.offset);
|
const ExposureSpotChangedEvent(this.offset);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue