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
a2d54ab0
Commit
a2d54ab0
authored
Nov 01, 2019
by
林生雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
21f5511c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
251 additions
and
47 deletions
+251
-47
workspace.xml
.idea/workspace.xml
+0
-0
Anim.dart
example/lib/AlbumModel/Anim.dart
+82
-0
AlbumModel.dart
example/lib/AlbumModel/page/album/AlbumModel.dart
+37
-0
AlbumPage.dart
example/lib/AlbumModel/page/album/AlbumPage.dart
+4
-1
AlbumPreviewModel.dart
example/lib/AlbumModel/page/preview/AlbumPreviewModel.dart
+13
-0
AlbumPreviewPage.dart
example/lib/AlbumModel/page/preview/AlbumPreviewPage.dart
+55
-0
GengmeiFlutterPlugin.m
ios/Classes/GengmeiFlutterPlugin.m
+60
-46
No files found.
.idea/workspace.xml
View file @
a2d54ab0
This diff is collapsed.
Click to expand it.
example/lib/AlbumModel/Anim.dart
0 → 100644
View file @
a2d54ab0
/*
* @author lsy
* @date 2019-10-14
**/
import
'package:flutter/material.dart'
;
enum
RouteWay
{
SCARE
,
TRAN_RIGHT_TO_LEFT
,
ALP
,
}
class
CustomRoute
extends
PageRouteBuilder
{
final
Widget
widget
;
RouteWay
routeWay
;
CustomRoute
(
this
.
widget
,
{
RouteWay
routeWay
=
RouteWay
.
TRAN_RIGHT_TO_LEFT
})
:
super
(
// 设置过度时间
transitionDuration:
Duration
(
milliseconds:
230
),
// 构造器
pageBuilder:
(
// 上下文和动画
BuildContext
context
,
Animation
<
double
>
animaton1
,
Animation
<
double
>
animaton2
,
)
{
return
widget
;
},
transitionsBuilder:
(
BuildContext
context
,
Animation
<
double
>
animaton1
,
Animation
<
double
>
animaton2
,
Widget
child
,
)
{
// 渐变效果
if
(
routeWay
.
index
==
2
)
{
return
FadeTransition
(
// 从0开始到1
opacity:
Tween
(
begin:
0.0
,
end:
1.0
).
animate
(
CurvedAnimation
(
// 传入设置的动画
parent:
animaton1
,
// 设置效果,快进漫出 这里有很多内置的效果
curve:
Curves
.
fastOutSlowIn
,
)),
child:
child
,
);
}
else
if
(
routeWay
.
index
==
1
)
{
return
SlideTransition
(
position:
Tween
<
Offset
>(
begin:
Offset
(
1.0
,
0.0
),
end:
Offset
(
0.0
,
0.0
))
.
animate
(
CurvedAnimation
(
parent:
animaton1
,
curve:
Curves
.
fastOutSlowIn
)),
child:
child
,
);
}
else
{
return
ScaleTransition
(
scale:
Tween
(
begin:
0.0
,
end:
1.0
).
animate
(
CurvedAnimation
(
parent:
animaton1
,
curve:
Curves
.
fastOutSlowIn
)),
child:
child
,
);
}
// 旋转加缩放动画效果
// return RotationTransition(
// turns: Tween(begin: 0.0,end: 1.0)
// .animate(CurvedAnimation(
// parent: animaton1,
// curve: Curves.fastOutSlowIn,
// )),
// child: ScaleTransition(
// scale: Tween(begin: 0.0,end: 1.0)
// .animate(CurvedAnimation(
// parent: animaton1,
// curve: Curves.fastOutSlowIn
// )),
// child: child,
// ),
// );
});
}
example/lib/AlbumModel/page/album/AlbumModel.dart
View file @
a2d54ab0
...
...
@@ -12,8 +12,11 @@ import 'package:gengmei_flutter_plugin/ScanImagePlugn.dart';
import
'package:gengmei_flutter_plugin/gengmei_flutter_plugin.dart'
;
import
'package:gengmei_flutter_plugin_example/AlbumModel/LiveData.dart'
;
import
'package:gengmei_flutter_plugin_example/AlbumModel/bean/DirBean.dart'
;
import
'package:gengmei_flutter_plugin_example/AlbumModel/page/preview/AlbumPreviewPage.dart'
;
import
'package:gengmei_flutter_plugin_example/AlbumModel/repository/AlbumRepository.dart'
;
import
'../../Anim.dart'
;
const
String
MainDir
=
"IsGengmeiAlbumAllImages"
;
const
String
MainDirExplain
=
"全部相片"
;
...
...
@@ -344,4 +347,38 @@ class AlbumModel {
showPop
=
false
;
albumLive
.
notifyView
(
_mainValue
[
dirName
]);
}
bool
previewItemClick
=
false
;
void
previewItem
(
BuildContext
context
,
int
index
,
String
pageName
)
{
String
path
;
if
(
Platform
.
isAndroid
)
{
path
=
albumLive
.
data
[
index
].
realPath
;
Navigator
.
push
(
context
,
CustomRoute
(
AlbumPreviewPage
(
path
,
pageName
)));
}
else
{
// Navigator.push(
// context, CustomRoute(AlbumPreviewPage(albumLive.data[index].path, pageName)));
if
(
previewItemClick
)
{
return
;
}
previewItemClick
=
true
;
path
=
albumLive
.
data
[
index
].
path
;
iosItem
(
path
,
context
,
(
value
)
{
var
realPath
=
value
[
"realImagePath"
];
Navigator
.
push
(
context
,
CustomRoute
(
AlbumPreviewPage
(
realPath
,
pageName
)));
});
}
}
void
iosItem
(
String
path
,
BuildContext
context
,
Function
fun
)
{
GengmeiFlutterPlugin
.
ios_album_item
(
path
).
then
((
value
)
{
if
(
value
!=
null
)
{
fun
(
Map
<
String
,
String
>.
from
(
value
));
}
previewItemClick
=
false
;
}).
catchError
((
error
)
{
previewItemClick
=
false
;
print
(
error
);
});
}
}
example/lib/AlbumModel/page/album/AlbumPage.dart
View file @
a2d54ab0
...
...
@@ -182,7 +182,10 @@ class AlbumState extends State<AlbumPage> {
return
Container
();
}
return
GestureDetector
(
onTap:
()
=>
_model
.
clickItem
(
context
,
newIndex
),
onTap:
(){
_model
.
previewItem
(
context
,
newIndex
,
"pageName"
);
// _model.clickItem(context, newIndex);
},
child:
Container
(
decoration:
BoxDecoration
(
image:
DecorationImage
(
...
...
example/lib/AlbumModel/page/preview/AlbumPreviewModel.dart
0 → 100644
View file @
a2d54ab0
/*
* @author lsy
* @date 2019-11-01
**/
class
AlbumPreviewModel
{
final
String
imgPath
;
AlbumPreviewModel
(
this
.
imgPath
);
}
\ No newline at end of file
example/lib/AlbumModel/page/preview/AlbumPreviewPage.dart
0 → 100644
View file @
a2d54ab0
/*
* @author lsy
* @date 2019-11-01
**/
import
'dart:io'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/material.dart'
;
import
'package:gengmei_flutter_plugin_example/AlbumModel/page/preview/AlbumPreviewModel.dart'
;
class
AlbumPreviewPage
extends
StatefulWidget
{
AlbumPreviewModel
_model
;
String
fromPage
;
AlbumPreviewPage
(
String
imgPath
,
this
.
fromPage
)
{
_model
=
AlbumPreviewModel
(
imgPath
);
}
@override
State
<
StatefulWidget
>
createState
()
=>
AlbumPreviewState
(
_model
,
fromPage
);
}
class
AlbumPreviewState
extends
State
<
AlbumPreviewPage
>
{
AlbumPreviewModel
_model
;
final
String
fromPage
;
AlbumPreviewState
(
this
.
_model
,
this
.
fromPage
);
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
Text
(
"test"
),
),
body:
ConstrainedBox
(
constraints:
BoxConstraints
.
expand
(),
child:
new
Image
.
file
(
File
(
_model
.
imgPath
,
),
fit:
BoxFit
.
fitWidth
,
)),
);
}
@override
String
pageName
()
{
return
"album_preview"
;
}
@override
String
referrer
()
{
return
fromPage
;
}
}
ios/Classes/GengmeiFlutterPlugin.m
View file @
a2d54ab0
...
...
@@ -44,6 +44,7 @@ NSString *cacheDirectory;
assetCollectionList
=
[
NSMutableArray
array
];
viewController
=
[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
;
concurrentQueue
=
dispatch_queue_create
(
"com.gengmei_flutter_plugin"
,
DISPATCH_QUEUE_CONCURRENT
);
// concurrentQueue=dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
queue
=
dispatch_queue_create
(
"com.gengmei_flutter_plugin"
,
DISPATCH_QUEUE_SERIAL
);
FlutterEventChannel
*
chargingChannel
=
[
FlutterEventChannel
eventChannelWithName
:
@"gengmei_flutter_plugin_event"
...
...
@@ -295,31 +296,33 @@ NSString *cacheDirectory;
// }
//
// 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
)
;
[
data
writeToFile
:
tempTake
atomically
:
YES
];
res
=
nil
;
data
=
nil
;
}
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
[
dict
setObject
:
path
[
i
]
forKey
:
@"path"
];
[
dict
setObject
:
tempTake
forKey
:
@"realImagePath"
];
@synchronized
(
self
)
{
self
.
channelSize
++
;
[
self
.
channelList
addObject
:
dict
];
}
if
(
self
.
channelSize
==
self
.
channelAllSize
){
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
self
.
channelList
];
});
}
});
}];
dispatch_async
(
concurrentQueue
,
^
{
[[
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
)
;
[
data
writeToFile
:
tempTake
atomically
:
YES
];
res
=
nil
;
data
=
nil
;
}
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
[
dict
setObject
:
path
[
i
]
forKey
:
@"path"
];
[
dict
setObject
:
tempTake
forKey
:
@"realImagePath"
];
@synchronized
(
self
)
{
self
.
channelSize
++
;
[
self
.
channelList
addObject
:
dict
];
}
if
(
self
.
channelSize
==
self
.
channelAllSize
){
dispatch_async
(
dispatch_get_main_queue
(),
^
{
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
self
.
channelList
];
});
}
});
}];
});
}
}
}
else
if
([[
self
.
takePhotoMap
allKeys
]
containsObject
:
path
[
i
]]){
...
...
@@ -350,7 +353,7 @@ NSString *cacheDirectory;
PHImageRequestOptions
*
imageRequestOption
=
[[
PHImageRequestOptions
alloc
]
init
];
imageRequestOption
.
synchronous
=
NO
;
imageRequestOption
.
networkAccessAllowed
=
YES
;
imageRequestOption
.
deliveryMode
=
PHImageRequestOptionsDeliveryModeHighQuality
Format
;
// imageRequestOption.deliveryMode=PHImageRequestOptionsDeliveryModeFast
Format;
imageRequestOption
.
resizeMode
=
PHImageRequestOptionsResizeModeFast
;
imageRequestOption
.
version
=
PHImageRequestOptionsVersionUnadjusted
;
NSString
*
tempPath
=
NSTemporaryDirectory
();
...
...
@@ -364,27 +367,38 @@ NSString *cacheDirectory;
[
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
=
1024
.
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
,
1
)
;
[
data
writeToFile
:
tempTake
atomically
:
YES
];
result
=
nil
;
data
=
nil
;
dispatch_async
(
queue
,
^
{
CFAbsoluteTime
start
=
CFAbsoluteTimeGetCurrent
();
int
picWidth
=
[
assets
pixelWidth
];
int
picHeight
=
[
assets
pixelHeight
];
float
tempScareSize
=
1
;
float
limit
=
1024
.
0
;
float
max
=
MAX
(
picWidth
,
picHeight
);
if
(
max
>
limit
){
tempScareSize
=
limit
/
max
;
}
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
[
dict
setObject
:
path
forKey
:
@"path"
];
[
dict
setObject
:
tempTake
forKey
:
@"realImagePath"
];
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
dict
];
}];
CGSize
temp
=
CGSizeMake
(
picWidth
*
tempScareSize
,
picHeight
*
tempScareSize
);
__block
bool
isResult
=
false
;
[[
PHImageManager
defaultManager
]
requestImageForAsset
:
assets
targetSize
:
temp
contentMode
:
PHImageContentModeDefault
options
:
imageRequestOption
resultHandler
:^
(
UIImage
*
_Nullable
result
,
NSDictionary
*
_Nullable
info
)
{
if
(
isResult
){
return
;
}
isResult
=
true
;
@autoreleasepool
{
NSData
*
data
=
UIImageJPEGRepresentation
(
result
,
0
.
7
)
;
[
data
writeToFile
:
tempTake
atomically
:
YES
];
// result=nil;
// data=nil;
}
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
[
dict
setObject
:
path
forKey
:
@"path"
];
[
dict
setObject
:
tempTake
forKey
:
@"realImagePath"
];
dispatch_async
(
dispatch_get_main_queue
(),
^
{
NSLog
(
@"压缩预览图片耗时:%f ms"
,(
CFAbsoluteTimeGetCurrent
()
-
start
)
*
1000
);
[[
ResultManager
sharedSingleton
]
resultSuccess
:[
NSNumber
numberWithLong
:
resultTemp
]
:
dict
];
});
}];
});
}
}
else
if
([[
self
.
takePhotoMap
allKeys
]
containsObject
:
path
]){
NSMutableDictionary
*
dict
=
[[
NSMutableDictionary
alloc
]
init
];
...
...
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