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
2024-05-31 15:55:50 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dbd5250878880833c6a23e0137d95fd02f2b37bc
dbd52508
1 parent
d1ac1192
refactor iOS impl to use well formatted error codes & messages for FlutterError
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
27 deletions
ios/Classes/MobileScannerPlugin.swift
ios/Classes/MobileScannerPlugin.swift
View file @
dbd5250
...
...
@@ -153,20 +153,20 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
}
}
}
catch
MobileScannerError
.
alreadyStarted
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"Called start() while already started!"
,
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
ALREADY_STARTED_ERROR
,
message
:
MobileScannerErrorCodes
.
ALREADY_STARTED_ERROR_MESSAGE
,
details
:
nil
))
}
catch
MobileScannerError
.
noCamera
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"No camera found or failed to open camera!"
,
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
NO_CAMERA_ERROR
,
message
:
MobileScannerErrorCodes
.
NO_CAMERA_ERROR_MESSAGE
,
details
:
nil
))
}
catch
MobileScannerError
.
cameraError
(
let
error
)
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"Error occured when setting up camera!"
,
details
:
error
))
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
CAMERA_ERROR
,
message
:
error
.
localizedDescription
,
details
:
nil
))
}
catch
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"Unknown error occured."
,
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
GENERIC_ERROR
,
message
:
MobileScannerErrorCodes
.
GENERIC_ERROR_MESSAGE
,
details
:
nil
))
}
}
...
...
@@ -189,25 +189,25 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
private
func
setScale
(
_
call
:
FlutterMethodCall
,
_
result
:
@escaping
FlutterResult
)
{
let
scale
=
call
.
arguments
as?
CGFloat
if
(
scale
==
nil
)
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"You must provide a scale when calling setScale!"
,
details
:
nil
))
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
GENERIC_ERROR
,
message
:
MobileScannerErrorCodes
.
INVALID_ZOOM_SCALE_ERROR_MESSAGE
,
details
:
"The invalid zoom scale was nil."
))
return
}
do
{
try
mobileScanner
.
setScale
(
scale
!
)
result
(
nil
)
}
catch
MobileScannerError
.
zoomWhenStopped
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"Called setScale() while stopped!"
,
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
SET_SCALE_WHEN_STOPPED_ERROR
,
message
:
MobileScannerErrorCodes
.
SET_SCALE_WHEN_STOPPED_ERROR_MESSAGE
,
details
:
nil
))
}
catch
MobileScannerError
.
zoomError
(
let
error
)
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"Error while zooming."
,
details
:
error
))
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
GENERIC_ERROR
,
message
:
error
.
localizedDescription
,
details
:
nil
))
}
catch
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"Error while zooming."
,
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
GENERIC_ERROR
,
message
:
MobileScannerErrorCodes
.
GENERIC_ERROR_MESSAGE
,
details
:
nil
))
}
}
...
...
@@ -218,16 +218,16 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
try
mobileScanner
.
resetScale
()
result
(
nil
)
}
catch
MobileScannerError
.
zoomWhenStopped
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"Called resetScale() while stopped!"
,
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
SET_SCALE_WHEN_STOPPED_ERROR
,
message
:
MobileScannerErrorCodes
.
SET_SCALE_WHEN_STOPPED_ERROR_MESSAGE
,
details
:
nil
))
}
catch
MobileScannerError
.
zoomError
(
let
error
)
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"Error while zooming."
,
details
:
error
))
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
GENERIC_ERROR
,
message
:
error
.
localizedDescription
,
details
:
nil
))
}
catch
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
message
:
"Error while zooming."
,
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
GENERIC_ERROR
,
message
:
MobileScannerErrorCodes
.
GENERIC_ERROR_MESSAGE
,
details
:
nil
))
}
}
...
...
@@ -269,7 +269,7 @@ public class MobileScannerPlugin: NSObject, FlutterPlugin {
barcodeScannerOptions
:
scannerOptions
,
callback
:
{
barcodes
,
error
in
if
error
!=
nil
{
DispatchQueue
.
main
.
async
{
result
(
FlutterError
(
code
:
"MobileScanner"
,
result
(
FlutterError
(
code
:
MobileScannerErrorCodes
.
GENERIC_ERROR
,
message
:
error
?
.
localizedDescription
,
details
:
nil
))
}
...
...
Please
register
or
login
to post a comment