Skip to content

Commit

Permalink
Merge pull request #18 from Apparence-io/fix/flash_ios
Browse files Browse the repository at this point in the history
✨ Add "On" flash mode for iOS
  • Loading branch information
g-apparence authored Sep 7, 2020
2 parents 1cfc890 + 5d26797 commit ca742b6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/ios/Flutter/.last_build_id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9ed35fd658790c3edd7f03fdbc99b18f
e2576089e52ba78a9fa95a7cfec17fb7
6 changes: 6 additions & 0 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,31 @@ PODS:
- camerawesome (0.0.1):
- Flutter
- Flutter (1.0.0)
- integration_test (0.0.1):
- Flutter
- path_provider (0.0.1):
- Flutter

DEPENDENCIES:
- camerawesome (from `.symlinks/plugins/camerawesome/ios`)
- Flutter (from `Flutter`)
- integration_test (from `.symlinks/plugins/integration_test/ios`)
- path_provider (from `.symlinks/plugins/path_provider/ios`)

EXTERNAL SOURCES:
camerawesome:
:path: ".symlinks/plugins/camerawesome/ios"
Flutter:
:path: Flutter
integration_test:
:path: ".symlinks/plugins/integration_test/ios"
path_provider:
:path: ".symlinks/plugins/path_provider/ios"

SPEC CHECKSUMS:
camerawesome: 0f8628efae993cb064ec4f36322e89c237e1064f
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
integration_test: 5ed24a436eb7ec17b6a13046e9bf7ca4a404e59e
path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c
Expand Down
1 change: 0 additions & 1 deletion example/test_driver/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:camerawesome/camerapreview.dart';
import 'package:camerawesome_example/main.dart' as app;
import 'package:camerawesome_example/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:path_provider/path_provider.dart';
Expand Down
3 changes: 1 addition & 2 deletions example/test_driver/app_test.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'dart:io';

import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';
import 'dart:async';

import 'package:integration_test/integration_test_driver.dart';

const String _examplePackage = 'com.apparence.camerawesome_example';
Expand Down
7 changes: 6 additions & 1 deletion ios/Classes/CameraView.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ - (instancetype)initWithCameraSensor:(CameraSensor)sensor result:(nonnull Flutte
[_captureConnection setAutomaticallyAdjustsVideoMirroring:NO];

// By default enable auto flash mode
_flashMode = AVCaptureFlashModeAuto;
_flashMode = AVCaptureFlashModeOff;
_torchMode = AVCaptureTorchModeOff;

_previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:_captureSession];
_previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
Expand Down Expand Up @@ -216,6 +217,10 @@ - (void)setFlashMode:(CameraFlashMode)flashMode {
_torchMode = AVCaptureTorchModeOff;
_flashMode = AVCaptureFlashModeOff;
break;
case On:
_torchMode = AVCaptureTorchModeOff;
_flashMode = AVCaptureFlashModeOn;
break;
case Auto:
_torchMode = AVCaptureTorchModeAuto;
_flashMode = AVCaptureFlashModeAuto;
Expand Down
2 changes: 2 additions & 0 deletions ios/Classes/CamerawesomePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ - (void)_handleFlashMode:(FlutterMethodCall*)call result:(FlutterResult)result
CameraFlashMode flash;
if ([flashMode isEqualToString:@"NONE"]) {
flash = None;
} else if ([flashMode isEqualToString:@"ON"]) {
flash = On;
} else if ([flashMode isEqualToString:@"AUTO"]) {
flash = Auto;
} else if ([flashMode isEqualToString:@"ALWAYS"]) {
Expand Down
1 change: 1 addition & 0 deletions ios/Classes/Constants/CameraFlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

typedef enum {
None, // Flash is disabled
On, // Flash is always enabled when photo is taken
Auto, // Flash is enabled when user take a photo only if necessary
Always, // Flash is enabled anytime, then trigger Auto mode when a photo is taken
} CameraFlashMode;
Expand Down

0 comments on commit ca742b6

Please sign in to comment.