Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
flutter_plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林生雨
flutter_plugin
Commits
732b57d5
Commit
732b57d5
authored
Nov 01, 2019
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coomit
parent
9e406c65
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
26 deletions
+85
-26
workspace.xml
.idea/workspace.xml
+10
-13
GengmeiFlutterPlugin.m
ios/Classes/GengmeiFlutterPlugin.m
+66
-13
ScanImagePlugn.dart
lib/ScanImagePlugn.dart
+5
-0
gengmei_flutter_plugin.dart
lib/gengmei_flutter_plugin.dart
+4
-0
No files found.
.idea/workspace.xml
View file @
732b57d5
...
...
@@ -5,12 +5,7 @@
<option
name=
"TOOL_WINDOW_CONFIGURED_FILTER"
value=
"Show only selected application"
/>
</component>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"5be6bbb5-7d6e-4540-a24f-d2b3bf78b3ba"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/ios/Classes/GengmeiFlutterPlugin.m"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/example/ios/.symlinks/plugins/gengmei_flutter_plugin/ios/Classes/GengmeiFlutterPlugin.m"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
afterDir=
"false"
/>
</list>
<list
default=
"true"
id=
"5be6bbb5-7d6e-4540-a24f-d2b3bf78b3ba"
name=
"Default Changelist"
comment=
""
/>
<ignored
path=
"$PROJECT_DIR$/.dart_tool/"
/>
<ignored
path=
"$PROJECT_DIR$/.idea/"
/>
<ignored
path=
"$PROJECT_DIR$/.pub/"
/>
...
...
@@ -106,8 +101,8 @@
<file
pinned=
"false"
current-in-tab=
"false"
>
<entry
file=
"file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"11
61
6"
>
<caret
line=
"54
9"
column=
"22"
selection-start-line=
"549"
selection-start-column=
"22"
selection-end-line=
"549
"
selection-end-column=
"22"
/>
<state
relative-caret-position=
"11
50
6"
>
<caret
line=
"54
4"
column=
"22"
selection-start-line=
"544"
selection-start-column=
"22"
selection-end-line=
"544
"
selection-end-column=
"22"
/>
</state>
</provider>
</entry>
...
...
@@ -188,7 +183,8 @@
</option>
</component>
<component
name=
"ProjectFrameBounds"
extendedState=
"6"
>
<option
name=
"y"
value=
"35"
/>
<option
name=
"x"
value=
"-33"
/>
<option
name=
"y"
value=
"23"
/>
<option
name=
"width"
value=
"1440"
/>
<option
name=
"height"
value=
"811"
/>
</component>
...
...
@@ -306,8 +302,9 @@
</component>
<component
name=
"ToolWindowManager"
>
<frame
x=
"9"
y=
"23"
width=
"1440"
height=
"811"
extended-state=
"6"
/>
<editor
active=
"true"
/>
<layout>
<window_info
active=
"true"
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.19742489"
/>
<window_info
content_ui=
"combo"
id=
"Project"
order=
"0"
visible=
"true"
weight=
"0.19742489"
/>
<window_info
id=
"Captures"
order=
"1"
side_tool=
"true"
/>
<window_info
id=
"Structure"
order=
"2"
side_tool=
"true"
/>
<window_info
id=
"Image Layers"
order=
"3"
/>
...
...
@@ -322,7 +319,7 @@
<window_info
anchor=
"bottom"
id=
"Android Profiler"
order=
"3"
show_stripe_button=
"false"
/>
<window_info
anchor=
"bottom"
id=
"Logcat"
order=
"4"
weight=
"0.4534075"
/>
<window_info
anchor=
"bottom"
id=
"Debug"
order=
"5"
/>
<window_info
anchor=
"bottom"
id=
"Terminal"
order=
"6"
visible=
"true"
weight=
"0.29346314"
/>
<window_info
a
ctive=
"true"
a
nchor=
"bottom"
id=
"Terminal"
order=
"6"
visible=
"true"
weight=
"0.29346314"
/>
<window_info
anchor=
"bottom"
id=
"Event Log"
order=
"7"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Flutter Performance"
order=
"8"
side_tool=
"true"
/>
<window_info
anchor=
"bottom"
id=
"Version Control"
order=
"9"
/>
...
...
@@ -534,8 +531,8 @@
</entry>
<entry
file=
"file://$PROJECT_DIR$/ios/Classes/GengmeiFlutterPlugin.m"
>
<provider
selected=
"true"
editor-type-id=
"text-editor"
>
<state
relative-caret-position=
"11
61
6"
>
<caret
line=
"54
9"
column=
"22"
selection-start-line=
"549"
selection-start-column=
"22"
selection-end-line=
"549
"
selection-end-column=
"22"
/>
<state
relative-caret-position=
"11
50
6"
>
<caret
line=
"54
4"
column=
"22"
selection-start-line=
"544"
selection-start-column=
"22"
selection-end-line=
"544
"
selection-end-column=
"22"
/>
</state>
</provider>
</entry>
...
...
ios/Classes/GengmeiFlutterPlugin.m
View file @
732b57d5
...
...
@@ -25,7 +25,7 @@
@end
@implementation
GengmeiFlutterPlugin
dispatch_queue_t
concurrentQueue
;
FlutterEventSink
_eventSink
;
NSMutableArray
<
AlbumItem
*>
*
assetCollectionList
;
UIViewController
*
viewController
;
...
...
@@ -43,7 +43,7 @@ NSString *cacheDirectory;
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
assetCollectionList
=
[
NSMutableArray
array
];
viewController
=
[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
;
// q
ueue = dispatch_queue_create("com.gengmei_flutter_plugin", DISPATCH_QUEUE_CONCURRENT);
concurrentQ
ueue
=
dispatch_queue_create
(
"com.gengmei_flutter_plugin"
,
DISPATCH_QUEUE_CONCURRENT
);
queue
=
dispatch_queue_create
(
"com.gengmei_flutter_plugin"
,
DISPATCH_QUEUE_SERIAL
);
FlutterEventChannel
*
chargingChannel
=
[
FlutterEventChannel
eventChannelWithName
:
@"gengmei_flutter_plugin_event"
...
...
@@ -228,7 +228,7 @@ NSString *cacheDirectory;
NSArray
<
NSString
*>
*
path
=
call
.
arguments
;
long
resultTemp
=
self
.
resultKey
;
if
(
path
!=
nil
){
dispatch_async
(
q
ueue
,
^
{
dispatch_async
(
concurrentQ
ueue
,
^
{
[
self
.
channelList
removeAllObjects
];
if
(
path
.
count
==
0
){
dispatch_async
(
dispatch_get_main_queue
(),
^
{
...
...
@@ -285,18 +285,20 @@ NSString *cacheDirectory;
});
}
}
else
{
int
picWidth
=
[
assets
pixelWidth
];
int
picHeight
=
[
assets
pixelHeight
];
float
tempScareSize
=
1
;
float
limit
=
1560
.
0
;
float
max
=
MAX
(
picWidth
,
picHeight
);
if
(
max
>
limit
){
tempScareSize
=
limit
/
max
;
}
CGSize
temp
=
CGSizeMake
(
picWidth
*
tempScareSize
,
picHeight
*
tempScareSize
);
//
int picWidth=[assets pixelWidth];
//
int picHeight=[assets pixelHeight];
//
float tempScareSize=1;
//
float limit=1560.0;
//
float max=MAX(picWidth, picHeight);
//
if(max>limit){
//
tempScareSize=limit/max;
//
}
//
//
CGSize temp=CGSizeMake(picWidth*tempScareSize, picHeight*tempScareSize);
[[
PHImageManager
defaultManager
]
requestImageDataForAsset
:
assets
options
:
imageRequestOption
resultHandler
:^
(
NSData
*
_Nullable
imageData
,
NSString
*
_Nullable
dataUTI
,
UIImageOrientation
orientation
,
NSDictionary
*
_Nullable
info
)
{
// [[PHImageManager defaultManager] requestImageForAsset:assets targetSize:temp contentMode:PHImageContentModeDefault options:imageRequestOption resultHandler:^(UIImage * _Nullable res, NSDictionary * _Nullable info) {
dispatch_async
(
concurrentQueue
,
^
{
@autoreleasepool
{
UIImage
*
res
=
[
UIImage
imageWithData
:
imageData
];
NSData
*
data
=
UIImageJPEGRepresentation
(
res
,
0
.
8
)
;
...
...
@@ -316,6 +318,7 @@ NSString *cacheDirectory;
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
self
.
channelList
];
});
}
});
}];
}
}
...
...
@@ -341,6 +344,56 @@ NSString *cacheDirectory;
}
else
{
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
nil
];
}
}
else
if
([
@"IOS_IMAGE_ITEM"
isEqualToString
:
call
.
method
]){
long
resultTemp
=
self
.
resultKey
;
NSString
*
path
=
call
.
arguments
;
PHImageRequestOptions
*
imageRequestOption
=
[[
PHImageRequestOptions
alloc
]
init
];
imageRequestOption
.
synchronous
=
NO
;
imageRequestOption
.
networkAccessAllowed
=
YES
;
imageRequestOption
.
deliveryMode
=
PHImageRequestOptionsDeliveryModeHighQualityFormat
;
imageRequestOption
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
imageRequestOption
.
version
=
PHImageRequestOptionsVersionUnadjusted
;
NSString
*
tempPath
=
NSTemporaryDirectory
();
NSFileManager
*
fileManager
=
[
NSFileManager
defaultManager
];
if
([[
self
.
scanMap
allKeys
]
containsObject
:
path
]){
NSString
*
tempTake
=
[
tempPath
stringByAppendingPathComponent
:[
path
lastPathComponent
]];
PHAsset
*
assets
=
self
.
scanMap
[
path
];
if
([
fileManager
fileExistsAtPath
:
tempTake
]){
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
[
dict
setObject
:
path
forKey
:
@"path"
];
[
dict
setObject
:
tempTake
forKey
:
@"realImagePath"
];
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
dict
];
}
else
{
int
picWidth
=
[
assets
pixelWidth
];
int
picHeight
=
[
assets
pixelHeight
];
float
tempScareSize
=
1
;
float
limit
=
1560
.
0
;
float
max
=
MAX
(
picWidth
,
picHeight
);
if
(
max
>
limit
){
tempScareSize
=
limit
/
max
;
}
CGSize
temp
=
CGSizeMake
(
picWidth
*
tempScareSize
,
picHeight
*
tempScareSize
);
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
assets
targetSize
:
temp
contentMode
:
PHImageContentModeDefault
options
:
imageRequestOption
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
@autoreleasepool
{
NSData
*
data
=
UIImageJPEGRepresentation
(
result
,
0
.
8
)
;
[
data
writeToFile
:
tempTake
atomically
:
YES
];
result
=
nil
;
data
=
nil
;
}
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
[
dict
setObject
:
path
forKey
:
@"path"
];
[
dict
setObject
:
tempTake
forKey
:
@"realImagePath"
];
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
dict
];
}];
}
}
else
if
([[
self
.
takePhotoMap
allKeys
]
containsObject
:
path
]){
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
[
dict
setObject
:
path
forKey
:
@"path"
];
[
dict
setObject
:
self
.
takePhotoMap
[
path
]
forKey
:
@"realImagePath"
];
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
dict
];
}
else
{
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
nil
];
}
}
else
{
result
(
FlutterMethodNotImplemented
);
}
...
...
lib/ScanImagePlugn.dart
View file @
732b57d5
...
...
@@ -46,6 +46,11 @@ class ScanImagePlugn {
MethodChannel
channel
,
List
<
String
>
path
)
async
{
return
await
channel
.
invokeMethod
(
"IOS_IMAGE_BY_PATH"
,
path
);
}
static
Future
<
Map
>
ios_album_item
(
MethodChannel
channel
,
String
path
)
async
{
return
await
channel
.
invokeMethod
(
"IOS_IMAGE_ITEM"
,
path
);
}
}
class
ScanImageItem
{
...
...
lib/gengmei_flutter_plugin.dart
View file @
732b57d5
...
...
@@ -27,6 +27,10 @@ class GengmeiFlutterPlugin {
return
await
ScanImagePlugn
.
ios_album_path
(
_channel
,
path
);
}
static
Future
<
Map
>
ios_album_item
(
String
path
)
async
{
return
await
ScanImagePlugn
.
ios_album_item
(
_channel
,
path
);
}
static
Future
<
bool
>
quitPage
()
async
{
return
await
ScanImagePlugn
.
quitPage
(
_channel
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment