Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
mobile_scanner
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Navaron Bracke
2023-10-31 11:12:28 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a56d397fa239373a8f434fdbaf62066c593f1962
a56d397f
1 parent
7d72a315
refactor iOS toggle torch
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
ios/Classes/MobileScanner.swift
ios/Classes/MobileScanner.swift
View file @
a56d397
...
...
@@ -273,19 +273,16 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
device
=
nil
}
/// Toggle the flashlight between on and off
/// Toggle the flashlight between on and off
.
func
toggleTorch
(
_
torch
:
AVCaptureDevice
.
TorchMode
)
throws
{
if
(
device
==
nil
)
{
throw
MobileScannerError
.
torchWhenStopped
if
(
device
==
nil
||
!
device
.
hasTorch
||
!
device
.
isTorchAvailable
)
{
return
}
if
(
device
.
hasTorch
&&
device
.
isTorchAvailable
)
{
do
{
try
device
.
lockForConfiguration
()
if
(
device
.
torchMode
!=
torch
)
{
device
.
lockForConfiguration
()
device
.
torchMode
=
torch
device
.
unlockForConfiguration
()
}
catch
{
throw
MobileScannerError
.
torchError
(
error
)
}
}
}
...
...
Please
register
or
login
to post a comment