From 9e41d0be85c2dc512f51f09777a435327be157d6 Mon Sep 17 00:00:00 2001 From: Amit Rawal Date: Fri, 1 Mar 2019 15:24:38 +0530 Subject: [PATCH 1/4] made changes to ensure that the iOS plugin works. --- ios/Classes/FlutterGallaryPlugin.m | 2 +- ios/{flutter_gallary_plugin.podspec => image_gallery.podspec} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename ios/{flutter_gallary_plugin.podspec => image_gallery.podspec} (92%) diff --git a/ios/Classes/FlutterGallaryPlugin.m b/ios/Classes/FlutterGallaryPlugin.m index 920c2ef..5a3c7dd 100644 --- a/ios/Classes/FlutterGallaryPlugin.m +++ b/ios/Classes/FlutterGallaryPlugin.m @@ -1,5 +1,5 @@ #import "FlutterGallaryPlugin.h" -#import +#import @implementation FlutterGallaryPlugin + (void)registerWithRegistrar:(NSObject*)registrar { diff --git a/ios/flutter_gallary_plugin.podspec b/ios/image_gallery.podspec similarity index 92% rename from ios/flutter_gallary_plugin.podspec rename to ios/image_gallery.podspec index 5d4b0c8..cdbeb0a 100644 --- a/ios/flutter_gallary_plugin.podspec +++ b/ios/image_gallery.podspec @@ -2,7 +2,7 @@ # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html # Pod::Spec.new do |s| - s.name = 'flutter_gallary_plugin' + s.name = 'image_gallery' s.version = '0.0.1' s.summary = 'A new Flutter plugin.' s.description = <<-DESC From 1422c5ffe70536244b6a489afc0424c1744f2b45 Mon Sep 17 00:00:00 2001 From: Nitesh Meshram Date: Mon, 20 May 2019 15:18:38 +0530 Subject: [PATCH 2/4] 1. iOS code fixes --- example/ios/Runner.xcodeproj/project.pbxproj | 34 +++++++++---------- .../xcshareddata/xcschemes/Runner.xcscheme | 4 +-- example/lib/main.dart | 19 +++++++---- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index aa361cb..7f92fc7 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; - 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; @@ -16,7 +15,6 @@ 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -41,7 +39,6 @@ 00A09835F4A6656C86FC52A1 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 4A6B1AB9FD4339FF50711893 /* 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 = ""; }; @@ -85,7 +82,6 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( - 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 9740EEBA1CF902C7004384FC /* Flutter.framework */, @@ -177,14 +173,14 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = SYLT36L949; + DevelopmentTeam = X5E35DL2Y9; LastSwiftMigration = 0910; - ProvisioningStyle = Manual; + ProvisioningStyle = Automatic; }; }; }; @@ -213,9 +209,7 @@ files = ( 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, - 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, - 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -283,14 +277,14 @@ inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", - "${BUILT_PRODUCTS_DIR}/flutter_gallary_plugin/flutter_gallary_plugin.framework", + "${BUILT_PRODUCTS_DIR}/image_gallery/image_gallery.framework", ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( ); outputPaths = ( "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_gallary_plugin.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_gallery.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; @@ -345,12 +339,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -399,12 +395,14 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -440,9 +438,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = SYLT36L949; + DEVELOPMENT_TEAM = X5E35DL2Y9; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -456,7 +455,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.successive.adhoc.flutterGallaryPluginExample; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = AdHocDevelopment; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = On; @@ -471,9 +470,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; - DEVELOPMENT_TEAM = SYLT36L949; + DEVELOPMENT_TEAM = X5E35DL2Y9; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -487,7 +487,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = com.successive.adhoc.flutterGallaryPluginExample; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = AdHocDevelopment; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 4.0; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 1263ac8..e4f93ed 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +45,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/example/lib/main.dart b/example/lib/main.dart index ff3c62f..64ee7d6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -16,6 +16,8 @@ class MyApp extends StatefulWidget { class _MyAppState extends State { List allImage = new List(); +// var data = allImageTemp[i] as Map; + @override void initState() { super.initState(); @@ -56,18 +58,23 @@ class _MyAppState extends State { } List _buildGridTileList(int count) { - return List.generate( count, (int index) => - Container(child: Image.file(File(allImage[index].toString()), + Container(child: Image.file(File( + _getFilePath(index)), +// Container(child: Image.file(File( +// allImage[index].toString()), width: 96.0, height: 96.0, - fit: BoxFit.contain,))); - } - - + fit: BoxFit.contain,) + )); + } + String _getFilePath(int itemIndex){ + var data = allImage[itemIndex] as Map; + return data['thumbailPath'].toString(); + } } From 580de2e6bf759ca638b1c1ef8326b041f072f605 Mon Sep 17 00:00:00 2001 From: Nitesh Meshram Date: Mon, 20 May 2019 16:44:06 +0530 Subject: [PATCH 3/4] Plugin changes for ios --- ios/Classes/SwiftFlutterGallaryPlugin.swift | 80 ++++++++++++++++----- lib/image_gallery.dart | 2 +- pubspec.lock | 2 +- 3 files changed, 63 insertions(+), 21 deletions(-) diff --git a/ios/Classes/SwiftFlutterGallaryPlugin.swift b/ios/Classes/SwiftFlutterGallaryPlugin.swift index ee3420b..2d9f5ec 100644 --- a/ios/Classes/SwiftFlutterGallaryPlugin.swift +++ b/ios/Classes/SwiftFlutterGallaryPlugin.swift @@ -23,8 +23,11 @@ public class SwiftFlutterGallaryPlugin: NSObject, FlutterPlugin { let fetchOptions = PHFetchOptions() fetchOptions.sortDescriptors = [NSSortDescriptor(key:"creationDate", ascending: true)] - let fetchResult = PHAsset.fetchAssets(with: PHAssetMediaType.image, options: fetchOptions) + fetchOptions.predicate = NSPredicate(format: "mediaType = %d || mediaType = %d", PHAssetMediaType.image.rawValue, PHAssetMediaType.video.rawValue) + + let fetchResult = PHAsset.fetchAssets(with: fetchOptions) var allImages = [String]() + var allAssetsDict = [NSDictionary]() var totalItration = 0 print("fetchResult.count : \(fetchResult.count)") @@ -33,35 +36,74 @@ public class SwiftFlutterGallaryPlugin: NSObject, FlutterPlugin { for index in 0.. Void)){ + if self.mediaType == .image { + let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions() + options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in + return true + } + self.requestContentEditingInput(with: options, completionHandler: {(contentEditingInput: PHContentEditingInput?, info: [AnyHashable : Any]) -> Void in + completionHandler(contentEditingInput!.fullSizeImageURL as URL?, "image") + }) + } else if self.mediaType == .video { + let options: PHVideoRequestOptions = PHVideoRequestOptions() + options.version = .original + PHImageManager.default().requestAVAsset(forVideo: self, options: options, resultHandler: {(asset: AVAsset?, audioMix: AVAudioMix?, info: [AnyHashable : Any]?) -> Void in + if let urlAsset = asset as? AVURLAsset { + let localVideoUrl: URL = urlAsset.url as URL + completionHandler(localVideoUrl, "video") + } else { + completionHandler(nil, "") + } + }) + } + } +} diff --git a/lib/image_gallery.dart b/lib/image_gallery.dart index f9502fd..980275a 100644 --- a/lib/image_gallery.dart +++ b/lib/image_gallery.dart @@ -7,7 +7,7 @@ class FlutterGallaryPlugin { const MethodChannel('image_gallery'); - static Future get getAllImages async { + static Future get getAllImages async { List object = await _channel.invokeMethod('getAllImages'); return object; } diff --git a/pubspec.lock b/pubspec.lock index 91e001e..74d4e6c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -40,4 +40,4 @@ packages: source: hosted version: "2.0.8" sdks: - dart: ">=2.0.0-dev.68.0 <3.0.0" + dart: ">=2.2.0 <3.0.0" From d7a1cee1ceeb997dcef154bf7678245f03f95f1d Mon Sep 17 00:00:00 2001 From: Nitesh Meshram Date: Mon, 20 May 2019 17:20:55 +0530 Subject: [PATCH 4/4] Added all the files --- .DS_Store | Bin 0 -> 6148 bytes .idea/codeStyles/Project.xml | 29 +++ .idea/image_gallery.iml | 19 ++ .idea/libraries/Dart_SDK.xml | 28 +++ .idea/libraries/Flutter_Plugins.xml | 9 + .idea/modules.xml | 8 + .idea/vcs.xml | 7 + .idea/workspace.xml | 332 ++++++++++++++++++++++++++++ .packages | 8 + 9 files changed, 440 insertions(+) create mode 100644 .DS_Store create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/image_gallery.iml create mode 100644 .idea/libraries/Dart_SDK.xml create mode 100644 .idea/libraries/Flutter_Plugins.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 .packages diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4c318644372e77c3eb80ed92628070aed4bc739d GIT binary patch literal 6148 zcmeHK%}T>S5T317Hx;o5L65n3^Uz|oUW8EV!J81#gG!swU;}AV+SI7ElGo5T@(Fw$ zXLh%uRu5i8$_&hYv-7jdehK>n0HQJKQ~}BWAW;bm7B=4q#YtzRU_69EjnRh)0zVt} z{b(ke9siL5`gY3@z%6*tgAd;?@iFq^_oHx_Rw}QeuuxoFT9&dTORJ?Tx0_^c>ZPM$ z!y8;s@5D>HzOhe}Bzm_!|11o$R(bs}iBm6(gMlgzI{~I#o`-QK$r{Nh?hMs9t`10P zNvl=f9FJ@D-EF(Jvp?Ck$Mt%J?7hjvk{esqgX4DZ?tc6*d3@5`3j7U~tQnlbGa6r( zdE*Y^D2cBzGOe0sGcp6r05dS>447?CuFUy5d3nqLGw^!`Xn(L#2_1vEMzwWdL)S-& z7YRwwrndy4ZO}28Ys3hO(4~mFRG24*(B + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/image_gallery.iml b/.idea/image_gallery.iml new file mode 100644 index 0000000..ee5a4b1 --- /dev/null +++ b/.idea/image_gallery.iml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml new file mode 100644 index 0000000..63a6481 --- /dev/null +++ b/.idea/libraries/Dart_SDK.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml new file mode 100644 index 0000000..53449da --- /dev/null +++ b/.idea/libraries/Flutter_Plugins.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7e5ecdb --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..d09f557 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..a6c6367 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,332 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Code style issuesJava + + + Dart + + + JSON and JSON5 + + + Java + + + Naming conventionsJava + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +