Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add iOS WeScan support and add more Android options #62

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,22 @@ platform :ios, '13.0'
end
end
```
3. Add this line to your Podfile in your project:

```
pod 'WeScan', :path => '.symlinks/plugins/cuning_document_scanner/ios/WeScan-3.0.0'
```

=> like this below:

```
target 'Runner' do
use_frameworks!
use_modular_headers!
pod 'WeScan', :path => '.symlinks/plugins/cuning_document_scanner/ios/WeScan-3.0.0'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
```

## How to use ?

Expand All @@ -95,9 +111,12 @@ There are some features in Android that allow you to adjust the scanner that wil

```
final imagesPath = await CunningDocumentScanner.getPictures(
noOfPages: 1, // Limit the number of pages to 1
isGalleryImportAllowed, // Allow the user to also pick an image from his gallery
)
androidOptions: const AndroidScannerOptions(
noOfPages: 1, // Limit the number of pages to 1
isGalleryImportAllowed: true, // Allow the user to also pick an image from his gallery
scannerMode: AndroidScannerMode.scannerModeFull,
)
)
```

## Installation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ class CunningDocumentScannerPlugin : FlutterPlugin, MethodCallHandler, ActivityA
if (call.method == "getPictures") {
val noOfPages = call.argument<Int>("noOfPages") ?: 50;
val isGalleryImportAllowed = call.argument<Boolean>("isGalleryImportAllowed") ?: false;
val scannerMode = call.argument<Int>("scannerMode") ?: 1;
this.pendingResult = result
startScan(noOfPages, isGalleryImportAllowed)
startScan(noOfPages, isGalleryImportAllowed, scannerMode)
} else {
result.notImplemented()
}
Expand Down Expand Up @@ -168,12 +169,12 @@ class CunningDocumentScannerPlugin : FlutterPlugin, MethodCallHandler, ActivityA
/**
* add document scanner result handler and launch the document scanner
*/
private fun startScan(noOfPages: Int, isGalleryImportAllowed: Boolean) {
private fun startScan(noOfPages: Int, isGalleryImportAllowed: Boolean,scannerMode: Int) {
val options = GmsDocumentScannerOptions.Builder()
.setGalleryImportAllowed(isGalleryImportAllowed)
.setPageLimit(noOfPages)
.setResultFormats(RESULT_FORMAT_JPEG)
.setScannerMode(SCANNER_MODE_FULL)
.setScannerMode(scannerMode)
.build()
val scanner = GmsDocumentScanning.getClient(options)
scanner.getStartScanIntent(activity).addOnSuccessListener {
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!

pod 'WeScan', :path => '.symlinks/plugins/cunning_document_scanner/ios/WeScan-3.0.0'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

Expand Down
23 changes: 21 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
PODS:
- CocoaLumberjack (3.8.5):
- CocoaLumberjack/Core (= 3.8.5)
- CocoaLumberjack/Core (3.8.5)
- cunning_document_scanner (1.0.0):
- Flutter
- SVGKit
- WeScan
- Flutter (1.0.0)
- path_provider_foundation (0.0.1):
- Flutter
- FlutterMacOS
- permission_handler_apple (9.3.0):
- Flutter
- SVGKit (3.0.0):
- CocoaLumberjack (~> 3.0)
- WeScan (3.0.0)

DEPENDENCIES:
- cunning_document_scanner (from `.symlinks/plugins/cunning_document_scanner/ios`)
- Flutter (from `Flutter`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- WeScan (from `.symlinks/plugins/cunning_document_scanner/ios/WeScan-3.0.0`)

SPEC REPOS:
trunk:
- CocoaLumberjack
- SVGKit

EXTERNAL SOURCES:
cunning_document_scanner:
Expand All @@ -23,13 +37,18 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/path_provider_foundation/darwin"
permission_handler_apple:
:path: ".symlinks/plugins/permission_handler_apple/ios"
WeScan:
:path: ".symlinks/plugins/cunning_document_scanner/ios/WeScan-3.0.0"

SPEC CHECKSUMS:
cunning_document_scanner: 7cb9bd173f7cc7b11696dde98d01492187fc3a67
CocoaLumberjack: 6a459bc897d6d80bd1b8c78482ec7ad05dffc3f0
cunning_document_scanner: 654ba004dbb3bbe54324d560f5c5780229789b2f
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
permission_handler_apple: 036b856153a2b1f61f21030ff725f3e6fece2b78
SVGKit: 1ad7513f8c74d9652f94ed64ddecda1a23864dea
WeScan: f50277f7304d146d9ebc4ebdc1b587df84dcdd8b

PODFILE CHECKSUM: e78c989774f3b5b54daf69ce13097109fe4b0da3
PODFILE CHECKSUM: c1a4e03013e58f8bd901ec6ecbff4df9feb094cc

COCOAPODS: 1.15.2
17 changes: 12 additions & 5 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
11EB18CF2BD261D5002CFE2F /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Main.strings; sourceTree = "<group>"; };
11EB18D02BD261D5002CFE2F /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
1A75B21102973CE41A6E8E7B /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -121,7 +123,6 @@
1A75B21102973CE41A6E8E7B /* Pods-Runner.release.xcconfig */,
554ACEF25A741CCBB5AC6F5D /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -156,7 +157,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand All @@ -172,6 +173,7 @@
knownRegions = (
en,
Base,
fr,
);
mainGroup = 97C146E51CF9000F007C117D;
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
Expand Down Expand Up @@ -287,6 +289,7 @@
isa = PBXVariantGroup;
children = (
97C146FB1CF9000F007C117D /* Base */,
11EB18CF2BD261D5002CFE2F /* fr */,
);
name = Main.storyboard;
sourceTree = "<group>";
Expand All @@ -295,6 +298,7 @@
isa = PBXVariantGroup;
children = (
97C147001CF9000F007C117D /* Base */,
11EB18D02BD261D5002CFE2F /* fr */,
);
name = LaunchScreen.storyboard;
sourceTree = "<group>";
Expand All @@ -306,6 +310,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -359,7 +364,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = F8R24LCAZ8;
DEVELOPMENT_TEAM = KZAYKKLV99;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -378,6 +383,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -433,6 +439,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -488,7 +495,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = F8R24LCAZ8;
DEVELOPMENT_TEAM = KZAYKKLV99;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -511,7 +518,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = F8R24LCAZ8;
DEVELOPMENT_TEAM = KZAYKKLV99;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
13 changes: 8 additions & 5 deletions example/ios/Runner/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--Flutter View Controller-->
Expand All @@ -14,13 +16,14 @@
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-16" y="-40"/>
</scene>
</scenes>
</document>
1 change: 1 addition & 0 deletions example/ios/Runner/fr.lproj/LaunchScreen.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions example/ios/Runner/fr.lproj/Main.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

19 changes: 16 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:io';

import 'package:cunning_document_scanner/cunning_document_scanner.dart';
import 'package:flutter/material.dart';

void main() {
runApp(const MyApp());
Expand Down Expand Up @@ -48,7 +49,19 @@ class _MyAppState extends State<MyApp> {
void onPressed() async {
List<String> pictures;
try {
pictures = await CunningDocumentScanner.getPictures() ?? [];
pictures = await CunningDocumentScanner.getPictures(
androidOptions: const AndroidScannerOptions(
scannerMode: AndroidScannerMode.scannerModeBase,
isGalleryImportAllowed: true,
),
iOSOptions: const IOSScannerOptions(
isGalleryImportAllowed: true,
isFlashAllowed: true,
backgroundColor: Color(0xFF333333),
tintColor: Colors.white,
),
) ??
[];
if (!mounted) return;
setState(() {
_pictures = pictures;
Expand Down
Empty file removed ios/Assets/.gitkeep
Empty file.
Loading
Loading