Commit 971be4de authored by 林生雨's avatar 林生雨

commit :

parent 877d09a4
This diff is collapsed.
...@@ -56,19 +56,52 @@ class AlbumModel { ...@@ -56,19 +56,52 @@ class AlbumModel {
void _onEvent(Object event) { void _onEvent(Object event) {
var map = (event as Map); var map = (event as Map);
// var list = map[_nowDirName]; if (_mainValue == null || _mainValue.length == 0) {
_mainValue.forEach((k, itemList) { _mainValue = map;
var key = map[k]; } else {
if (key != null) { _mainValue.forEach((k, itemList) {
for (int i = 0; i < itemList.length; i++) { var key = map[k];
if (key[i] == null) { if (key != null) {
continue; for (int i = 0; i < itemList.length; i++) {
if (key[i] == null) {
continue;
}
itemList[i].path = key[i]["path"];
itemList[i].realPath = key[i]["realPath"];
} }
itemList[i].path = key[i]["path"];
itemList[i].realPath = key[i]["realPath"];
} }
} });
}); }
// var map = Map<String, List<dynamic>>.from(event);
//
// var newMap = Map<String, List<ScanImageItem>>();
// map.forEach((k, v) {
// var key = newMap["k"];
// if(key==null){
// newMap["k"]=new List<ScanImageItem>();
// }
// v.forEach((value){
// ScanImageItem item=new ScanImageItem();
// item.path=value["path"];
// item.isVideo=value["isVideo"]=="T"?true:false;
// item.during = value["during"] ?? "0";
// newMap["k"].add(item);
// });
// });
// _mainValue=newMap;
// var list = map[_nowDirName];
// _mainValue.forEach((k, itemList) {
// var key = map[k];
// if (key != null) {
// for (int i = 0; i < itemList.length; i++) {
// if (key[i] == null) {
// continue;
// }
// itemList[i].path = key[i]["path"];
// itemList[i].realPath = key[i]["realPath"];
// }
// }
// });
// var recordList=_mainValue[_nowDirName]; // var recordList=_mainValue[_nowDirName];
// List<ScanImageItem> tempList = new List(); // List<ScanImageItem> tempList = new List();
// if (list != null && !list.isEmpty) { // if (list != null && !list.isEmpty) {
...@@ -195,11 +228,38 @@ class AlbumModel { ...@@ -195,11 +228,38 @@ class AlbumModel {
return; return;
} }
AlbumRepository.getInstance().nativeCamera().listen((data) { AlbumRepository.getInstance().nativeCamera().listen((data) {
print("DATTTTTT ${data}"); if (data == null) {
if (data == null || data.isEmpty || data == "") {
// Toast.show(context, "没有拍摄照片"); // Toast.show(context, "没有拍摄照片");
} else { } else {
Navigator.pop(context, data); print(data);
ScanImageItem item = new ScanImageItem();
item.realPath = data["realPath"]==null?null:data["realPath"] as String;
item.path = data["path"] as String;
item.isVideo = false;
String foldName = data["folderName"] as String;
var list = _mainValue[foldName];
if (list == null) {
_mainValue[foldName] = new List();
_mainValue[foldName].add(item);
} else {
list.insert(0, item);
}
_mainValue[MainDir].insert(0, item);
_selectList.add(item.realPath);
bool haveIt = false;
_dirList.forEach((it) {
if (it.dirName == foldName) {
haveIt = true;
it.picCount++;
}
});
if (!haveIt) {
_dirList.add(new DirBean(foldName, 1, File(item.path)));
}
dirLive.notifyView(_dirList);
albumLive.notifyView(_mainValue[_nowDirName]);
// selectSizeLive.notifyView(_selectList.length + _selectVideoList.length);
// Navigator.pop(context, data);
// _selectList.add(data); // _selectList.add(data);
//TODO //TODO
} }
......
...@@ -32,7 +32,6 @@ class AlbumState extends State<AlbumPage> { ...@@ -32,7 +32,6 @@ class AlbumState extends State<AlbumPage> {
_model.initScanImages(context); _model.initScanImages(context);
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
...@@ -177,8 +176,9 @@ class AlbumState extends State<AlbumPage> { ...@@ -177,8 +176,9 @@ class AlbumState extends State<AlbumPage> {
} }
int newIndex = index - 2; int newIndex = index - 2;
if (imgList.data[newIndex] == null || if (imgList.data[newIndex] == null ||
imgList.data[newIndex].path == null|| imgList.data[newIndex].path == null
imgList.data[newIndex].realPath == null) { // || imgList.data[newIndex].realPath == null
) {
return Container(); return Container();
} }
return GestureDetector( return GestureDetector(
...@@ -204,13 +204,25 @@ class AlbumState extends State<AlbumPage> { ...@@ -204,13 +204,25 @@ class AlbumState extends State<AlbumPage> {
color: Colors.grey, color: Colors.grey,
size: 25, size: 25,
), ),
imgList.data[newIndex].isVideo?Icon(Icons.cancel,color: Colors.yellow,):Container(), imgList.data[newIndex].isVideo
? Icon(
Icons.cancel,
color: Colors.yellow,
)
: Container(),
_model.isFullSelect() && !_model.isSelect(newIndex) _model.isFullSelect() && !_model.isSelect(newIndex)
? Container( ? Container(
width: double.maxFinite, width: double.maxFinite,
height: double.maxFinite, height: double.maxFinite,
color: Colors.white60, color: Colors.white60,
) )
: Container(),
imgList.data[newIndex].isVideo&&imgList.data[newIndex].during != null
? Text(
imgList.data[newIndex].during,
style:
TextStyle(fontSize: 20, color: Colors.green),
)
: Container() : Container()
], ],
), ),
......
This diff is collapsed.
...@@ -34,6 +34,11 @@ class ScanImagePlugn { ...@@ -34,6 +34,11 @@ class ScanImagePlugn {
static Future<bool> quitPage(MethodChannel channel) async { static Future<bool> quitPage(MethodChannel channel) async {
return await channel.invokeMethod("quit_page"); return await channel.invokeMethod("quit_page");
} }
static Future<String> ios_album_path(
MethodChannel channel, String path) async {
return await channel.invokeMethod("IOS_IMAGE_BY_PATH", {"path", path});
}
} }
class ScanImageItem { class ScanImageItem {
......
...@@ -23,6 +23,10 @@ class GengmeiFlutterPlugin { ...@@ -23,6 +23,10 @@ class GengmeiFlutterPlugin {
return await ScanImagePlugn.nativeCamera(_channel, authority); return await ScanImagePlugn.nativeCamera(_channel, authority);
} }
static Future<String> ios_album_path(String path) async {
return await ScanImagePlugn.ios_album_path(_channel, path);
}
static Future<bool> quitPage() async { static Future<bool> quitPage() async {
return await ScanImagePlugn.quitPage(_channel); return await ScanImagePlugn.quitPage(_channel);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment