Commit 2614a897 authored by 林生雨's avatar 林生雨

fix

parent 0431ebee
package io.flutter.plugins;
import io.flutter.plugin.common.PluginRegistry;
import com.taobao.idlefish.flutterboost.FlutterBoostPlugin;
import com.idlefish.flutterboost.FlutterBoostPlugin;
import com.example.flutter_drag_scale.FlutterDragScalePlugin;
import com.example.gengmei_flutter_plugin.GengmeiFlutterPlugin;
import io.flutter.plugins.pathprovider.PathProviderPlugin;
import com.tekartik.sqflite.SqflitePlugin;
import fleamarket.taobao.com.xservicekit.XserviceKitPlugin;
/**
* Generated file. Do not edit.
......@@ -16,12 +15,11 @@ public final class GeneratedPluginRegistrant {
if (alreadyRegisteredWith(registry)) {
return;
}
FlutterBoostPlugin.registerWith(registry.registrarFor("com.taobao.idlefish.flutterboost.FlutterBoostPlugin"));
FlutterBoostPlugin.registerWith(registry.registrarFor("com.idlefish.flutterboost.FlutterBoostPlugin"));
FlutterDragScalePlugin.registerWith(registry.registrarFor("com.example.flutter_drag_scale.FlutterDragScalePlugin"));
GengmeiFlutterPlugin.registerWith(registry.registrarFor("com.example.gengmei_flutter_plugin.GengmeiFlutterPlugin"));
PathProviderPlugin.registerWith(registry.registrarFor("io.flutter.plugins.pathprovider.PathProviderPlugin"));
SqflitePlugin.registerWith(registry.registrarFor("com.tekartik.sqflite.SqflitePlugin"));
XserviceKitPlugin.registerWith(registry.registrarFor("fleamarket.taobao.com.xservicekit.XserviceKitPlugin"));
}
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
......
......@@ -3,8 +3,6 @@ package com.example.gmalpha_flutter
import android.app.Activity
import android.app.Application
import android.content.Context
import com.taobao.idlefish.flutterboost.FlutterBoostPlugin
import com.taobao.idlefish.flutterboost.interfaces.IPlatform
import io.flutter.BuildConfig
import io.flutter.Log
import io.flutter.view.FlutterMain
......
......@@ -8,8 +8,6 @@ import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.view.View
import com.taobao.idlefish.flutterboost.FlutterBoostPlugin
import com.taobao.idlefish.flutterboost.containers.BoostFlutterActivity
import io.flutter.app.FlutterActivity
import io.flutter.embedding.engine.plugins.FlutterPlugin
......
......@@ -175,6 +175,13 @@ function ios(){
cp -r /Users/apple/lsy/gmalpha_flutter/ios/Flutter/App.framework /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project
cp -r /Users/apple/lsy/gmalpha_flutter/ios/Flutter/Flutter.framework /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project
cp -r /Users/apple/lsy/gmalpha_flutter/build/ios/Release-iphoneos/gengmei_flutter_plugin/gengmei_flutter_plugin.framework /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project
# cp -r /Users/apple/lsy/gmalpha_flutter/build/ios/Release-iphoneos/flutter_boost/flutter_boost.framework /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project
# cp -r /Users/apple/lsy/gmalpha_flutter/build/ios/Release-iphoneos/FMDB/FMDB.framework /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project
# cp -r /Users/apple/lsy/gmalpha_flutter/build/ios/Release-iphoneos/path_provider/path_provider.framework /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project
# cp -r /Users/apple/lsy/gmalpha_flutter/build/ios/Release-iphoneos/sqflite/sqflite.framework /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project
# cp -r /Users/apple/lsy/gmalpha_flutter/build/ios/Release-iphoneos/flutter_drag_scale/flutter_drag_scale.framework /Users/apple/lsy/GMAlpha/GMAlpha/Classes/APP/flutter_project
}
function ios_publish(){
......@@ -260,12 +267,12 @@ mkdir /Users/apple/lsy/aar_update/androd${message}/
mkdir /Users/apple/lsy/aar_update/ios${message}/
clean
android_apk
#android_apk
#android
#android_publish
#copyAAR
#upload_android_aar
#ios
ios
#ios_publish
#notifyDingDing
......
......@@ -20,9 +20,6 @@ import 'package:gmalpha_flutter/commonModel/live/LiveData.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
import 'package:gmalpha_flutter/res/GMRes.dart';
const String MainDir = "IsGengmeiAlbumAllImages";
const String MainDirExplain = "全部相片";
Map<String, List<ScanImageItem>> paseAlbum(Object event) {
var map = Map<String, List<dynamic>>.from(event);
var newMap = Map<String, List<ScanImageItem>>();
......@@ -54,27 +51,18 @@ Map<String, List<ScanImageItem>> paseAlbum(Object event) {
}
class AlbumModel extends BaseModel {
AlbumRepository repo = AlbumRepository.getInstance();
LiveData<List<ScanImageItem>> albumLive = LiveData();
LiveData<int> selectSizeLive = LiveData();
LiveData<List<DirBean>> dirLive = LiveData();
LiveData<String> titleData = LiveData();
LiveData<int> backLive = LiveData();
Map<String, List<ScanImageItem>> _mainValue = Map();
List<String> _selectList = List();
List<String> _selectVideoList = List();
String _nowDirName = MainDir;
StreamSubscription _listen;
bool showCamera = true;
final String provider;
int _maxCount = 1;
get selectList => _selectList;
get maxCount => _maxCount;
get nowDirName {
if (_nowDirName == MainDir) {
return MainDirExplain;
......@@ -91,8 +79,6 @@ class AlbumModel extends BaseModel {
final String iosPushedPage;
final String noVideoHint;
get dirList => _dirList;
AlbumModel(
this.provider,
this.showCamera,
......@@ -102,52 +88,29 @@ class AlbumModel extends BaseModel {
int maxVideoCount,
List<String> videoSelectPath,
this.fromPage,
this.iosPushedPage
,this.noVideoHint) {
print("======>>>>>${selectedList} ${videoSelectPath} <<<<<=====");
this.iosPushedPage,
this.noVideoHint) {
repo.clear();
this.maxVideoCount = maxVideoCount;
this._maxCount = maxCount;
if (selectedList != null && !selectedList.isEmpty) {
this._selectList.clear();
this._selectList.addAll(selectedList);
repo.updateSelectPhoto(selectedList);
}
if (videoSelectPath != null && !videoSelectPath.isEmpty) {
this._selectVideoList.clear();
this._selectVideoList.addAll(videoSelectPath);
repo.updateSelectVideo(videoSelectPath);
}
}
void _onEvent(Object event) {
// if (Platform.isAndroid) {
// var map = (event as Map);
// if (_mainValue == null || _mainValue.length == 0) {
// _mainValue = map;
// } else {
// _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"];
// }
// }
// });
// }
// albumLive.notifyView(_mainValue[_nowDirName]);
// } else {
compute(paseAlbum, event).then((value) {
_mainValue = value;
repo.updataMainValue(value);
_dirList.clear();
_mainValue.forEach((k, v) {
repo.getMainValue().forEach((k, v) {
_dirList.add(DirBean(
k == MainDir ? MainDirExplain : k, v.length, File(v[0].path)));
});
albumLive.notifyView(_mainValue[_nowDirName]);
albumLive.notifyView(repo.getMainValue()[_nowDirName]);
});
// }
}
void _onError(Object error) {
......@@ -156,13 +119,14 @@ class AlbumModel extends BaseModel {
void initScanImages(BuildContext context) {
titleData.notifyView(MainDirExplain);
selectSizeLive.notifyView(_selectList.length + _selectVideoList.length);
selectSizeLive.notifyView(
repo.getSelectPhoto().length + repo.getSelectVideo().length);
_listen = GengmeiFlutterPlugin.phoneImagesEvent
.receiveBroadcastStream()
.listen(_onEvent, onError: _onError);
AlbumRepository.getInstance().scanPhoneImg().listen((value) {
if (value != null) {
_mainValue = value;
repo.updataMainValue(value);
value.forEach((key, eachValue) {
if (eachValue != null && !eachValue.isEmpty) {
if (key == MainDir) {
......@@ -195,10 +159,9 @@ class AlbumModel extends BaseModel {
});
}
void changDir() {}
@override
void dispose() {
GengmeiFlutterPlugin.quitPage();
if (_listen != null) {
_listen.cancel();
}
......@@ -207,15 +170,14 @@ class AlbumModel extends BaseModel {
albumLive.dispost();
dirLive.dispost();
titleData.dispost();
GengmeiFlutterPlugin.quitPage();
}
bool isSelect(int index) {
bool haveIt = false;
if (_selectList.isEmpty) {
if (repo.getSelectPhoto().isEmpty) {
return false;
}
_selectList.forEach((value) {
repo.getSelectPhoto().forEach((value) {
if (Platform.isAndroid) {
if (value == albumLive.data[index].realPath) {
haveIt = true;
......@@ -232,10 +194,10 @@ class AlbumModel extends BaseModel {
bool isSelectVideo(int index) {
bool haveIt = false;
if (_selectVideoList.isEmpty) {
if (repo.getSelectVideo().isEmpty) {
return false;
}
_selectVideoList.forEach((value) {
repo.getSelectVideo().forEach((value) {
if (Platform.isAndroid) {
if (value == albumLive.data[index].realPath) {
haveIt = true;
......@@ -250,11 +212,11 @@ class AlbumModel extends BaseModel {
}
bool isFullSelect() {
return _selectList.length == _maxCount;
return repo.getSelectPhoto().length == _maxCount;
}
bool isFullSelectVideo() {
return _selectVideoList.length == maxVideoCount;
return repo.getSelectVideo().length == maxVideoCount;
}
bool isVideo(int index) {
......@@ -262,8 +224,8 @@ class AlbumModel extends BaseModel {
}
void clickItem(BuildContext context, int index) {
if(maxVideoCount==0&&albumLive.data[index].isVideo){
if(noVideoHint!=null){
if (maxVideoCount == 0 && albumLive.data[index].isVideo) {
if (noVideoHint != null) {
Toast.show(context, noVideoHint);
}
return;
......@@ -275,45 +237,47 @@ class AlbumModel extends BaseModel {
path = albumLive.data[index].path;
}
if (maxVideoCount > 0 && albumLive.data[index].isVideo) {
if (!_selectVideoList.contains(path)) {
if (_selectVideoList.length >= maxVideoCount) {
if (!repo.getSelectVideo().contains(path)) {
if (repo.getSelectVideo().length >= maxVideoCount) {
Toast.show(context, "最多选择${maxVideoCount}个视频");
return;
}
_selectVideoList.add(path);
repo.addVideo(path);
} else {
_selectVideoList.remove(path);
repo.removeVideo(path);
}
} else {
if (!_selectList.contains(path)) {
if (_selectList.length >= _maxCount) {
if (!repo.getSelectPhoto().contains(path)) {
if (repo.getSelectPhoto().length >= _maxCount) {
Toast.show(context, "最多选择${_maxCount}张图片");
return;
}
_selectList.add(path);
repo.addPhoto(path);
} else {
_selectList.remove(path);
repo.removePhoto(path);
}
}
albumLive.notifyView(albumLive.data);
selectSizeLive.notifyView(_selectList.length + _selectVideoList.length);
selectSizeLive.notifyView(
repo.getSelectPhoto().length + repo.getSelectVideo().length);
}
void onNext(BuildContext context) {
RouterCenterImpl()
.findBuriedRouter()
?.onEvent("post_add_pic_click_next", {"page_name": "post_add_pic"});
if (_selectList.isEmpty && _selectVideoList.isEmpty) {
if (repo.getSelectPhoto().isEmpty && repo.getSelectVideo().isEmpty) {
Navigator.pop(context, null);
} else {
if (fromNative) {
if (Platform.isAndroid) {
albumResult({"image": _selectList, "video": _selectVideoList});
albumResult(
{"image": repo.getSelectPhoto(), "video": repo.getSelectVideo()});
} else {
iosAlbum(_selectList, context, (image) {
iosAlbum(_selectVideoList, context, (video) {
iosAlbum(repo.getSelectPhoto(), context, (image) {
iosAlbum(repo.getSelectVideo(), context, (video) {
var newImages = List<String>();
for (String item in _selectList) {
for (String item in repo.getSelectPhoto()) {
for (Map real in image) {
var map = Map<String, String>.from(real);
if (map["path"] == item) {
......@@ -323,7 +287,7 @@ class AlbumModel extends BaseModel {
}
}
var newVideos = List<String>();
for (String item in _selectVideoList) {
for (String item in repo.getSelectVideo()) {
for (Map real in video) {
var map = Map<String, String>.from(real);
if (map["path"] == item) {
......@@ -335,9 +299,9 @@ class AlbumModel extends BaseModel {
print("IM ${newImages} $image VIDEI ${newVideos} ${video}");
Navigator.pop(context);
albumResult({
"image": _selectList,
"image": repo.getSelectPhoto(),
"image_real": newImages,
"video": _selectVideoList,
"video": repo.getSelectVideo(),
"video_real": newVideos,
"iosPushedPage": iosPushedPage
});
......@@ -346,9 +310,9 @@ class AlbumModel extends BaseModel {
}
} else {
if (Platform.isAndroid) {
Navigator.pop(context, _selectList);
Navigator.pop(context, repo.getSelectPhoto());
} else {
iosAlbum(_selectList, context, (value) {
iosAlbum(repo.getSelectPhoto(), context, (value) {
print(value);
List<String> resultList = new List();
resultList.add(Map<String, String>.from(value[0])["realImagePath"]);
......@@ -370,16 +334,14 @@ class AlbumModel extends BaseModel {
}
int allSelectSize() {
return _selectList.length + _selectVideoList.length;
return repo.getSelectPhoto().length + repo.getSelectVideo().length;
}
void iosAlbumGetImagePath(String path, int index) {}
void nativeCamera(BuildContext context) {
RouterCenterImpl()
.findBuriedRouter()
?.onEvent("post_add_pic_click_camera", {"page_name": "post_add_pic"});
if (_selectList.length == maxCount) {
if (repo.getSelectPhoto().length == _maxCount) {
Toast.show(context, "最多选择${_maxCount}张图片");
return;
}
......@@ -392,18 +354,11 @@ class AlbumModel extends BaseModel {
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);
repo.addItem(item, foldName);
if (Platform.isAndroid) {
_selectList.add(item.realPath);
repo.addPhoto(item.realPath);
} else {
_selectList.add(item.path);
repo.addPhoto(item.path);
}
bool haveIt = false;
_dirList.forEach((it) {
......@@ -416,8 +371,9 @@ class AlbumModel extends BaseModel {
_dirList.add(new DirBean(foldName, 1, File(item.path)));
}
dirLive.notifyView(_dirList);
albumLive.notifyView(_mainValue[_nowDirName]);
selectSizeLive.notifyView(_selectList.length + _selectVideoList.length);
albumLive.notifyView(repo.getMainValue()[_nowDirName]);
selectSizeLive.notifyView(
repo.getSelectPhoto().length + repo.getSelectVideo().length);
// Navigator.pop(context, data);
// _selectList.add(data);
//TODO
......@@ -428,26 +384,6 @@ class AlbumModel extends BaseModel {
});
}
void AiCamera(BuildContext context) {
if (_selectList.length == maxCount) {
Toast.show(context, "最多选择${_maxCount}张图片");
return;
}
AlbumRepository.getInstance().aiCamera().listen((data) {
if (data == null || data.isEmpty || data == "") {
Toast.show(context, "没有拍摄照片");
} else {
Navigator.pop(context, data);
// _selectList.add(data);
//TODO
}
}).onError((error) {});
}
File getDirPic(int index) {
return File(_mainValue[_dirList[index]][0].path);
}
void changPopState() {
if (showPop) {
showPop = false;
......@@ -471,7 +407,39 @@ class AlbumModel extends BaseModel {
_nowDirName = dirName;
changPopState();
showPop = false;
albumLive.notifyView(_mainValue[dirName]);
albumLive.notifyView(repo.getMainValue()[dirName]);
}
void previewItem(BuildContext context, int index, String pageName) {
String path = Platform.isAndroid
? albumLive.data[index].realPath
: albumLive.data[index].path;
print("LSY $path");
if (albumLive.data[index].isVideo) {
GengmeiFlutterPlugin.playAlbumVideo(path);
} else {
// GengmeiFlutterPlugin.previewImage(path);
Navigator.push(
context,
CustomRoute(AlbumPreviewPage(
path,
albumLive.data[index].size,
albumLive.data,
_maxCount,
maxVideoCount,
noVideoHint,
index)))
.then((value) {
albumLive.notifyView(repo.getMainValue()[_nowDirName]);
selectSizeLive.notifyView(
repo.getSelectPhoto().length + repo.getSelectVideo().length);
if (value != null) {
if (value == -1) {
onNext(context);
}
}
});
}
}
void backAnim(double dy) {
......@@ -487,54 +455,4 @@ class AlbumModel extends BaseModel {
print(colorString);
backLive.notifyView(int.parse(colorString));
}
String getFormatTime(String during) {
if (during == null) {
return "";
} else {
try {
var parse = int.parse(during);
String min;
int minn;
if (parse > 60 * 1000) {
min = "00";
minn = 0;
} else {
minn = (parse / (60 * 1000)).floor();
min = "${minn}";
}
String second = "${((parse - minn * (60 * 1000)) / 1000).floor()}";
if (min.length == 1) {
min = "0$min";
}
if (second.length == 1) {
second = "0$second";
}
if (min.length > 2) {
min = "99";
}
return "$min:$second";
} catch (e) {
print(e);
return "";
}
}
}
void previewItem(BuildContext context, int index, String pageName) {
String path = Platform.isAndroid
? albumLive.data[index].realPath
: albumLive.data[index].path;
print("LSY $path");
if (albumLive.data[index].isVideo) {
GengmeiFlutterPlugin.playAlbumVideo(path);
} else {
GengmeiFlutterPlugin.previewImage(path);
// Navigator.push(
// context,
// CustomRoute(
// AlbumPreviewPage(path, albumLive.data[index].size, pageName)));
}
}
}
......@@ -10,6 +10,7 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:gengmei_flutter_plugin/ScanImagePlugn.dart';
import 'package:gmalpha_flutter/AlbumModel/bean/DirBean.dart';
import 'package:gmalpha_flutter/AlbumModel/page/preview/AlbumPreviewPage.dart';
import 'package:gmalpha_flutter/AlbumModel/util/AlbumUtil.dart';
import 'package:gmalpha_flutter/Annotations/RouterCenterRestore.mark.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/base/BasePage.dart';
......@@ -32,8 +33,17 @@ class AlbumPage extends StatefulWidget {
String fromPage,
String iosPushedPage,
String noVideoHint) {
model = new AlbumModel(provider, showCamera, maxCount, selectedList,
fromNative, maxVideo, videoSelectPath, fromPage, iosPushedPage,noVideoHint);
model = new AlbumModel(
provider,
showCamera,
maxCount,
selectedList,
fromNative,
maxVideo,
videoSelectPath,
fromPage,
iosPushedPage,
noVideoHint);
}
@override
......@@ -43,6 +53,7 @@ class AlbumPage extends StatefulWidget {
class AlbumState extends BasePage<AlbumPage>
with SingleTickerProviderStateMixin {
final AlbumModel _model;
ScrollController scrollController = new ScrollController();
AlbumState(this._model);
......@@ -177,6 +188,7 @@ class AlbumState extends BasePage<AlbumPage>
@override
void dispose() {
scrollController.dispose();
_model.dispose();
controller.dispose();
super.dispose();
......@@ -197,6 +209,7 @@ class AlbumState extends BasePage<AlbumPage>
);
}
return GridView.builder(
controller: scrollController,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 4,
crossAxisSpacing: 1,
......@@ -224,7 +237,7 @@ class AlbumState extends BasePage<AlbumPage>
}
String during;
if (_model.isVideo(newIndex)) {
during = _model.getFormatTime(imgList.data[newIndex].during);
during = AlbumUtil.getFormatTime(imgList.data[newIndex].during);
}
return GestureDetector(
onTap: () {
......
......@@ -7,17 +7,29 @@ import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:gengmei_flutter_plugin/ScanImagePlugn.dart';
import 'package:gengmei_flutter_plugin/gengmei_flutter_plugin.dart';
import 'package:gmalpha_flutter/AlbumModel/repository/AlbumRepository.dart';
import 'package:gmalpha_flutter/commonModel/GMBase.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
class AlbumPreviewModel extends BaseModel {
AlbumRepository repo = AlbumRepository.getInstance();
var imageLive = LiveData<String>();
var pageList = LiveData<List<ScanImageItem>>();
var titleLive = LiveData<String>();
var selectLive = LiveData<bool>();
var nextLive = LiveData<int>();
final String imgPath;
int size;
int _maxCount;
int maxVideoCount;
String noVideoHint;
AlbumPreviewModel(this.imgPath, this.size);
AlbumPreviewModel(this.imgPath, this.size, this._maxCount, this.maxVideoCount,
this.noVideoHint);
getPreviewImage(BuildContext context) {
print("IMAGE SIZE ===> $size");
......@@ -33,6 +45,7 @@ class AlbumPreviewModel extends BaseModel {
// }
}
//
// Future<Codec> _loadAsync(ResizeFileImage key) async {
// assert(key == this);
// final Uint8List bytes = await file.readAsBytes();
......@@ -52,8 +65,129 @@ class AlbumPreviewModel extends BaseModel {
// });
// }
void getItem(String path, BuildContext context) {
List<String> temp = [path];
}
@override
void dispose() {
nextLive.dispost();
selectLive.dispost();
pageList.dispost();
imageLive.dispost();
titleLive.dispost();
}
void getRealPath(BuildContext context, int index) {
if(Platform.isAndroid){
pageList.notifyView(fromPage);
return;
}
GengmeiFlutterPlugin.ios_album_path([fromPage[index].path]).then((value) {
print("HEEEEEEE ");
var map = Map<String, String>.from(value[0]);
print(map);
fromPage[index].realPath = map["realImagePath"];
pageList.notifyView(fromPage);
}).catchError((error) {
Toast.show(context, error.toString());
print(error);
});
}
List<ScanImageItem> fromPage;
void setList(List<ScanImageItem> fromPage) {
this.fromPage = fromPage;
}
void init(BuildContext context) {
nextLive.notifyView(
repo.getSelectVideo().length + repo.getSelectPhoto().length);
}
void clickItem(BuildContext context) {
if (maxVideoCount == 0 && fromPage[currentIndex].isVideo) {
if (noVideoHint != null) {
Toast.show(context, noVideoHint);
}
return;
}
String path;
if (Platform.isAndroid) {
path = fromPage[currentIndex].realPath;
} else {
path = fromPage[currentIndex].path;
}
if (maxVideoCount > 0 && fromPage[currentIndex].isVideo) {
if (!repo.getSelectVideo().contains(path)) {
if (repo.getSelectVideo().length >= maxVideoCount) {
Toast.show(context, "最多选择${maxVideoCount}个视频");
return;
}
repo.addVideo(path);
selectLive.notifyView(true);
} else {
repo.removeVideo(path);
selectLive.notifyView(false);
}
} else {
if (!repo.getSelectPhoto().contains(path)) {
if (repo.getSelectPhoto().length >= _maxCount) {
Toast.show(context, "最多选择${_maxCount}张图片");
return;
}
repo.addPhoto(path);
selectLive.notifyView(true);
} else {
repo.removePhoto(path);
selectLive.notifyView(false);
}
}
nextLive.notifyView(
repo.getSelectPhoto().length + repo.getSelectVideo().length);
}
int currentIndex;
void pageIndex(int index) {
currentIndex = index;
bool haveIt = false;
repo.getSelectPhoto().forEach((value) {
if (Platform.isAndroid) {
if (value == fromPage[index].realPath) {
haveIt = true;
}
} else {
if (value == fromPage[index].path) {
haveIt = true;
}
}
});
repo.getSelectVideo().forEach((value) {
if (Platform.isAndroid) {
if (value == fromPage[index].realPath) {
haveIt = true;
}
} else {
if (value == fromPage[index].path) {
haveIt = true;
}
}
});
selectLive.notifyView(haveIt);
titleLive.notifyView("${currentIndex+1} / ${fromPage.length}");
}
void playVideo() {
if (fromPage[currentIndex].isVideo) {
String path = Platform.isAndroid
? fromPage[currentIndex].realPath
: fromPage[currentIndex].path;
GengmeiFlutterPlugin.playAlbumVideo(path);
}
}
void onNext() {
}
}
......@@ -2,73 +2,274 @@
* @author lsy
* @date 2019-11-01
**/
import 'dart:async';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_drag_scale/core/drag_scale_widget.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:gengmei_flutter_plugin/ScanImagePlugn.dart';
import 'package:gmalpha_flutter/AlbumModel/page/preview/AlbumPreviewModel.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
import 'package:gmalpha_flutter/res/GMRes.dart';
class AlbumPreviewPage extends StatefulWidget {
AlbumPreviewModel _model;
String fromPage;
List<ScanImageItem> fromPage;
int startIndex;
AlbumPreviewPage(String imgPath, int size, this.fromPage) {
_model = AlbumPreviewModel(imgPath,size);
AlbumPreviewPage(String imgPath, int size, this.fromPage, int maxPhotoCount,
int maxVideoCount, String hint, this.startIndex) {
_model =
AlbumPreviewModel(imgPath, size, maxPhotoCount, maxVideoCount, hint);
}
@override
State<StatefulWidget> createState() => AlbumPreviewState(_model, fromPage);
}
class AlbumPreviewState extends State<AlbumPreviewPage> {
class AlbumPreviewState extends State<AlbumPreviewPage>
with SingleTickerProviderStateMixin {
AlbumPreviewModel _model;
final String fromPage;
PageController _pageController;
Size _size;
Animation<Offset> animation;
AnimationController controller;
bool showPop = true;
AlbumPreviewState(this._model, this.fromPage);
AlbumPreviewState(this._model, List<ScanImageItem> fromPage) {
_model.setList(fromPage);
}
@override
void initState() {
super.initState();
_model.getPreviewImage(context);
_model.init(context);
_pageController = PageController(initialPage: widget.startIndex);
_pageController.addListener(() {});
_model.pageIndex(widget.startIndex);
controller = new AnimationController(
duration: const Duration(milliseconds: 100), vsync: this);
animation =
Tween(begin: Offset(0, 0), end: Offset(0, -1)).animate(controller);
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () {
Navigator.pop(context);
},
child: Scaffold(
appBar: baseAppBar(backClick: () {
Navigator.pop(context);
}),
body: Container(
alignment: Alignment.center,
width: double.maxFinite,
height: double.maxFinite,
child: StreamBuilder(
stream: _model.imageLive.stream,
initialData: _model.imageLive.data,
builder: ((con, data) {
if (data.data == null) {
return loadingItem();
}
return DragScaleContainer(
doubleTapStillScale: false,
child: new Image.file(
File(
_model.imgPath,
),
_size = MediaQuery.of(context).size;
return Scaffold(
// appBar: baseAppBar(backClick: () {
// Navigator.pop(context);
// }),
body: Container(
color: Colors.black,
child: Stack(
children: <Widget>[
getPage(),
SlideTransition(
position: animation,
child: Container(
width: double.maxFinite,
height: 80,
alignment: Alignment.center,
color: Colors.black38,
child: Stack(
// alignment: AlignmentDirectional.topCenter,
children: <Widget>[
Positioned(
left: 0,
top: 0,
child: GestureDetector(
onTap: () {
Navigator.pop(context, _model.currentIndex);
},
child: Container(
color: Colors.transparent,
padding: EdgeInsets.only(
left: 22,
top: 38,
),
child: SvgPicture.asset(
"images/left_arrow.svg",
color: Colors.white,
)),
),
),
Container(
alignment: Alignment.topCenter,
width: double.maxFinite,
height: 80,
padding: EdgeInsets.only(top: 41),
child: StreamBuilder<String>(
stream: _model.titleLive.stream,
initialData: _model.titleLive.data,
builder: (con, data) {
if (data.data == null) {
return baseText("", 16, ALColors.ColorFFFFFF);
}
return baseText(
data.data, 16, ALColors.ColorFFFFFF);
},
),
),
Positioned(
right: 22,
top: 39,
child: StreamBuilder<int>(
stream: _model.nextLive.stream,
initialData: _model.nextLive.data,
builder: (con, data) {
if (data.data == null || data.data == 0) {
return baseText(
"下一步", 16, ALColors.ColorC4C4C4);
}
return GestureDetector(
onTap: () {
Navigator.pop(context, -1);
},
child: baseText("下一步(${data.data})", 16,
ALColors.ColorFFFFFF));
},
)),
],
),
),
),
Positioned(
top: 100,
right: 0,
child: GestureDetector(
onTap: () {
_model.clickItem(context);
},
child: StreamBuilder<bool>(
stream: _model.selectLive.stream,
initialData: _model.selectLive.data,
builder: (con, data) {
if (data.data == null || !data.data) {
return Container(
color: Colors.transparent,
padding: EdgeInsets.only(
top: 20, right: 22, bottom: 20),
child: SvgPicture.asset(
"images/album_not_sel.svg"));
}
return Container(
padding: EdgeInsets.only(
top: 20, right: 22, bottom: 20),
color: Colors.transparent,
child:
SvgPicture.asset("images/album_sel.svg"));
})),
),
],
)));
// Container(
// alignment: Alignment.center,
// width: double.maxFinite,
// height: double.maxFinite,
// child: StreamBuilder(
// stream: _model.imageLive.stream,
// initialData: _model.imageLive.data,
// builder: ((con, data) {
// if (data.data == null) {
// return loadingItem();
// }
// return DragScaleContainer(
// doubleTapStillScale: false,
// child: new Image.file(
// File(
// _model.imgPath,
// ),
// fit: BoxFit.fitWidth,
// ));
// })))));
}
getPage() {
return StreamBuilder<List<ScanImageItem>>(
stream: _model.pageList.stream,
initialData: _model.pageList.data,
builder: (con, data) {
return PageView.builder(
onPageChanged: (index) {
_model.pageIndex(index);
},
itemBuilder: (con, index) {
print("INDEXXX $index ");
if (data.data != null && data.data[index].isVideo) {
return Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
ConstrainedBox(
constraints: BoxConstraints.expand(),
child: GestureDetector(
onTap: (){
hide();
},
child: Image.file(File(data.data[index].path),
fit: BoxFit.fitWidth),
)),
GestureDetector(
onTap: () {
_model.playVideo();
},
child: Icon(
Icons.play_circle_filled,
size: 80,
),
)
],
);
}
if (data.data == null ||
data.data[index].realPath == null ||
data.data[index].realPath.isEmpty) {
_model.getRealPath(context, index);
return loadingItem();
}
return Container(
alignment: Alignment.center,
child: ConstrainedBox(
constraints: BoxConstraints.expand(),
child: DragScaleContainer(
doubleTapStillScale: false,
child: GestureDetector(
onTap: () {
hide();
},
child: Image.file(
File(data.data[index].realPath),
fit: BoxFit.fitWidth,
));
})))));
)))),
);
},
itemCount: _model.fromPage.length,
scrollDirection: Axis.horizontal,
reverse: false,
controller: _pageController,
physics: PageScrollPhysics(parent: ClampingScrollPhysics()),
);
},
);
}
hide(){
if (showPop) {
controller.forward();
} else {
controller.reverse();
}
showPop = !showPop;
}
@override
void dispose() {
_pageController.dispose();
_model.dispose();
controller.dispose();
super.dispose();
}
// @override
......
......@@ -7,6 +7,9 @@ import 'package:gengmei_flutter_plugin/ScanImagePlugn.dart';
import 'package:gengmei_flutter_plugin/gengmei_flutter_plugin.dart';
import 'package:rxdart/rxdart.dart';
const String MainDir = "IsGengmeiAlbumAllImages";
const String MainDirExplain = "全部相片";
class AlbumRepository {
AlbumRepository._();
......@@ -19,30 +22,38 @@ class AlbumRepository {
return _instance;
}
Map<String, List<ScanImageItem>> _cacheList = new Map();
Map<String, List<ScanImageItem>> _mainValue = Map();
List<String> _selectList = List();
List<String> _selectVideoList = List();
Observable<Map<String, List<ScanImageItem>>> scanPhoneImg() {
return Observable.fromFuture(GengmeiFlutterPlugin.phoneImages())
.map((value) {
// Map<String, List<ScanImageItem>> finalList = new Map();
// var all = value["IsGengmeiAlbumAllImages"];
// if (all != null) {
// value.forEach((k, v) {
// List<ScanImageItem> newList = List();
// v.forEach((value) {
//
// });
// });
// }
//
// if (value != null) {}
return Observable.fromFuture(GengmeiFlutterPlugin.phoneImages());
}
void updataMainValue(Map<String, List<ScanImageItem>> value) {
_mainValue = value;
}
Map<String, List<ScanImageItem>> getMainValue() {
return _mainValue;
}
return value;
});
void updateSelectPhoto(List<String> value) {
_selectList.clear();
_selectList.addAll(value);
}
void clearMemory() {
_cacheList.clear();
void updateSelectVideo(List<String> value) {
_selectVideoList.clear();
_selectVideoList.addAll(value);
}
List<String> getSelectPhoto() {
return _selectList;
}
List<String> getSelectVideo() {
return _selectVideoList;
}
Observable<Map> nativeCamera(String provider) {
......@@ -52,4 +63,39 @@ class AlbumRepository {
Observable<String> aiCamera() {
// return Observable.fromFuture(GengmeiFlutterPlugin.aiCamera());
}
void addItem(ScanImageItem item, String foldName) {
if (_mainValue != null) {
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);
}
}
void addVideo(String path) {
_selectVideoList.add(path);
}
void removeVideo(String path) {
_selectVideoList.remove(path);
}
void addPhoto(String path) {
_selectList.add(path);
}
void removePhoto(String path) {
_selectList.remove(path);
}
void clear() {
_selectList.clear();
_selectVideoList.clear();
_mainValue.clear();
}
}
/*
* @author lsy
* @date 2019-11-12
**/
class AlbumUtil{
static String getFormatTime(String during) {
if (during == null) {
return "";
} else {
try {
var parse = int.parse(during);
String min;
int minn;
if (parse > 60 * 1000) {
min = "00";
minn = 0;
} else {
minn = (parse / (60 * 1000)).floor();
min = "${minn}";
}
String second = "${((parse - minn * (60 * 1000)) / 1000).floor()}";
if (min.length == 1) {
min = "0$min";
}
if (second.length == 1) {
second = "0$second";
}
if (min.length > 2) {
min = "99";
}
return "$min:$second";
} catch (e) {
print(e);
return "";
}
}
}
}
\ No newline at end of file
......@@ -85,8 +85,8 @@ class TestPage extends StatelessWidget {
Navigator.push(
context,
new CustomRoute(RouterCenterImpl().findAlbumRouter()?.getAlbumPage(
"com.example.gmalpha_flutter", true, 1, null, false, "test",
maxVideoCount: 0)));
"com.example.gmalpha_flutter", true, 9, null, false, "test",
maxVideoCount: 0,noVideoHint: "测试测试测试")));
}, "相册页面");
}
......
......@@ -116,9 +116,9 @@ class UserSettingModel extends BaseModel {
if (value != null) {
print("$value");
selectImgPath = value[0];
File txt=File(selectImgPath);
var dir_bool=txt.exists().then((value){
print("RESULT!!!!!$selectImgPath bool ${value}" );
File txt = File(selectImgPath);
var dir_bool = txt.exists().then((value) {
print("RESULT!!!!!$selectImgPath bool ${value}");
});
headImgLive.notifyView(selectImgPath);
......@@ -213,7 +213,7 @@ class UserSettingModel extends BaseModel {
UserEntityImpl().savecountryInfoId(countryId);
UserEntityImpl().savecountryInfoName(cityLive.data);
Timer(Duration(milliseconds: 100), () {
FlutterBoost.singleton.closePageForContext(context);
Navigator.pop(context);
// Navigator.pop(context);
});
// FlutterBoost.singleton.closePageForContext(context);
......
......@@ -125,7 +125,6 @@ class _MyAppState extends State<MyApp> {
?.getFindPage(params["fromPage"]);
},
});
FlutterBoost.handleOnStartPage();
}
@override
......
......@@ -27,7 +27,11 @@ dependencies:
dio: ^2.2.2
rxdart: ^0.22.0 #链式编程
pull_to_refresh: ^1.5.0
flutter_boost: ^0.0.420
flutter_boost: ^0.1.60
# flutter_boost:
# git:
# url: 'https://github.com/alibaba/flutter_boost.git'
# ref: '0.1.60'
event_bus: ^1.1.0
# gengmei_flutter_plugin: ^0.0.731
# flutter_boost:
......@@ -39,14 +43,16 @@ dependencies:
gengmei_flutter_plugin:
git:
url: 'git@git.wanmeizhensuo.com:linshengyu/flutter_plugin.git'
ref: "85f3ca475ec55464ff29e68dfaf444add58a0b64"
ref: 'c4e2b08443761ea46bdef6dc8d2b93d13c2689f4'
# gengmei_flutter_plugin:
# path: /Users/apple/lsy/gengmei_flutter_plugin
flutter_drag_scale:
git: 'https://github.com/LiuC520/flutter_drag_scale.git'
protobuf: ^0.14.4
grpc: ^2.1.2
flutter_svg: ^0.14.1
flutter_drag_scale:
git:
url: 'https://github.com/LiuC520/flutter_drag_scale.git'
# ref: '33d4dfa904728e277f67d029767b833330655333'
dev_dependencies:
source_gen: '>=0.8.0'
......
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