This commit is contained in:
otsmr 2025-02-13 13:18:08 +01:00
parent 606d377617
commit 1b249e494e

View file

@ -51,6 +51,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
double _basePanY = 0; double _basePanY = 0;
bool sharePreviewIsShown = false; bool sharePreviewIsShown = false;
bool isFlashOn = false; bool isFlashOn = false;
bool showSelfieFlash = false;
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
@override @override
@ -156,7 +157,9 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
}, },
onDoubleTap: () async { onDoubleTap: () async {
cameraState.switchCameraSensor( cameraState.switchCameraSensor(
aspectRatio: CameraAspectRatios.ratio_16_9); aspectRatio: CameraAspectRatios.ratio_16_9,
flash: isFlashOn ? FlashMode.on : FlashMode.none,
);
}, },
), ),
), ),
@ -178,12 +181,15 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
onPressed: () async { onPressed: () async {
cameraState.switchCameraSensor( cameraState.switchCameraSensor(
aspectRatio: aspectRatio:
CameraAspectRatios.ratio_16_9); CameraAspectRatios.ratio_16_9,
flash: isFlashOn
? FlashMode.on
: FlashMode.none,
);
}, },
), ),
// SizedBox(height: 20),
ActionButton( ActionButton(
FontAwesomeIcons.bolt, FontAwesomeIcons.boltLightning,
tooltipText: context.lang.toggleFlashLight, tooltipText: context.lang.toggleFlashLight,
color: isFlashOn color: isFlashOn
? const Color.fromARGB(255, 255, 230, 0) ? const Color.fromARGB(255, 255, 230, 0)
@ -196,7 +202,7 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
isFlashOn = false; isFlashOn = false;
} else { } else {
cameraState.sensorConfig cameraState.sensorConfig
.setFlashMode(FlashMode.always); .setFlashMode(FlashMode.on);
isFlashOn = true; isFlashOn = true;
} }
setState(() {}); setState(() {});
@ -220,9 +226,23 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
const SizedBox(height: 30), const SizedBox(height: 30),
GestureDetector( GestureDetector(
onTap: () async { onTap: () async {
if (cameraState.sensorConfig.flashMode ==
FlashMode.on &&
cameraState.sensorConfig.sensors.first
.position ==
SensorPosition.front) {
setState(() {
showSelfieFlash = true;
});
await Future.delayed(
Duration(milliseconds: 500));
}
cameraState.when( cameraState.when(
onPhotoMode: (picState) => onPhotoMode: (picState) =>
picState.takePhoto()); picState.takePhoto());
setState(() {
showSelfieFlash = false;
});
}, },
onLongPress: () async {}, onLongPress: () async {},
child: Align( child: Align(
@ -262,6 +282,15 @@ class _CameraPreviewViewState extends State<CameraPreviewView> {
), ),
), ),
), ),
if (showSelfieFlash)
Positioned.fill(
child: ClipRRect(
borderRadius: BorderRadius.circular(22),
child: Container(
color: Colors.white,
),
),
),
if (sharePreviewIsShown) if (sharePreviewIsShown)
Positioned.fill( Positioned.fill(
child: BackdropFilter( child: BackdropFilter(