Commit 1400309e authored by 林生雨's avatar 林生雨

commit

parent e2848217
No preview for this file type
#!/usr/bin/env bash
flutter packages pub run build_runner clean
flutter packages pub run build_runner build --delete-conflicting-outputs
\ No newline at end of file
......@@ -26,6 +26,7 @@ class ServiceGenerator extends GeneratorForAnnotation<ServiceCenter> {
StringBuffer methodBuffer = StringBuffer("");
StringBuffer outBuffer = StringBuffer();
StringBuffer mapBuffer = new StringBuffer();
List<String> outList=[];
List<String> differentList = [];
for (var methodElement in (element as ClassElement).methods) {
for (var annometadata in methodElement.metadata) {
......@@ -96,11 +97,14 @@ class ServiceGenerator extends GeneratorForAnnotation<ServiceCenter> {
// Map map = json.decode(value.toString());
// return ${methodElement.returnType.name}.fromJson(map);
mapBuffer.write("))");
if(!outList.contains(methodElement.returnType.name)){
outList.add(methodElement.returnType.name);
outBuffer.write("""
${methodElement.returnType.name} pase${methodElement.returnType.name}(String value){
return ${methodElement.returnType.name}.fromJson(json.decode(value));
}\n
""");
}
mapBuffer.write("""
.flatMap((value){
if(value!=null&&(value.statusCode>=200&&value.statusCode<300)){
......
......@@ -5,6 +5,7 @@
import 'dart:math';
import 'dart:ui';
import 'package:example_flutter/commonModel/toast/toast.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
......@@ -13,7 +14,7 @@ import 'commonModel/live/BaseModel.dart';
import 'commonModel/live/LiveData.dart';
class HomeItem {
HomeItem(this.index, this.svgIcon,this.name);
HomeItem(this.index, this.svgIcon, this.name);
int index;
String svgIcon;
......@@ -33,27 +34,32 @@ class HomeModel extends BaseModel {
void init() {
var mainWidget = RouterCenterImpl().findHomeRouter()?.getHomePage();
var persionPage=RouterCenterImpl().findUserRouter()?.getPersionPage();
var persionPage = RouterCenterImpl().findUserRouter()?.getPersionPage();
var checkPage = RouterCenterImpl().findHomeRouter()?.getCheckPage();
var findPage = RouterCenterImpl().findHomeRouter()?.getDataPage();
int index = 0;
if (mainWidget != null) {
items.add(HomeItem(index, "images/home.svg","主页"));
items.add(HomeItem(index, "images/home.svg", "主页"));
pages.add(mainWidget);
index++;
}
if(persionPage!=null){
items.add(HomeItem(index, "images/home.svg","主页"));
if (checkPage != null) {
items.add(HomeItem(index, "images/home.svg", "主页"));
pages.add(checkPage);
index++;
}
if (persionPage != null) {
items.add(HomeItem(index, "images/home.svg", "主页"));
pages.add(persionPage);
index++;
}
if (findPage != null) {
items.add(HomeItem(index, "images/find.svg","变美助手"));
items.add(HomeItem(index, "images/find.svg", "变美助手"));
pages.add(findPage);
index++;
}
}
void onTap(int index) {
widgetLive.notifyView(index);
}
......
......@@ -11,4 +11,5 @@ import 'package:flutter/cupertino.dart';
abstract class HomeRouter extends RouterBaser {
Widget getHomePage();
Widget getDataPage();
Widget getCheckPage();
}
......@@ -3,6 +3,7 @@
* @date 2019-11-07
**/
import 'package:example_flutter/HomeModel/HomeRouter.dart';
import 'package:example_flutter/HomeModel/page/check/CheckPage.dart';
import 'package:example_flutter/HomeModel/page/data/DataCenter.dart';
import 'package:example_flutter/HomeModel/page/home/HomePage.dart';
import 'package:flutter/src/widgets/framework.dart';
......@@ -18,4 +19,9 @@ class HomeRouterImpl extends HomeRouter{
return DataCenter();
}
@override
Widget getCheckPage() {
return CheckPage();
}
}
\ No newline at end of file
......@@ -92,7 +92,7 @@ Widget basehead(BuildContext context) {
GestureDetector(
onTap: () {
BaseDrawPicker()
..setPicker(DrawPicker(["全部项目", "成员管理", "数据中心"]))
..setPicker(DrawPicker(["全部项目", "标注审核", "人员管理","数据中心"]))
..show(context);
},
child: Container(
......@@ -247,26 +247,6 @@ class DrawPicker implements IDrawPicker {
}
}
Widget baseButton(VoidCallback press, EdgeInsetsGeometry margin, String text) {
return FlatButton(
onPressed: press,
child: Container(
margin: margin,
alignment: Alignment.center,
width: 100,
height: 39,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: Colors.purple,
gradient: LinearGradient(colors: [
Color.fromARGB(255, 253, 113, 34),
Color.fromARGB(255, 253, 166, 41)
], begin: Alignment.centerRight, end: Alignment.centerLeft),
),
child: baseText(text, 15, Colors.white),
),
);
}
class SurePicker implements ICenterPicker {
VoidCallback cancel;
......@@ -453,11 +433,3 @@ Widget refreshloadingItem(VoidCallback callback) {
return SliverFillViewport(delegate: SliverChildListDelegate([loadCircle]));
}
Widget baseFlatButtonItem(VoidCallback callback,String text){
return FlatButton(
padding: EdgeInsets.only(top: 2, bottom: 2),
color: Color.fromARGB(255, 236, 236, 236),
onPressed: callback,
child: baseText(text, 13, Colors.black),
);
}
/*
* @author lsy
* @date 2019-12-10
**/
const checkListText="""
{
"pic_list": [{
"picurl": "https://anno-1258538551.cos.ap-chengdu.myqcloud.com/f540275d1e6d2fbad9273a8f17924e94.png",
"id": 11,
"status": "2"
}, {
"picurl": "https://anno-1258538551.cos.ap-chengdu.myqcloud.com/f540275d1e6d2fbad9273a8f17924e94",
"id": 12,
"status": "2"
}, {
"picurl": "https://anno-1258538551.cos.ap-chengdu.myqcloud.com/f540275d1e6d2fbad9273a8f17924e94",
"id": 12,
"status": "2"
}, {
"picurl": "https://anno-1258538551.cos.ap-chengdu.myqcloud.com/f540275d1e6d2fbad9273a8f17924e94",
"id": 12,
"status": "2"
}, {
"picurl": "https://anno-1258538551.cos.ap-chengdu.myqcloud.com/f540275d1e6d2fbad9273a8f17924e94",
"id": 12,
"status": "2"
}, {
"picurl": "https://anno-1258538551.cos.ap-chengdu.myqcloud.com/f540275d1e6d2fbad9273a8f17924e94",
"id": 12,
"status": "2"
}, {
"picurl": "https://anno-1258538551.cos.ap-chengdu.myqcloud.com/f540275d1e6d2fbad9273a8f17924e94",
"id": 12,
"status": "2"
}, {
"picurl": "https://anno-1258538551.cos.ap-chengdu.myqcloud.com/f540275d1e6d2fbad9273a8f17924e94",
"id": 12,
"status": "2"
}, {
"picurl": "https://anno-1258538551.cos.ap-chengdu.myqcloud.com/f540275d1e6d2fbad9273a8f17924e94",
"id": 12,
"status": "2"
}]
}
""";
const checkDetail="""
{
"url": "http://img.zcool.cn/community/038500855ea70a732f875a13258473a.jpg",
"anno": {
"eyelid_right": "单眼皮",
"eyelid_left": "单眼皮",
"nose": "窄鼻翼",
"wrink": "有",
"lip_thickness": "标准唇",
"lip_peak": "无",
"pouch": "有",
"cheekbone": "高颧骨",
"brow_shape": "上挑眉",
"brow_density": "分布均匀",
"chin_shape": "圆",
"lip_shape": "樱桃唇",
"lip_radian": "微笑唇",
"eye_shape_right": "杏眼",
"eye_shape_left": "杏眼",
"brows_style": "柳叶眉",
"brows_thickness": "粗眉",
"Dense": "非常淡",
"brows_spacing": "宽",
"face": "梨形脸",
"heiyanquan_left": "有",
"wocan_left": "有",
"yanwen_left": "有",
"yuweiwen_left": "有",
"zhongyanpao_left": "有",
"leigou_left": "有",
"heiyanquan_right": "有",
"wocan_right": "有",
"yanwen_right": "有",
"yuweiwen_right": "有",
"zhongyanpao_right": "有",
"leigou_right": "有"
}
}
""";
/*
* @author lsy
* @date 2019-12-09
**/
import 'dart:math';
import 'package:example_flutter/HomeModel/page/checkInfo/CheckInfoPage.dart';
import 'package:example_flutter/HomeModel/service/HomeRepo.dart';
import 'package:example_flutter/HomeModel/service/remote/entity/ImageResultBean.dart';
import 'package:example_flutter/HomeModel/util/JumpUtil.dart';
import 'package:example_flutter/commonModel/GMBase.dart';
import 'package:example_flutter/commonModel/picker/base/BasePickerComponent.dart';
import 'package:example_flutter/commonModel/toast/toast.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/src/widgets/framework.dart';
class CheckModel extends BaseModel {
LiveData<int> pageIndexLive = new LiveData();
LiveData<List<PicList>> checkItemLive = new LiveData();
LiveData<String> titleLive = new LiveData();
HomeRepo _repo = HomeRepo.getInstance();
//0 标签 1 mask ..
int state = 0;
@override
void dispose() {
pageIndexLive.dispost();
checkItemLive.dispost();
titleLive.dispost();
}
void changeState(BuildContext context, int sta, String title) {
checkItemLive.notifyView(null);
state = sta;
if (sta == 0) {
getData(context, true);
} else if (sta == 1) {
getMaskData(context, true);
}
titleLive.notifyView(title);
}
void getMaskData(BuildContext context, bool showDialog) {
if (showDialog) {
BaseCenterPicker()
..setPicker(BaseLoadingItem("加载中..."))
..show(context);
}
HomeRepo.getInstance()
.getCheckMaskList(HomeRepo.getInstance().nowCheckMaskPageIndex)
.listen((value) {
if (showDialog) {
Navigator.pop(context);
}
_repo.updateCheckMaskList(value.picList);
checkItemLive.notifyView(value.picList);
pageIndexLive.notifyView(_repo.nowCheckMaskPageIndex);
}).onError((error) {
if (showDialog) {
Navigator.pop(context);
}
Toast.show(context, error.toString());
print(error.toString());
});
}
void getData(BuildContext context, bool showDialog) {
if (showDialog) {
BaseCenterPicker()
..setPicker(BaseLoadingItem("加载中..."))
..show(context);
}
titleLive.notifyView("标记列表");
HomeRepo.getInstance()
.getCheckList(HomeRepo.getInstance().nowCheckPageIndex)
.listen((value) {
if (showDialog) {
Navigator.pop(context);
}
_repo.updateCheckList(value.picList);
checkItemLive.notifyView(value.picList);
pageIndexLive.notifyView(_repo.nowCheckPageIndex);
}).onError((error) {
if (showDialog) {
Navigator.pop(context);
}
Toast.show(context, error.toString());
print(error.toString());
});
}
void checkClick(BuildContext context, String id, int index) {
JumpUtil.jumpToPage(context, CheckInfoPage(state, id, index)).then((value) {
if (state == 0) {
getData(context, false);
} else if (state == 1) {
getMaskData(context, false);
}
});
}
void after(BuildContext context) {
BaseCenterPicker()
..setPicker(BaseLoadingItem("加载中。。。"))
..show(context);
if (state == 0) {
_repo.getCheckList(_repo.nowCheckPageIndex + 1).listen((data) {
if (data == null || data.picList == null || data.picList.isEmpty) {
Toast.show(context, "已经是最后一页了哦~");
} else {
_repo.nowCheckPageIndex = _repo.nowCheckPageIndex + 1;
_repo.updateCheckList(data.picList);
checkItemLive.notifyView(data.picList);
}
pageIndexLive.notifyView(_repo.nowCheckPageIndex);
Navigator.pop(context);
}).onError((error) {
Toast.show(context, error.toString());
Toast.show(context, "没有下一页了");
print(error.toString());
Navigator.pop(context);
});
} else if (state == 1) {
_repo.getCheckMaskList(_repo.nowCheckMaskPageIndex + 1).listen((data) {
if (data == null || data.picList == null || data.picList.isEmpty) {
Toast.show(context, "已经是最后一页了哦~");
} else {
_repo.nowCheckMaskPageIndex = _repo.nowCheckMaskPageIndex + 1;
_repo.updateCheckMaskList(data.picList);
checkItemLive.notifyView(data.picList);
}
pageIndexLive.notifyView(_repo.nowCheckMaskPageIndex);
Navigator.pop(context);
}).onError((error) {
Toast.show(context, error.toString());
Toast.show(context, "没有下一页了");
print(error.toString());
Navigator.pop(context);
});
}
}
void before(BuildContext context) {
if (state == 0) {
if (_repo.nowCheckPageIndex == 1) {
Toast.show(context, "已经是第一页了哦");
return;
}
_repo.nowCheckPageIndex = _repo.nowCheckPageIndex - 1;
getData(context, true);
pageIndexLive.notifyView(_repo.nowCheckPageIndex);
} else if (state == 1) {
if (_repo.nowCheckMaskPageIndex == 1) {
Toast.show(context, "已经是第一页了哦");
return;
}
_repo.nowCheckMaskPageIndex = _repo.nowCheckMaskPageIndex - 1;
getMaskData(context, true);
pageIndexLive.notifyView(_repo.nowCheckMaskPageIndex);
}
}
}
/*
* @author lsy
* @date 2019-12-09
**/
import 'package:example_flutter/HomeModel/base/BaseTitle.dart';
import 'package:example_flutter/HomeModel/page/work/temp.dart';
import 'package:example_flutter/HomeModel/service/remote/entity/ImageResultBean.dart';
import 'package:example_flutter/commonModel/base/BaseComponent.dart';
import 'package:example_flutter/commonModel/base/BaseState.dart';
import 'package:example_flutter/commonModel/cache/CacheManager.dart';
import 'package:example_flutter/res/GMRes.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'CheckModel.dart';
class CheckPage extends StatefulWidget {
@override
State<StatefulWidget> createState() => CheckState();
}
class CheckState extends State<CheckPage> {
bool isChecker = false;
CheckModel _model;
@override
void initState() {
isChecker =
(CacheManager.getInstance().get(MEMORY_CACHE).get("checkId")==null ? -1:CacheManager.getInstance().get(MEMORY_CACHE).get("checkId") == 1);
_model = CheckModel();
if (isChecker) {
_model.getData(context, false);
}
super.initState();
}
@override
void dispose() {
_model.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(),
body: isChecker
? Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
FixLeft(),
Expanded(
child: RightItem(),
)
],
)
: Center(
child: baseText("这个账号没有审核权限哦", 18, Colors.black),
),
);
}
Widget RightItem() {
return Card(
elevation: 5,
margin: EdgeInsets.only(left: 30, top: 30, right: 200, bottom: 50),
child: Container(
child: Column(
children: <Widget>[rightTitle(), rightBody(), rightFoot()],
),
),
);
}
Widget rightTitle() {
return Container(
width: double.maxFinite,
height: 50,
color: Colors.red,
alignment: Alignment.center,
child: StreamBuilder(
stream: _model.titleLive.stream,
initialData: "",
builder: (con, data) {
return baseText("审查列表 -- ${data.data}", 15, Colors.black);
},
));
}
Widget rightFoot() {
return Container(
width: double.maxFinite,
height: 50,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
baseButton(() {
if(_model.state==0){
_model.getData(context, true);
}else if(_model.state==1){
_model.getMaskData(context, true);
}
}, EdgeInsets.only(), "刷新"),
// baseButton(() {}, EdgeInsets.only(), ""),
// baseButton(() {}, EdgeInsets.only(), ""),
// baseButton(() {}, EdgeInsets.only(), ""),
Expanded(
child: Container(),
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
_model.before(context);
},
child: Container(
alignment: Alignment.center,
width: 38,
height: 38,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(color: Colors.orange, width: 2),
),
child: Icon(
Icons.arrow_left,
color: Colors.orange,
),
)),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {},
child: Container(
margin: EdgeInsets.only(left: 5, right: 5),
alignment: Alignment.center,
width: 38,
height: 38,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(color: Colors.orange, width: 2),
),
child: StreamBuilder<int>(
stream: _model.pageIndexLive.stream,
initialData: 1,
builder: (con, data) {
return baseText("${data.data}", 13, Colors.orange);
},
))),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
_model.after(context);
},
child: Container(
alignment: Alignment.center,
width: 38,
height: 38,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
border: Border.all(color: Colors.orange, width: 2),
),
child: Icon(
Icons.arrow_right,
color: Colors.orange,
),
)),
Container(
width: 30,
)
],
),
);
}
Widget rightBody() {
return Expanded(
child: Container(
child: StreamBuilder<List<PicList>>(
stream: _model.checkItemLive.stream,
initialData: [],
builder: (con, data) {
List<Widget> list = [
Item(ALColors.ColorTitle, "id", null, "名称", "标注者", "审查类型", "质检状态",
"完成时间", -1)
];
list.add(baseDivideColumn());
int index = 0;
if (data.data != null) {
data.data.forEach((value) {
list.add(Item(
Colors.white,
"${value.id}",
value.picurl,
value.picurl.substring(
value.picurl.lastIndexOf("/") + 1, value.picurl.length),
"未知",
_model.state == 0 ? "标记审查" : "点审查",
STATEEXPLAIN[value.status],
"未知",
index));
index++;
list.add(baseDivideColumn());
});
}
print(list.length);
return ListView(
children: list,
);
},
)),
);
}
Widget Item(Color color, String id, String url, String name, String persion,
String type, String state, String date, int index) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
if (index != -1) {
_model.checkClick(context, id, index);
}
},
child: Container(
width: double.maxFinite,
height: 50,
color: color,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
alignment: Alignment.center,
height: 50,
width: 50,
child: Container(
child: baseText(id, 13, Colors.black),
),
),
baseDivideRow(),
Expanded(
child: Container(
alignment: Alignment.center,
child: url == null
? baseText("图片", 13, Colors.black)
: Image.network(
url,
height: double.maxFinite,
fit: BoxFit.fitHeight,
),
),
),
baseDivideRow(),
Expanded(
child: Container(
alignment: Alignment.center,
child: baseText(name, 13, Colors.black),
),
),
baseDivideRow(),
Expanded(
child: Container(
alignment: Alignment.center,
child: baseText(persion, 13, Colors.black),
),
),
baseDivideRow(),
Expanded(
child: Container(
alignment: Alignment.center,
child: baseText(state, 13, Colors.black),
),
),
baseDivideRow(),
Expanded(
child: Container(
alignment: Alignment.center,
child: baseText(type, 13, Colors.black),
),
),
baseDivideRow(),
Expanded(
child: Container(
alignment: Alignment.center,
child: baseText(date, 13, Colors.black),
),
)
],
)));
}
Widget FixLeft() {
return Card(
elevation: 5,
margin: EdgeInsets.only(left: 50, top: 30),
child: Container(
width: 120,
height: 300,
child: Column(
children: <Widget>[
Container(
height: 30,
),
baseFlatButtonItem(() {
_model.changeState(context, 0, "标记列表");
}, "标记列表"),
baseFlatButtonItem(() {
_model.changeState(context, 1, "点列表");
}, "点列表"),
baseFlatButtonItem(() {}, "TODO"),
Expanded(
child: Container(),
),
],
),
),
);
}
}
/*
* @author lsy
* @date 2019-12-09
**/
import 'dart:io';
import 'package:example_flutter/HomeModel/base/BaseTitle.dart';
import 'package:example_flutter/HomeModel/base/bean/PointItem.dart';
import 'package:example_flutter/HomeModel/page/work/temp.dart';
import 'package:example_flutter/HomeModel/service/HomeRepo.dart';
import 'package:example_flutter/HomeModel/util/ParseUtil.dart';
import 'package:example_flutter/commonModel/GMBase.dart';
import 'package:example_flutter/commonModel/cache/CacheManager.dart';
import 'package:example_flutter/commonModel/picker/base/BasePickerComponent.dart';
import 'package:example_flutter/commonModel/toast/toast.dart';
import 'package:example_flutter/commonModel/util/ImageUtil.dart';
import 'package:flutter/material.dart';
class CheckInfoModel implements BaseModel {
LiveData<PointItem> pointLive = new LiveData();
LiveData<List<int>> nowIndexLive = new LiveData();
LiveData<String> maskTabLive = new LiveData();
LiveData<bool> needHelpLineLive = new LiveData();
LiveData<Map<String, List<List<String>>>> tabLive = new LiveData();
LiveData<Map<String, List<List<String>>>> selectLive = new LiveData();
Map<String, List<List<String>>> selectMap = new Map();
PointItem pointItem = new PointItem();
int state;
String id;
int currentIndex;
HomeRepo _repo = HomeRepo.getInstance();
CheckInfoModel(this.state, this.id, this.currentIndex);
init(BuildContext context) {
if (state == 0) {
needHelpLine = false;
allTab(context, false);
getImageResutl(context, false);
} else if (state == 1) {
needHelpLine = true;
}
getNetWorkImg(context);
notiIndex();
needHelpLineLive.notifyView(needHelpLine);
}
getImageResutl(BuildContext context, bool showPicker) {
if (showPicker) {
BaseCenterPicker()
..setPicker(BaseLoadingItem("加载中..."))
..show(context);
}
HomeRepo.getInstance().imageAi(id).listen((value) {
selectMap.clear();
selectMap.addAll(ParseUtil.parseSelect(value));
selectLive.notifyView(selectMap);
if (showPicker) {
Navigator.pop(context);
}
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
if (showPicker) {
Navigator.pop(context);
}
});
}
void deleteSelectItem(BuildContext context, String key, String title) {
BaseCenterPicker()
..setPicker(SurePicker("确定删除这个条目吗?", () {
Navigator.pop(context);
}, () {
Navigator.pop(context);
var selectList = selectMap[key];
if (selectList != null && selectList.isNotEmpty) {
if (selectList.length == 1) {
selectMap.remove(key);
} else {
int index = -1;
for (int i = 0; i < selectList.length; i++) {
if (selectList[i][0] == title) {
index = i;
}
}
if (index != -1) {
selectList.removeAt(index);
}
}
}
selectLive.notifyView(selectMap);
}))
..show(context);
}
allTab(BuildContext context, bool showPicker) {
if (showPicker) {
BaseCenterPicker()
..setPicker(BaseLoadingItem("加载中"))
..show(context);
}
HomeRepo.getInstance().getAllTab().listen((value) {
tabLive.notifyView(ParseUtil.changTabToList(value));
if (showPicker) {
Navigator.pop(context);
}
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
if (showPicker) {
Navigator.pop(context);
}
});
}
notiIndex() {
if (state == 0) {
nowIndexLive.notifyView(
[HomeRepo.getInstance().nowCheckPageIndex, currentIndex + 1]);
} else if (state == 1) {
nowIndexLive.notifyView(
[HomeRepo.getInstance().nowCheckMaskPageIndex, currentIndex + 1]);
}
}
void selectItem(String key, String title, String result) {
List<List<String>> innlist = selectMap[key];
if (innlist == null || innlist.isEmpty) {
selectMap[key] = [
[title, result]
];
} else {
int index = -1;
for (int i = 0; i < innlist.length; i++) {
if (innlist[i][0] == title) {
index = i;
break;
}
}
if (index != -1) {
innlist[index][1] = result;
} else {
List<String> list = [title, result];
innlist.add(list);
}
}
selectLive.notifyView(selectMap);
}
@override
void dispose() {
tabLive.dispost();
selectLive.dispost();
pointLive.dispost();
nowIndexLive.dispost();
maskTabLive.dispost();
needHelpLineLive.dispost();
}
void getNetWorkImg(BuildContext context) {
if (state == 0) {
loadNetWorkImage(HomeRepo.getInstance().checkList[currentIndex].picurl)
.then((value) {
pointItem.reset();
pointItem.setImage(value);
pointLive.notifyView(pointItem);
}).catchError((error) {
Toast.show(context, error.toString());
print(error.toString());
});
} else if (state == 1) {
loadNetWorkImage(
HomeRepo.getInstance().checkMaskList[currentIndex].picurl)
.then((value) {
pointItem.reset();
pointItem.setImage(value);
pointLive.notifyView(pointItem);
}).catchError((error) {
Toast.show(context, error.toString());
print(error.toString());
});
}
}
void syncPoint() {
pointLive.notifyView(pointItem);
}
void saveDrawImage(
BuildContext context, double picScare, double topBuf, double topAdd) {
if (maskTabLive.data == null) {
Toast.show(context, "得选着一个标签哦");
return;
}
print("SCARE ===== >>>>> $picScare");
if (pointItem.list.isEmpty) {
Toast.show(context, "还没有标记数据哦~");
return;
}
BaseCenterPicker()
..setPicker(BaseLoadingItem("保存中..."))
..show(context);
List<int> uploadList = [];
pointItem.list.forEach((off) {
uploadList.add((off.dx * picScare).toInt());
print("TOPPPP AADD ${topAdd} ${topBuf}");
if (topAdd < 0) {
uploadList.add(((off.dy - topAdd) * picScare).toInt());
} else {
uploadList.add(((off.dy - topBuf) * picScare).toInt());
}
});
if (uploadList.isNotEmpty) {
getTempDirX(context, (dir) {
var savePath = "${dir}/${DateTime.now().millisecondsSinceEpoch}.jpeg";
DioUtil()
.getDio()
.download(
state == 0
? _repo.checkList[_repo.nowCheckPageIndex].picurl
: _repo.checkMaskList[_repo.nowCheckMaskPageIndex].picurl,
savePath)
.whenComplete(() {
String uploadPath =
"${dir}/sign${DateTime.now().millisecondsSinceEpoch}.jpeg";
toImage(uploadList, uploadPath, savePath).whenComplete(() {
// HomeRepo.getInstance()
// .maskImage(uploadPath, imageId, maskExplain[maskTabLive.data],
// listToUi(pointItem.list))
// .listen((value) {
// if (value != null) {
// Toast.show(context, "保存成功");
// Navigator.pop(context);
// File(uploadPath).delete();
// Navigator.pop(context);
// }
// }).onError((error) {
// Toast.show(context, error.toString());
// print(error.toString());
// Navigator.pop(context);
// });
print("HERE WWWWW");
//TODO HERE WWWWw
String realSavePath =
"${dir}/mask${DateTime.now().millisecondsSinceEpoch}.png";
_repo.uploadMyImage(uploadPath, "${id}").listen((value) {
_repo.downloadMyImage(realSavePath, value.fileId, () {
print("UPLOAD MY OKKKKK");
// toImageTest(uploadList, "${dir}/test${DateTime.now().millisecondsSinceEpoch}.jpeg",savePath ).whenComplete((){});
File(savePath).delete();
File(uploadPath).delete();
// Timer(Duration(seconds: 2),(){
HomeRepo.getInstance()
.maskImage(realSavePath, id, maskExplain[maskTabLive.data],
listToUi(pointItem.list), 1)
.listen((value) {
if (value != null) {
Toast.show(context, "保存成功");
Navigator.pop(context);
Navigator.pop(context);
}
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
Navigator.pop(context);
});
// });
});
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
Navigator.pop(context);
});
}).catchError((error) {
Navigator.pop(context);
Toast.show(context, "保存失败");
print(error.toString());
});
});
});
}
}
void syncPos(double dx, double dy) {
pointItem.setX(dx);
pointItem.setY(dy);
pointLive.notifyView(pointItem);
}
bool needHelpLine = true;
void needHelpLineNotify(bool value) {
needHelpLine = value;
needHelpLineLive.notifyView(needHelpLine);
syncPos(-10, -10);
}
void imageNext(BuildContext context) {
if (state == 0) {
if (currentIndex == 8) {
_repo.getCheckList(_repo.nowCheckPageIndex + 1).listen((data) {
if (data == null || data.picList == null || data.picList.isEmpty) {
Toast.show(context, "已经是最后一张了哦~");
} else {
currentIndex = 0;
_repo.nowCheckPageIndex = _repo.nowCheckPageIndex + 1;
_repo.updateCheckList(data.picList);
getNetWorkImg(context);
id = "${_repo.checkList[currentIndex].id}";
nowIndexLive
.notifyView([_repo.nowCheckPageIndex, currentIndex + 1]);
selectLive.notifyView(null);
getImageResutl(context, false);
}
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
});
} else {
if (currentIndex + 1 > _repo.checkList.length - 1) {
Toast.show(context, "已经是最后一张了哦~");
return;
}
currentIndex = currentIndex + 1;
getNetWorkImg(context);
id = "${_repo.checkList[currentIndex].id}";
selectLive.notifyView(null);
getImageResutl(context, false);
nowIndexLive.notifyView([_repo.nowCheckPageIndex, currentIndex + 1]);
}
} else if (state == 1) {
if (currentIndex == 8) {
_repo.getCheckMaskList(_repo.nowCheckMaskPageIndex + 1).listen((data) {
if (data == null || data.picList == null || data.picList.isEmpty) {
Toast.show(context, "已经是最后一张了哦~");
} else {
currentIndex = 0;
_repo.nowCheckMaskPageIndex = _repo.nowCheckMaskPageIndex + 1;
_repo.updateCheckMaskList(data.picList);
getNetWorkImg(context);
id = "${_repo.checkMaskList[currentIndex].id}";
nowIndexLive
.notifyView([_repo.nowCheckMaskPageIndex, currentIndex + 1]);
selectLive.notifyView(null);
getImageResutl(context, false);
}
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
});
} else {
if (currentIndex + 1 > _repo.checkMaskList.length - 1) {
Toast.show(context, "已经是最后一张了哦~");
return;
}
currentIndex = currentIndex + 1;
getNetWorkImg(context);
id = "${_repo.checkMaskList[currentIndex].id}";
selectLive.notifyView(null);
getImageResutl(context, false);
nowIndexLive
.notifyView([_repo.nowCheckMaskPageIndex, currentIndex + 1]);
}
}
}
void imageBefore(BuildContext context) {
if (state == 0) {
if (currentIndex == 0) {
if (_repo.nowCheckPageIndex == 1) {
Toast.show(context, "已经是第一张了哦~");
return;
}
_repo.nowCheckPageIndex = _repo.nowCheckPageIndex - 1;
_repo.getCheckList(_repo.nowCheckPageIndex).listen((data) {
currentIndex = 8;
_repo.updateCheckList(data.picList);
getNetWorkImg(context);
id = "${_repo.checkList[currentIndex].id}";
selectLive.notifyView(null);
getImageResutl(context, false);
nowIndexLive.notifyView([_repo.nowCheckPageIndex, currentIndex + 1]);
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
});
} else {
currentIndex = currentIndex - 1;
getNetWorkImg(context);
id = "${_repo.checkList[currentIndex].id}";
selectLive.notifyView(null);
getImageResutl(context, false);
nowIndexLive.notifyView([_repo.nowCheckPageIndex, currentIndex + 1]);
}
} else if (state == 1) {
if (currentIndex == 0) {
if (_repo.nowCheckMaskPageIndex == 1) {
Toast.show(context, "已经是第一张了哦~");
return;
}
_repo.nowCheckMaskPageIndex = _repo.nowCheckMaskPageIndex - 1;
_repo.getCheckMaskList(_repo.nowCheckMaskPageIndex).listen((data) {
currentIndex = 8;
_repo.updateCheckMaskList(data.picList);
getNetWorkImg(context);
id = "${_repo.checkMaskList[currentIndex].id}";
selectLive.notifyView(null);
getImageResutl(context, false);
nowIndexLive
.notifyView([_repo.nowCheckMaskPageIndex, currentIndex + 1]);
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
});
} else {
currentIndex = currentIndex - 1;
getNetWorkImg(context);
id = "${_repo.checkMaskList[currentIndex].id}";
selectLive.notifyView(null);
getImageResutl(context, false);
nowIndexLive
.notifyView([_repo.nowCheckMaskPageIndex, currentIndex + 1]);
}
}
}
void save(BuildContext context, bool param1) {
BaseCenterPicker()
..setPicker(BaseLoadingItem("保存中..."))
..show(context);
StringBuffer stringBuffer = new StringBuffer();
stringBuffer.write("""
{"face_details":{
""");
List<List<String>> finalResult = new List();
selectMap.forEach((key, value) {
for (int i = 0; i < value.length; i++) {
String before;
EXPLAN.forEach((k, v) {
if (v == value[i][0]) {
before = k;
}
});
finalResult.add([before, value[i][1]]);
}
});
for (int i = 0; i < finalResult.length; i++) {
stringBuffer.write("""
"${finalResult[i][0]}":"${finalResult[i][1]}"
""");
if (i != finalResult.length - 1) {
stringBuffer.write(",");
}
}
stringBuffer.write("""
},"audit_id": "${CacheManager.getInstance().get(MEMORY_CACHE).get("uid")}"}
""");
print("====> ${stringBuffer.toString()}");
_repo.saveCheckResult(id, stringBuffer.toString()).listen((value) {
if (value != null) {
Navigator.pop(context);
imageNext(context);
// Navigator.pop(context, -1);
Toast.show(context, "保存成功");
}
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
Navigator.pop(context);
});
}
void getMaskedImage(BuildContext context) {
if (maskTabLive.data == null) {
Toast.show(context, "请先选着标签");
return;
}
BaseCenterPicker()
..setPicker(BaseLoadingItem("加载中..."))
..show(context);
HomeRepo.getInstance()
.getMaskInfo(id, maskExplain[maskTabLive.data], 1)
.listen((value) {
print(value.picurl);
if (value != null && value.ui != null && value.ui.isNotEmpty) {
pointItem.list = uiToList(value.ui);
pointItem.drawPath = true;
syncPoint();
}
Navigator.pop(context);
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
Navigator.pop(context);
});
}
void showMaskTabSelect(BuildContext context) {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
List<Widget> list = new List();
maskTabList.forEach((value) {
list.add(new ListTile(
leading: new Icon(Icons.select_all),
title: new Text(value),
onTap: () async {
Navigator.pop(context);
maskTabLive.notifyView(value);
},
));
});
return new Column(mainAxisSize: MainAxisSize.min, children: list);
});
}
}
/*
* @author lsy
* @date 2019-12-09
**/
import 'package:example_flutter/HomeModel/base/BaseTitle.dart';
import 'package:example_flutter/HomeModel/base/bean/PointItem.dart';
import 'package:example_flutter/HomeModel/base/view/WorkView.dart';
import 'package:example_flutter/HomeModel/page/checkInfo/CheckInfoModel.dart';
import 'package:example_flutter/commonModel/GMBase.dart';
import 'package:example_flutter/commonModel/base/BaseState.dart';
import 'package:example_flutter/res/GMRes.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
class CheckInfoPage extends StatefulWidget {
int state;
String id;
int currentIndex;
CheckInfoPage(this.state,this.id,this.currentIndex);
@override
State<StatefulWidget> createState() => CheckInfoState(state,id,currentIndex);
}
class CheckInfoState extends BaseState<CheckInfoPage> {
CheckInfoModel _model;
Size screenSize;
double tabItemHeight = 30;
double rightAllWidth = 238;
double rightTitleHeight = 15;
WorkView workItem;
double picScareSize;
double topBuf;
double topAdd;
bool dragMask;
double dragStartX, dragStartY, startTranX, startTranY;
double tapStartX, tapStartY;
CheckInfoState(int state,String id,int currentIndex){
_model=new CheckInfoModel(state,id,currentIndex);
}
@override
void initState() {
_model.init(context);
super.initState();
}
@override
void dispose() {
_model.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
screenSize = MediaQuery.of(context).size;
List<Widget> body=[];
body.add(mainView());
body.add(divide());
if(_model.state==0){
body.add(centerItem());
body.add(divide());
body.add(rightItem());
}else{
body.add(leftLItem());
body.add(leftItem());
}
return Scaffold(
appBar: MyAppBar(),
body: Row(
children: body,
),
);
}
leftLItem() {
return Container(
width: 200,
height: double.maxFinite,
child: Column(
children: <Widget>[
Container(
height: 30,
),
Container(
alignment: Alignment.center,
width: double.maxFinite,
child: baseText("辅助线", 13, Colors.black),
),
StreamBuilder<bool>(
stream: _model.needHelpLineLive.stream,
initialData: _model.needHelpLineLive.data,
builder: (con,data){
bool needHelpLine;
if(data.data==null||data.data){
needHelpLine=true;
}else{
needHelpLine=false;
}
return Switch(
value: needHelpLine,
activeColor: Colors.blue,
onChanged: (value) {
_model.needHelpLineNotify(value);
},
);
},
),
baseFlatButtonItem(() {
_model.pointItem.close();
_model.syncPoint();
}, "闭合标记"),
baseFlatButtonItem(() {
_model.pointItem.removePoint();
_model.syncPoint();
}, "撤销一步"),
baseFlatButtonItem(() {
_model.pointItem.reset();
_model.syncPoint();
}, "清除所有"),
baseFlatButtonItem(() {
if (_model.pointItem.scareSize == 1) {
_model.pointItem.setScareSize(3);
_model.pointItem.setTranX(_model.pointItem.getX());
_model.pointItem.setTranY(_model.pointItem.getY());
_model.syncPoint();
} else {
_model.pointItem.setScareSize(1);
_model.pointItem.setTranX(0);
_model.pointItem.setTranY(0);
_model.syncPoint();
}
}, "放大&缩小"),
baseFlatButtonItem(() {
_model.getMaskedImage(context);
}, "获取点标记结果"),
baseFlatButtonItem(() {
_model.saveDrawImage(context, picScareSize, topBuf, topAdd);
}, "保存结果"),
Expanded(
child: Container(),
),
baseFlatButtonItem(() {
Navigator.pop(context,-1);
}, "返回上一页"),
],
),
);
}
leftItem() {
return Container(
width: 300,
height: double.maxFinite,
child: Column(
children: <Widget>[
Container(
height: 30,
),
Container(
child: baseFlatButtonItem(() {
_model.showMaskTabSelect(context);
}, "选取标签"),
),
Container(
margin: EdgeInsets.only(top: 3, bottom: 20),
alignment: Alignment.center,
width: double.maxFinite,
child: StreamBuilder(
stream: _model.maskTabLive.stream,
initialData: _model.maskTabLive.data,
builder: (con, data) {
if (data.data == null) {
return baseText("还没有选着标签哦", 12, Colors.black);
}
return baseText("选着的标签:${data.data}", 12, Colors.black);
},
),
),
Expanded(
child: Container(),
),
// baseFlatButtonItem(() {
// Navigator.pop(context,-1);
// }, "返回上一页"),
],
),
);
}
Widget mainView() {
return Expanded(
child: Stack(
alignment: AlignmentDirectional.bottomCenter,
children: <Widget>[
Container(
width: double.maxFinite,
height: double.maxFinite,
color: Colors.black54,
child: Listener(
onPointerDown: (down) {
print("onPointerDownEvent");
},
onPointerMove: (move) {
print("onPointerMove");
},
onPointerUp: (up) {
print("onPointerUp");
},
onPointerHover: (hover) {
if(_model.needHelpLine){
_model.syncPos(
hover.position.dx, hover.position.dy - kToolbarHeight);
}
},
onPointerExit: (exit) {
print("onPointerExit");
},
onPointerCancel: (cancle) {
print("onPointerCancel");
},
onPointerEnter: (enter) {
print("onPointerEnter");
},
)),
StreamBuilder<PointItem>(
stream: _model.pointLive.stream,
initialData: _model.pointLive.data,
builder: (con, data) {
if (data.data == null) {
return Container();
}
workItem = WorkView(_model.pointItem, (scareSize, top, topA) {
picScareSize = scareSize;
topBuf = top;
topAdd = topA;
});
return GestureDetector(
onVerticalDragDown: (details) {
// print(
// "DOWN ${details.localPosition.dx} ${details.localPosition.dy}"
// " ${_model.pointItem.getX()} ${_model.pointItem.getY()}"
// " ${tapStartX} ${tapStartY}");
startTranX = _model.pointItem.tranX;
startTranY = _model.pointItem.tranY;
dragStartX = details.localPosition.dx;
dragStartY = details.localPosition.dy;
},
onVerticalDragEnd: (details) {
_model.pointItem.dragEnd(details);
},
onVerticalDragUpdate: (details) {
_model.pointItem.drag(details, startTranX, dragStartX,
startTranY, dragStartY, dragMask);
_model.syncPoint();
},
onTap: () {
if(_model.state==1) {
_model.pointItem.addPoint(tapStartX, tapStartY);
_model.syncPoint();
}
},
onTapDown: (details) {
tapStartX = details.localPosition.dx;
tapStartY = details.localPosition.dy;
dragMask = workItem.calutePath(Offset(tapStartX, tapStartY));
_model.pointItem.down(tapStartX, tapStartY, dragMask);
print("gesture onTap down");
},
// onDoubleTap: () {
// if (_model.pointItem.scareSize == 1) {
// _model.pointItem.setScareSize(3);
// _model.pointItem.setTranX(_model.pointItem.getX());
// _model.pointItem.setTranY(_model.pointItem.getY());
// _model.syncPoint();
// } else {
// _model.pointItem.setScareSize(1);
// _model.pointItem.setTranX(0);
// _model.pointItem.setTranY(0);
// _model.syncPoint();
// }
// },
child: ClipRect(
child: Container(
width: double.maxFinite,
height: double.maxFinite,
child: CustomPaint(painter: workItem),
)));
},
),
// Container(
// width: double.maxFinite,
// height: double.maxFinite,
// alignment: Alignment.topCenter,
// child: Container(
// width: double.maxFinite,
// height: 50,
// color: Colors.black54,
// child: Row(
// children: <Widget>[],
// )),
// ),
Container(
width: double.maxFinite,
height: 50,
color: Colors.black54,
),
StreamBuilder<List<int>>(
stream: _model.nowIndexLive.stream,
initialData: _model.nowIndexLive.data,
builder: (con, data) {
if (data.data == null) {
return loadingItem();
}
return Container(
height: 50,
alignment: Alignment.center,
child: baseText(
"第${data.data[0]}页 第${data.data[1]}张", 15, Colors.white),
);
},
),
Positioned(
left: 0,
bottom: 0,
child: FlatButton(
onPressed: () {
BaseCenterPicker()
..setPicker(SurePicker("还没有保存哦 确定上一张吗?", () {
Navigator.pop(context);
}, () {
Navigator.pop(context);
_model.imageBefore(context);
}))
..show(context);
},
child: Container(
width: 50,
height: 30,
alignment: Alignment.centerLeft,
child: baseText("上一张", 15, Colors.white),
),
),
),
Positioned(
right: 0,
bottom: 0,
child: FlatButton(
onPressed: () {
BaseCenterPicker()
..setPicker(SurePicker("还没有保存哦 确定下一张吗?", () {
Navigator.pop(context);
}, () {
Navigator.pop(context);
_model.imageNext(context);
}))
..show(context);
},
child: Container(
width: 50,
height: 30,
alignment: Alignment.center,
child: baseText("下一张", 15, Colors.white),
),
),
),
],
));
}
Widget divide() {
return Container(
margin: EdgeInsets.only(left: 2, right: 2),
color: Colors.black38,
width: 1,
height: double.maxFinite,
);
}
rightItem() {
return Container(
height: double.maxFinite,
width: rightAllWidth,
child: StreamBuilder<Map<String, List<List<String>>>>(
stream: _model.tabLive.stream,
initialData: _model.tabLive.data,
builder: (con, data) {
if (data.data == null || data.data.isEmpty) {
return Center(child: CircularProgressIndicator());
}
double tabHeadHeight = 30 + kToolbarHeight;
double center1 = screenSize.width - rightAllWidth;
double center2 = screenSize.width - rightAllWidth / 2;
List<Widget> allList = new List();
allList.add(tabHead());
double startHeight = tabHeadHeight;
data.data.forEach((k, value) {
startHeight = startHeight + (rightTitleHeight + tabItemHeight);
allList.add(divideItem(k));
List<Widget> grids = new List();
for (int i = 0; i < value.length; i += 2) {
if (i != 0) {
startHeight = startHeight + (tabItemHeight);
}
grids.add(glidItem(k, value[i], startHeight, center1));
if (i + 1 < value.length) {
grids.add(glidItem(k, value[i + 1], startHeight, center2));
}
}
int count = (value.length / 2).ceil();
allList.add(tabItem(tabItemHeight * count, grids));
});
return ListView(
physics: BouncingScrollPhysics(),
children: allList,
);
},
));
}
tabItem(double height, List<Widget> items) {
return Container(
width: rightAllWidth / 2,
height: height,
child: GridView.count(
crossAxisCount: 2,
childAspectRatio: rightAllWidth / 2 / tabItemHeight,
children: items,
),
);
}
divideItem(String text) {
return Container(
alignment: Alignment.center,
width: double.maxFinite,
height: rightTitleHeight,
child: baseText(text, 10, Colors.black54),
);
}
glidItem(String key, List<String> dataList, double top, double left) {
String title = dataList[0];
List<PopupMenuItem<String>> list = new List();
for (int i = 1; i < dataList.length; i++) {
list.add(PopupMenuItem(
value: dataList[i],
child: Container(
width: rightAllWidth / 4,
alignment: Alignment.center,
child: baseText(dataList[i], 12, ALColors.Color666666),
)));
}
return Container(
padding: EdgeInsets.all(5),
child: FlatButton(
color: Color.fromARGB(255, 236, 236, 236),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(5))),
onPressed: () async {
final result = await showMenu(
context: context,
position: RelativeRect.fromLTRB(
left, top, left + rightAllWidth / 2, 0),
items: list);
print(result);
if (result != null) {
_model.selectItem(key, title, result);
}
},
child: Container(
width: double.maxFinite,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Expanded(
child: Container(),
),
Container(
padding: EdgeInsets.only(right: 5),
child: baseText(title, 13, Colors.black),
),
Container(
width: 5,
child: SvgPicture.asset("image/bottom_arrow.svg"),
),
Expanded(
child: Container(),
),
],
))));
}
tabHead() {
return GestureDetector(
onTap: () => _model.allTab(context, true),
child: Container(
padding: EdgeInsets.only(top: 5, left: 16),
height: 30,
alignment: Alignment.centerLeft,
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Icon(Icons.sync),
Expanded(
child: Container(),
),
baseButton((){
Navigator.pop(context);
}, EdgeInsets.only(), "返回上一页"),
],
),
));
}
centerItem() {
return Container(
width: 160,
height: double.maxFinite,
child: StreamBuilder<Map<String, List<List<String>>>>(
stream: _model.selectLive.stream,
initialData: _model.selectLive.data,
builder: (con, data) {
if (data.data == null) {
return Column(
children: <Widget>[
centerTitle(context),
Expanded(
child: Center(child: CircularProgressIndicator()),
)
],
);
}
List<Widget> list = new List();
list.add(centerTitle(context));
data.data.forEach((k, v) {
list.add(divideItem(k));
for (int i = 0; i < v.length; i++) {
list.add(centerListItem(k, "${v[i][0]}:${v[i][1]}", v[i][0]));
}
});
return ListView(
physics: BouncingScrollPhysics(),
children: list,
);
},
));
}
centerListItem(String key, String showText, String title) {
return Container(
margin: EdgeInsets.all(5),
color: Color.fromARGB(255, 236, 236, 236),
width: double.maxFinite,
height: 30,
child: Stack(
alignment: AlignmentDirectional.center,
children: <Widget>[
baseText(showText, 13, Colors.black),
Positioned(
right: 5,
top: 5,
child: GestureDetector(
onTap: () {
_model.deleteSelectItem(context, key, title);
},
child: Icon(
Icons.delete,
color: Colors.red,
size: 18,
),
)),
],
),
);
}
Widget centerTitle(BuildContext context) {
return Container(
width: double.maxFinite,
height: 26,
padding: EdgeInsets.only(top: 5, left: 5),
alignment: Alignment.centerLeft,
child: Row(
children: <Widget>[
GestureDetector(
onTap: () {
BaseCenterPicker()
..setPicker(SurePicker("清除已经选好的数据 重新识别图片吗?", () {
Navigator.pop(context);
}, () {
Navigator.pop(context);
_model.getImageResutl(context, true);
}))
..show(context);
},
child: Icon(Icons.sync)),
Expanded(
child: Container(),
),
GestureDetector(
onTap: () {
BaseCenterPicker()
..setPicker(SurePicker("确定保存吗?", () {
Navigator.pop(context);
}, () {
Navigator.pop(context);
_model.save(context, true);
}))
..show(context);
},
child: Container(
decoration: BoxDecoration(
color: Colors.red,
borderRadius: BorderRadius.all(Radius.circular(2))),
alignment: Alignment.center,
height: double.maxFinite,
width: 50,
margin: EdgeInsets.only(right: 5),
child: baseText("保存", 13, Colors.white),
),
)
],
),
);
}
}
......@@ -13,6 +13,7 @@ import 'package:example_flutter/HomeModel/service/HomeRepo.dart';
import 'package:example_flutter/HomeModel/service/remote/entity/AllTabBean.dart';
import 'package:example_flutter/HomeModel/service/remote/entity/ImageResultBean.dart';
import 'package:example_flutter/HomeModel/service/remote/entity/UploadResultBean.dart';
import 'package:example_flutter/HomeModel/util/ParseUtil.dart';
import 'package:example_flutter/commonModel/GMBase.dart';
import 'package:example_flutter/commonModel/picker/base/BasePickerComponent.dart';
import 'package:example_flutter/commonModel/toast/toast.dart';
......@@ -48,165 +49,9 @@ class WorkModel extends BaseModel {
..setPicker(BaseLoadingItem("加载中..."))
..show(context);
}
_repo.imageAi(imageId).listen((value) {
_repo.imageAi("${imageId}").listen((value) {
selectMap.clear();
List<List<String>> browList = new List();
if (value.anno.browsStyle != null && value.anno.browsStyle != "无结果") {
browList.add([EXPLAN["brows_style"], value.anno.browsStyle]);
}
if (value.anno.browsThickness != null &&
value.anno.browsThickness != "无结果") {
browList.add([EXPLAN["brows_thickness"], value.anno.browsThickness]);
}
if (value.anno.dense != null && value.anno.dense != "无结果") {
browList.add([EXPLAN["Dense"], value.anno.dense]);
}
if (value.anno.browDensity != null && value.anno.browDensity != "无结果") {
browList.add([EXPLAN["brow_density"], value.anno.browDensity]);
}
if (value.anno.browsSpacing != null && value.anno.browsSpacing != "无结果") {
browList.add([EXPLAN["brows_spacing"], value.anno.browsSpacing]);
}
if (value.anno.browShape != null && value.anno.browShape != "无结果") {
browList.add([EXPLAN["brow_shape"], value.anno.browShape]);
}
if (browList.isNotEmpty) {
selectMap.putIfAbsent("眉毛部分", () => browList);
}
List<List<String>> eyeList = new List();
if (value.anno.eyelidLeft != null && value.anno.eyelidLeft != "无结果") {
eyeList.add([EXPLAN["eyelid_left"], value.anno.eyelidLeft]);
}
if (value.anno.eyelidRight != null && value.anno.eyelidRight != "无结果") {
eyeList.add([EXPLAN["eyelid_right"], value.anno.eyelidRight]);
}
if (value.anno.eyeShapeRight != null &&
value.anno.eyeShapeRight != "无结果") {
eyeList.add([EXPLAN["eye_shape_right"], value.anno.eyeShapeRight]);
}
if (value.anno.eyeShapeLeft != null && value.anno.eyeShapeLeft != "无结果") {
eyeList.add([EXPLAN["eye_shape_left"], value.anno.eyeShapeLeft]);
}
if (value.anno.pouch != null && value.anno.pouch != "无结果") {
eyeList.add([EXPLAN["pouch"], value.anno.pouch]);
}
if (value.anno.eyeDistance != null && value.anno.eyeDistance != "无结果") {
eyeList.add([EXPLAN["eye_distance"], value.anno.eyeDistance]);
}
if (value.anno.heiyanquanLeft != null && value.anno.heiyanquanLeft != "无结果") {
eyeList.add([EXPLAN["heiyanquan_left"], value.anno.heiyanquanLeft]);
}
if (value.anno.wocanLeft != null && value.anno.wocanLeft != "无结果") {
eyeList.add([EXPLAN["wocan_left"], value.anno.wocanLeft]);
}
if (value.anno.yanwenLeft != null && value.anno.yanwenLeft != "无结果") {
eyeList.add([EXPLAN["yanwen_left"], value.anno.yanwenLeft]);
}
if (value.anno.yuweiwenLeft != null && value.anno.yuweiwenLeft != "无结果") {
eyeList.add([EXPLAN["yuweiwen_left"], value.anno.yuweiwenLeft]);
}
if (value.anno.zhongyanpaoLeft != null && value.anno.zhongyanpaoLeft != "无结果") {
eyeList.add([EXPLAN["zhongyanpao_left"], value.anno.zhongyanpaoLeft]);
}
if (value.anno.leigouLeft != null && value.anno.leigouLeft != "无结果") {
eyeList.add([EXPLAN["leigou_left"], value.anno.leigouLeft]);
}
if (value.anno.heiyanquanRight != null && value.anno.heiyanquanRight != "无结果") {
eyeList.add([EXPLAN["heiyanquan_right"], value.anno.heiyanquanRight]);
}
if (value.anno.wocanRight != null && value.anno.wocanRight != "无结果") {
eyeList.add([EXPLAN["wocan_right"], value.anno.wocanRight]);
}
if (value.anno.yanwenRight != null && value.anno.yanwenRight != "无结果") {
eyeList.add([EXPLAN["yanwen_right"], value.anno.yanwenRight]);
}
if (value.anno.yuweiwenRight != null && value.anno.yuweiwenRight != "无结果") {
eyeList.add([EXPLAN["yuweiwen_right"], value.anno.yuweiwenRight]);
}
if (value.anno.zhongyanpaoRight != null && value.anno.zhongyanpaoRight != "无结果") {
eyeList.add([EXPLAN["zhongyanpao_right"], value.anno.zhongyanpaoRight]);
}
if (value.anno.leigouRight != null && value.anno.leigouRight != "无结果") {
eyeList.add([EXPLAN["leigou_right"], value.anno.leigouRight]);
}
if (eyeList.isNotEmpty) {
selectMap.putIfAbsent("眼睛部分", () => eyeList);
}
List<List<String>> noseList = new List();
if (value.anno.nose != null && value.anno.nose != "无结果") {
noseList.add([EXPLAN["nose"], value.anno.nose]);
}
if (noseList.isNotEmpty) {
selectMap.putIfAbsent("鼻子部分", () => noseList);
}
List<List<String>> lipList = new List();
if (value.anno.lipThickness != null && value.anno.lipThickness != "无结果") {
lipList.add([EXPLAN["lip_thickness"], value.anno.lipThickness]);
}
if (value.anno.lipPeak != null && value.anno.lipPeak != "无结果") {
lipList.add([EXPLAN["lip_peak"], value.anno.lipPeak]);
}
if (value.anno.lipShape != null && value.anno.lipShape != "无结果") {
lipList.add([EXPLAN["lip_shape"], value.anno.lipShape]);
}
if (value.anno.lipRadian != null && value.anno.lipRadian != "无结果") {
lipList.add([EXPLAN["lip_radian"], value.anno.lipRadian]);
}
if (lipList.isNotEmpty) {
selectMap.putIfAbsent("嘴唇部分", () => lipList);
}
List<List<String>> wrinkList = new List();
if (value.anno.wrink != null && value.anno.wrink != "无结果") {
wrinkList.add([EXPLAN["wrink"], value.anno.wrink]);
}
if (wrinkList.isNotEmpty) {
selectMap.putIfAbsent("法令纹", () => wrinkList);
}
List<List<String>> cheekboneList = new List();
if (value.anno.cheekbone != null && value.anno.cheekbone != "无结果") {
cheekboneList.add([EXPLAN["cheekbone"], value.anno.cheekbone]);
}
if (cheekboneList.isNotEmpty) {
selectMap.putIfAbsent("颧骨部分", () => cheekboneList);
}
List<List<String>> chinList = new List();
if (value.anno.chinShape != null && value.anno.chinShape != "无结果") {
chinList.add([EXPLAN["chin_shape"], value.anno.chinShape]);
}
if (chinList.isNotEmpty) {
selectMap.putIfAbsent("下巴部分", () => chinList);
}
List<List<String>> faceList = new List();
if (value.anno.face != null && value.anno.face != "无结果") {
faceList.add([EXPLAN["face"], value.anno.face]);
}
if (faceList.isNotEmpty) {
selectMap.putIfAbsent("脸型相关", () => faceList);
}
selectMap.addAll(ParseUtil.parseSelect(value));
selectLive.notifyView(selectMap);
if (showPicker) {
Navigator.pop(context);
......@@ -221,8 +66,6 @@ class WorkModel extends BaseModel {
});
}
selectChangeToMap() {}
allTab(BuildContext context, bool showPicker) {
if (showPicker) {
BaseCenterPicker()
......@@ -233,277 +76,7 @@ class WorkModel extends BaseModel {
HomeRepo.getInstance().getAllTab().listen((value) {
allTabBean = value;
fixDataMap.clear();
//=====眉毛
List<List<String>> browList = new List();
List<String> eyebrowStyle = new List();
eyebrowStyle.add(allTabBean.eyebrowstyle.name);
eyebrowStyle.add(allTabBean.eyebrowstyle.eyebrowstyleData.willow);
eyebrowStyle.add(allTabBean.eyebrowstyle.eyebrowstyleData.wild);
List<String> eyebrowthickStyle = new List();
eyebrowthickStyle.add(allTabBean.eyebrowthickness.name);
eyebrowthickStyle
.add(allTabBean.eyebrowthickness.eyebrowthicknessData.cumei);
eyebrowthickStyle
.add(allTabBean.eyebrowthickness.eyebrowthicknessData.biaozhunmei);
eyebrowthickStyle
.add(allTabBean.eyebrowthickness.eyebrowthicknessData.xiemei);
List<String> concen = new List();
concen.add(allTabBean.eyebrowsconcentration.name);
concen.add(
allTabBean.eyebrowsconcentration.eyebrowsconcentrationData.piandan);
concen.add(allTabBean
.eyebrowsconcentration.eyebrowsconcentrationData.feichandan);
concen.add(allTabBean
.eyebrowsconcentration.eyebrowsconcentrationData.nongduzhenghao);
List<String> concenf = new List();
concenf.add(allTabBean.eyebrowsconcentrationF.name);
concenf.add(allTabBean
.eyebrowsconcentrationF.eyebrowsconcentrationFData.fenbujunyun);
concenf.add(allTabBean
.eyebrowsconcentrationF.eyebrowsconcentrationFData.qianshuhoumi);
concenf.add(allTabBean
.eyebrowsconcentrationF.eyebrowsconcentrationFData.qianmuhoushu);
concenf.add(allTabBean
.eyebrowsconcentrationF.eyebrowsconcentrationFData.lianjunyun);
List<String> brow = new List();
brow.add(allTabBean.brow.name);
brow.add(allTabBean.brow.browData.wide);
brow.add(allTabBean.brow.browData.narrow);
brow.add(allTabBean.brow.browData.appropriate);
List<String> eyebrow = new List();
eyebrow.add(allTabBean.eyebow.name);
eyebrow.add(allTabBean.eyebow.eyebowData.on);
eyebrow.add(allTabBean.eyebow.eyebowData.standard);
eyebrow.add(allTabBean.eyebow.eyebowData.one);
eyebrow.add(allTabBean.eyebow.eyebowData.sagging);
browList.add(eyebrowStyle);
browList.add(eyebrowthickStyle);
browList.add(concen);
browList.add(concenf);
browList.add(brow);
browList.add(eyebrow);
fixDataMap.putIfAbsent("眉毛部分", () => browList);
//=====眼睛👀
List<List<String>> eyeList = new List();
List<String> lefteye = new List();
lefteye.add(allTabBean.leftEye.name);
lefteye.add(allTabBean.leftEye.leftEyeData.seye);
lefteye.add(allTabBean.leftEye.leftEyeData.eyes);
lefteye.add(allTabBean.leftEye.leftEyeData.doubleIn);
List<String> righteye = new List();
righteye.add(allTabBean.rigthEye.name);
righteye.add(allTabBean.rigthEye.rigthEyeData.seye);
righteye.add(allTabBean.rigthEye.rigthEyeData.eyes);
righteye.add(allTabBean.rigthEye.rigthEyeData.doubleIn);
List<String> eyebag = new List();
eyebag.add(allTabBean.eyebag.name);
eyebag.add(allTabBean.eyebag.eyebagData.yes);
eyebag.add(allTabBean.eyebag.eyebagData.no);
List<String> eyeStyleleft = new List();
eyeStyleleft.add(allTabBean.eyestyleLeft.name);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.almonEyes);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.peach);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.fineCheng);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.deerEye);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.dogEye);
List<String> eyeStyleright = new List();
eyeStyleright.add(allTabBean.eyestyleRight.name);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.almonEyes);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.peach);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.fineCheng);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.deerEye);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.dogEye);
List<String> eyeSpace = new List();
eyeSpace.add(allTabBean.eyespacing.name);
eyeSpace.add(allTabBean.eyespacing.eyespacingData.wide);
eyeSpace.add(allTabBean.eyespacing.eyespacingData.narrow);
eyeSpace.add(allTabBean.eyespacing.eyespacingData.appropriate);
List<String> heiyanquan = new List();
heiyanquan.add(allTabBean.heiyanquanLeft.name);
heiyanquan.add(allTabBean.heiyanquanLeft.heiyanquanLeftData.yes);
heiyanquan.add(allTabBean.heiyanquanLeft.heiyanquanLeftData.no);
List<String> heiyanquanR = new List();
heiyanquanR.add(allTabBean.heiyanquanRight.name);
heiyanquanR.add(allTabBean.heiyanquanRight.heiyanquanRightData.yes);
heiyanquanR.add(allTabBean.heiyanquanRight.heiyanquanRightData.no);
List<String> wocan = new List();
wocan.add(allTabBean.wocanLeft.name);
wocan.add(allTabBean.wocanLeft.wocanLeftData.yes);
wocan.add(allTabBean.wocanLeft.wocanLeftData.no);
List<String> wocanR = new List();
wocanR.add(allTabBean.wocanRight.name);
wocanR.add(allTabBean.wocanRight.wocanRightData.yes);
wocanR.add(allTabBean.wocanRight.wocanRightData.no);
List<String> yanwen = new List();
yanwen.add(allTabBean.yanwenLeft.name);
yanwen.add(allTabBean.yanwenLeft.yanwenLeftData.yes);
yanwen.add(allTabBean.yanwenLeft.yanwenLeftData.no);
List<String> yanwenR = new List();
yanwenR.add(allTabBean.yanwenRight.name);
yanwenR.add(allTabBean.yanwenRight.yanwenRightData.yes);
yanwenR.add(allTabBean.yanwenRight.yanwenRightData.no);
List<String> yuweiwen = new List();
yuweiwen.add(allTabBean.yuweiwenLeft.name);
yuweiwen.add(allTabBean.yuweiwenLeft.yuweiwenLeftData.yes);
yuweiwen.add(allTabBean.yuweiwenLeft.yuweiwenLeftData.no);
List<String> yuweiwenR = new List();
yuweiwenR.add(allTabBean.yuweiwenRight.name);
yuweiwenR.add(allTabBean.yuweiwenRight.yuweiwenRightData.yes);
yuweiwenR.add(allTabBean.yuweiwenRight.yuweiwenRightData.no);
List<String> yanpao = new List();
yanpao.add(allTabBean.zhongyanpaoLeft.name);
yanpao.add(allTabBean.zhongyanpaoLeft.zhongyanpaoLeftData.yes);
yanpao.add(allTabBean.zhongyanpaoLeft.zhongyanpaoLeftData.no);
List<String> yanpaoR = new List();
yanpaoR.add(allTabBean.zhongyanpaoRight.name);
yanpaoR.add(allTabBean.zhongyanpaoRight.zhongyanpaoRightData.yes);
yanpaoR.add(allTabBean.zhongyanpaoRight.zhongyanpaoRightData.no);
List<String> leigou = new List();
leigou.add(allTabBean.leigouLeft.name);
leigou.add(allTabBean.leigouLeft.leigouLeftData.yes);
leigou.add(allTabBean.leigouLeft.leigouLeftData.no);
List<String> leigouR = new List();
leigouR.add(allTabBean.leigouRight.name);
leigouR.add(allTabBean.leigouRight.leigouRightData.yes);
leigouR.add(allTabBean.leigouRight.leigouRightData.no);
eyeList.add(lefteye);
eyeList.add(righteye);
eyeList.add(eyeStyleleft);
eyeList.add(eyeStyleright);
eyeList.add(eyebag);
eyeList.add(eyeSpace);
eyeList.add(heiyanquan);
eyeList.add(heiyanquanR);
eyeList.add(wocan);
eyeList.add(wocanR);
eyeList.add(yanwen);
eyeList.add(yanwenR);
eyeList.add(yuweiwen);
eyeList.add(yuweiwenR);
eyeList.add(yanpao);
eyeList.add(yanpaoR);
eyeList.add(leigou);
eyeList.add(leigouR);
fixDataMap.putIfAbsent("眼睛部分", () => eyeList);
//======== 鼻子👃
List<List<String>> noseList = new List();
List<String> nose = new List();
nose.add(allTabBean.nose.name);
nose.add(allTabBean.nose.noseData.narrowNose);
nose.add(allTabBean.nose.noseData.standardNose);
nose.add(allTabBean.nose.noseData.widepNose);
nose.add(allTabBean.nose.noseData.wideNose);
noseList.add(nose);
fixDataMap.putIfAbsent("鼻子部分", () => noseList);
//====== 嘴唇👄
List<List<String>> mouthList = new List();
List<String> mouth = new List();
mouth.add(allTabBean.mouth.name);
mouth.add(allTabBean.mouth.mouthData.standard);
mouth.add(allTabBean.mouth.mouthData.thick);
mouth.add(allTabBean.mouth.mouthData.thin);
List<String> lip = new List();
lip.add(allTabBean.lip.name);
lip.add(allTabBean.lip.lipData.yes);
lip.add(allTabBean.lip.lipData.no);
lip.add(allTabBean.lip.lipData.notObvious);
List<String> lipscurved = new List();
lipscurved.add(allTabBean.lipscurved.name);
lipscurved.add(allTabBean.lipscurved.lipscurvedData.smile);
lipscurved.add(allTabBean.lipscurved.lipscurvedData.moderate);
lipscurved.add(allTabBean.lipscurved.lipscurvedData.attitude);
List<String> Speciallip = new List();
Speciallip.add(allTabBean.speciallip.name);
Speciallip.add(allTabBean.speciallip.speciallipData.cherryLip);
Speciallip.add(allTabBean.speciallip.speciallipData.supermodelLip);
mouthList.add(mouth);
mouthList.add(lip);
mouthList.add(lipscurved);
mouthList.add(Speciallip);
fixDataMap.putIfAbsent("嘴唇部分", () => mouthList);
//=======其他
List<List<String>> wrinkList = new List();
List<String> wrink = new List();
wrink.add(allTabBean.wrink.name);
wrink.add(allTabBean.wrink.wrinkData.yes);
wrink.add(allTabBean.wrink.wrinkData.no);
wrinkList.add(wrink);
fixDataMap.putIfAbsent("法令纹", () => wrinkList);
List<List<String>> checkboneList = new List();
List<String> checkbone = new List();
checkbone.add(allTabBean.checkbone.name);
checkbone.add(allTabBean.checkbone.checkboneData.high);
checkbone.add(allTabBean.checkbone.checkboneData.flat);
checkboneList.add(checkbone);
fixDataMap.putIfAbsent("颧骨部分", () => checkboneList);
List<List<String>> chinList = new List();
List<String> chin = new List();
chin.add(allTabBean.chin.name);
chin.add(allTabBean.chin.chinData.tip);
chin.add(allTabBean.chin.chinData.party);
chin.add(allTabBean.chin.chinData.round);
chin.add(allTabBean.chin.chinData.ass);
chinList.add(chin);
fixDataMap.putIfAbsent("下巴部分", () => chinList);
List<List<String>> faceList = new List();
List<String> face = new List();
face.add(allTabBean.face.name);
face.add(allTabBean.face.faceData.babyFace);
face.add(allTabBean.face.faceData.guazilian);
face.add(allTabBean.face.faceData.fanglian);
face.add(allTabBean.face.faceData.edanlian);
face.add(allTabBean.face.faceData.changxinglian);
face.add(allTabBean.face.faceData.lixinglian);
face.add(allTabBean.face.faceData.jingzhuan);
faceList.add(face);
fixDataMap.putIfAbsent("脸型相关", () => faceList);
fixDataMap.addAll(ParseUtil.changTabToList(allTabBean));
tabLive.notifyView(fixDataMap);
if (showPicker) {
Navigator.pop(context);
......@@ -748,13 +321,14 @@ class WorkModel extends BaseModel {
// Timer(Duration(seconds: 2),(){
HomeRepo.getInstance()
.maskImage(
realSavePath, imageId, maskExplain[maskTabLive.data],
listToUi(pointItem.list))
realSavePath, "${imageId}", maskExplain[maskTabLive.data],
listToUi(pointItem.list),0)
.listen((value) {
if (value != null) {
Toast.show(context, "保存成功");
Navigator.pop(context);
Navigator.pop(context);
// Navigator.pop(context);
imageNext(context);
}
}).onError((error) {
Toast.show(context, error.toString());
......@@ -857,7 +431,7 @@ class WorkModel extends BaseModel {
..setPicker(BaseLoadingItem("加载中..."))
..show(context);
HomeRepo.getInstance()
.getMaskInfo(imageId, maskExplain[maskTabLive.data])
.getMaskInfo("${imageId}", maskExplain[maskTabLive.data],0)
.listen((value) {
print(value.picurl);
if (value != null && value.ui != null && value.ui.isNotEmpty) {
......
......@@ -54,6 +54,7 @@ class WorkState extends BaseState<WorkPage> {
_model = new WorkModel(id, currentIndex);
}
@override
void initState() {
super.initState();
......
......@@ -309,3 +309,9 @@ String listToUi(List<Offset> list) {
}
return stringBuffer.toString();
}
const STATEEXPLAIN={
"0":"未分配",
"1":"已分配未标记",
"2":"已分配已标记",
"3":"已审核"
};
......@@ -7,6 +7,7 @@ import 'dart:io';
import 'dart:typed_data';
import 'package:dio/dio.dart';
import 'package:example_flutter/HomeModel/base/test/HomeTest.dart';
import 'package:example_flutter/HomeModel/page/work/temp.dart';
import 'package:example_flutter/HomeModel/service/remote/api/HomeApi.serv.dart';
import 'package:example_flutter/HomeModel/service/remote/entity/AllTabBean.dart';
......@@ -25,10 +26,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter_animation_set/animator.dart';
import 'package:rxdart/rxdart.dart';
ImageResultBean paseImageResult(String value) {
return ImageResultBean.fromJson(json.decode(value));
}
class HomeRepo {
Dio mydio;
......@@ -63,10 +60,6 @@ class HomeRepo {
// return Observable.fromFuture(compute(paseImageResult, TEST_IMAGES));
}
Observable<UploadResultBean> upload() {
// DioUtil().downloadFile(urlPath, savePath)
}
List<PicList> currentList = new List();
void updateCurrentPageList(List<PicList> picList) {
......@@ -80,7 +73,7 @@ class HomeRepo {
return currentList;
}
Observable<ImageAiBean> imageAi(int id) {
Observable<ImageAiBean> imageAi(String id) {
return Observable.fromFuture(DioUtil().get('images/${id}/'))
.flatMap((value) {
if (value != null &&
......@@ -108,15 +101,14 @@ class HomeRepo {
}
Observable<MaskResultBean> maskImage(
String path, int id, String tag, String ui) {
String path, String id, String tag, String ui,int tagged) {
var name = path.substring(path.lastIndexOf("/") + 1, path.length);
FormData formData = new FormData.from({
"file": new UploadFileInfo(new File(path), name),
"tag": tag,
"ui": ui
"ui": ui,
"tagged":"${tagged}"
});
var existsSync = File(path).existsSync();
print("EXITTTT $existsSync");
return Observable.fromFuture(DioUtil.getInstance()
.getDio()
.post('maskimages/${id}/', data: formData))
......@@ -131,10 +123,10 @@ class HomeRepo {
});
}
Observable<MaskResultBean> getMaskInfo(int id, String tag) {
Observable<MaskResultBean> getMaskInfo(String id, String tag,int tagged) {
return Observable.fromFuture(DioUtil.getInstance()
.getDio()
.get('maskimages/${id}/', queryParameters: {"tag": tag}))
.get('maskimages/${id}/', queryParameters: {"tag": tag,"tagged":tagged}))
.flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
......@@ -169,7 +161,6 @@ class HomeRepo {
.download("api/downfile", path,
options: Options(method: "POST"), data: FormData.from({"id": id}))
.then((value) {
print(value);
}).whenComplete(() {
ok();
});
......@@ -244,6 +235,69 @@ class HomeRepo {
}
});
}
final int checkPageSize = 9;
int nowCheckPageIndex = 1;
List<PicList> checkList = [];
Observable<ImageResultBean> getCheckList(int currentPage) {
return HomeApiImpl().getCheckList(currentPage, checkPageSize);
// return Observable.fromFuture(
// Future.value(paseImageResultBean(checkListText)));
}
int nowCheckMaskPageIndex = 1;
List<PicList> checkMaskList = [];
Observable<ImageResultBean> getCheckMaskList(int currentPage) {
return HomeApiImpl().getCheckMaskList(currentPage, checkPageSize,"0");
// return Observable.fromFuture(
// Future.value(paseImageResultBean(checkListText)));
}
void updateCheckList(List<PicList> picList) {
if (picList != null && picList.isNotEmpty) {
checkList.clear();
checkList.addAll(picList);
}
}
void updateCheckMaskList(List<PicList> picList) {
if (picList != null && picList.isNotEmpty) {
checkMaskList.clear();
checkMaskList.addAll(picList);
}
}
Observable<ImageAiBean> getCheckImageDetail(String id) {
return Observable.fromFuture(
DioUtil().getDio().get("checkimagedetail/${id}"))
.flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Observable.fromFuture(compute(paseImageAi, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
// return Observable.fromFuture(
// Future.value(ImageAiBean.fromJson(json.decode(checkDetail))));
}
Observable<PutImageDataBean> saveCheckResult(String id, String jsonResult) {
return Observable.fromFuture(DioUtil.getInstance()
.getDio()
.put('checkimagedetail/${id}/', data: jsonResult))
.flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Observable.fromFuture(
compute(parsePutImageBean, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
}
UploadBean parseUpload(String value) {
......
......@@ -26,4 +26,10 @@ abstract class HomeApi{
@Get("countimage/")
TotalImageBean getTotalImages();
@Get("checkimagelist/")
ImageResultBean getCheckList(@Query("page")int page,@Query("pageSize")int pageSize);
@Get("checkmasklist/")
ImageResultBean getCheckMaskList(@Query("page")int page,@Query("pageSize")int pageSize,@Query("tagged")String tagged);
}
\ No newline at end of file
......@@ -83,6 +83,34 @@ class HomeApiImpl {
}
});
}
Observable<ImageResultBean> getCheckList(int page, int pageSize) {
return Observable.fromFuture(DioUtil().get('checkimagelist/',
data: {'page': page, 'pageSize': pageSize})).flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Observable.fromFuture(
compute(paseImageResultBean, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
Observable<ImageResultBean> getCheckMaskList(
int page, int pageSize, String tagged) {
return Observable.fromFuture(DioUtil().get('checkmasklist/',
data: {'page': page, 'pageSize': pageSize, 'tagged': tagged}))
.flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Observable.fromFuture(
compute(paseImageResultBean, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
}
AllTabBean paseAllTabBean(String value) {
......
/*
* @author lsy
* @date 2019-12-10
**/
class CheckDetailBean {
String url;
Anno anno;
CheckDetailBean({this.url, this.anno});
CheckDetailBean.fromJson(Map<String, dynamic> json) {
url = json['url'];
anno = json['anno'] != null ? new Anno.fromJson(json['anno']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url;
if (this.anno != null) {
data['anno'] = this.anno.toJson();
}
return data;
}
}
class Anno {
String eyelidRight;
String eyelidLeft;
String nose;
String wrink;
String lipThickness;
String lipPeak;
String pouch;
String cheekbone;
String browShape;
String browDensity;
String chinShape;
String lipShape;
String lipRadian;
String eyeShapeRight;
String eyeShapeLeft;
String browsStyle;
String browsThickness;
String dense;
String browsSpacing;
String face;
String heiyanquanLeft;
String wocanLeft;
String yanwenLeft;
String yuweiwenLeft;
String zhongyanpaoLeft;
String leigouLeft;
String heiyanquanRight;
String wocanRight;
String yanwenRight;
String yuweiwenRight;
String zhongyanpaoRight;
String leigouRight;
Anno(
{this.eyelidRight,
this.eyelidLeft,
this.nose,
this.wrink,
this.lipThickness,
this.lipPeak,
this.pouch,
this.cheekbone,
this.browShape,
this.browDensity,
this.chinShape,
this.lipShape,
this.lipRadian,
this.eyeShapeRight,
this.eyeShapeLeft,
this.browsStyle,
this.browsThickness,
this.dense,
this.browsSpacing,
this.face,
this.heiyanquanLeft,
this.wocanLeft,
this.yanwenLeft,
this.yuweiwenLeft,
this.zhongyanpaoLeft,
this.leigouLeft,
this.heiyanquanRight,
this.wocanRight,
this.yanwenRight,
this.yuweiwenRight,
this.zhongyanpaoRight,
this.leigouRight});
Anno.fromJson(Map<String, dynamic> json) {
eyelidRight = json['eyelid_right'];
eyelidLeft = json['eyelid_left'];
nose = json['nose'];
wrink = json['wrink'];
lipThickness = json['lip_thickness'];
lipPeak = json['lip_peak'];
pouch = json['pouch'];
cheekbone = json['cheekbone'];
browShape = json['brow_shape'];
browDensity = json['brow_density'];
chinShape = json['chin_shape'];
lipShape = json['lip_shape'];
lipRadian = json['lip_radian'];
eyeShapeRight = json['eye_shape_right'];
eyeShapeLeft = json['eye_shape_left'];
browsStyle = json['brows_style'];
browsThickness = json['brows_thickness'];
dense = json['Dense'];
browsSpacing = json['brows_spacing'];
face = json['face'];
heiyanquanLeft = json['heiyanquan_left'];
wocanLeft = json['wocan_left'];
yanwenLeft = json['yanwen_left'];
yuweiwenLeft = json['yuweiwen_left'];
zhongyanpaoLeft = json['zhongyanpao_left'];
leigouLeft = json['leigou_left'];
heiyanquanRight = json['heiyanquan_right'];
wocanRight = json['wocan_right'];
yanwenRight = json['yanwen_right'];
yuweiwenRight = json['yuweiwen_right'];
zhongyanpaoRight = json['zhongyanpao_right'];
leigouRight = json['leigou_right'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['eyelid_right'] = this.eyelidRight;
data['eyelid_left'] = this.eyelidLeft;
data['nose'] = this.nose;
data['wrink'] = this.wrink;
data['lip_thickness'] = this.lipThickness;
data['lip_peak'] = this.lipPeak;
data['pouch'] = this.pouch;
data['cheekbone'] = this.cheekbone;
data['brow_shape'] = this.browShape;
data['brow_density'] = this.browDensity;
data['chin_shape'] = this.chinShape;
data['lip_shape'] = this.lipShape;
data['lip_radian'] = this.lipRadian;
data['eye_shape_right'] = this.eyeShapeRight;
data['eye_shape_left'] = this.eyeShapeLeft;
data['brows_style'] = this.browsStyle;
data['brows_thickness'] = this.browsThickness;
data['Dense'] = this.dense;
data['brows_spacing'] = this.browsSpacing;
data['face'] = this.face;
data['heiyanquan_left'] = this.heiyanquanLeft;
data['wocan_left'] = this.wocanLeft;
data['yanwen_left'] = this.yanwenLeft;
data['yuweiwen_left'] = this.yuweiwenLeft;
data['zhongyanpao_left'] = this.zhongyanpaoLeft;
data['leigou_left'] = this.leigouLeft;
data['heiyanquan_right'] = this.heiyanquanRight;
data['wocan_right'] = this.wocanRight;
data['yanwen_right'] = this.yanwenRight;
data['yuweiwen_right'] = this.yuweiwenRight;
data['zhongyanpao_right'] = this.zhongyanpaoRight;
data['leigou_right'] = this.leigouRight;
return data;
}
}
......@@ -6,8 +6,8 @@ import 'package:example_flutter/res/anim/Anim.dart';
import 'package:flutter/cupertino.dart';
class JumpUtil {
static void jumpToPage(BuildContext context, Widget widget) {
Navigator.of(context).push(CustomRoute(widget, routeWay: RouteWay.ALP));
static Future jumpToPage(BuildContext context, Widget widget) {
return Navigator.of(context).push(CustomRoute(widget, routeWay: RouteWay.ALP));
}
static void jumpReplace(BuildContext context,Widget widget){
......
/*
* @author lsy
* @date 2019-12-09
**/
import 'package:example_flutter/HomeModel/page/work/temp.dart';
import 'package:example_flutter/HomeModel/service/remote/entity/AllTabBean.dart';
import 'package:example_flutter/HomeModel/service/remote/entity/ImageAiBean.dart';
class ParseUtil {
static Map<String, List<List<String>>> changTabToList(AllTabBean allTabBean) {
Map<String, List<List<String>>> fixDataMap = new Map();
//=====眉毛
List<List<String>> browList = new List();
List<String> eyebrowStyle = new List();
eyebrowStyle.add(allTabBean.eyebrowstyle.name);
eyebrowStyle.add(allTabBean.eyebrowstyle.eyebrowstyleData.willow);
eyebrowStyle.add(allTabBean.eyebrowstyle.eyebrowstyleData.wild);
List<String> eyebrowthickStyle = new List();
eyebrowthickStyle.add(allTabBean.eyebrowthickness.name);
eyebrowthickStyle
.add(allTabBean.eyebrowthickness.eyebrowthicknessData.cumei);
eyebrowthickStyle
.add(allTabBean.eyebrowthickness.eyebrowthicknessData.biaozhunmei);
eyebrowthickStyle
.add(allTabBean.eyebrowthickness.eyebrowthicknessData.xiemei);
List<String> concen = new List();
concen.add(allTabBean.eyebrowsconcentration.name);
concen.add(
allTabBean.eyebrowsconcentration.eyebrowsconcentrationData.piandan);
concen.add(
allTabBean.eyebrowsconcentration.eyebrowsconcentrationData.feichandan);
concen.add(allTabBean
.eyebrowsconcentration.eyebrowsconcentrationData.nongduzhenghao);
List<String> concenf = new List();
concenf.add(allTabBean.eyebrowsconcentrationF.name);
concenf.add(allTabBean
.eyebrowsconcentrationF.eyebrowsconcentrationFData.fenbujunyun);
concenf.add(allTabBean
.eyebrowsconcentrationF.eyebrowsconcentrationFData.qianshuhoumi);
concenf.add(allTabBean
.eyebrowsconcentrationF.eyebrowsconcentrationFData.qianmuhoushu);
concenf.add(allTabBean
.eyebrowsconcentrationF.eyebrowsconcentrationFData.lianjunyun);
List<String> brow = new List();
brow.add(allTabBean.brow.name);
brow.add(allTabBean.brow.browData.wide);
brow.add(allTabBean.brow.browData.narrow);
brow.add(allTabBean.brow.browData.appropriate);
List<String> eyebrow = new List();
eyebrow.add(allTabBean.eyebow.name);
eyebrow.add(allTabBean.eyebow.eyebowData.on);
eyebrow.add(allTabBean.eyebow.eyebowData.standard);
eyebrow.add(allTabBean.eyebow.eyebowData.one);
eyebrow.add(allTabBean.eyebow.eyebowData.sagging);
browList.add(eyebrowStyle);
browList.add(eyebrowthickStyle);
browList.add(concen);
browList.add(concenf);
browList.add(brow);
browList.add(eyebrow);
fixDataMap.putIfAbsent("眉毛部分", () => browList);
//=====眼睛👀
List<List<String>> eyeList = new List();
List<String> lefteye = new List();
lefteye.add(allTabBean.leftEye.name);
lefteye.add(allTabBean.leftEye.leftEyeData.seye);
lefteye.add(allTabBean.leftEye.leftEyeData.eyes);
lefteye.add(allTabBean.leftEye.leftEyeData.doubleIn);
List<String> righteye = new List();
righteye.add(allTabBean.rigthEye.name);
righteye.add(allTabBean.rigthEye.rigthEyeData.seye);
righteye.add(allTabBean.rigthEye.rigthEyeData.eyes);
righteye.add(allTabBean.rigthEye.rigthEyeData.doubleIn);
List<String> eyebag = new List();
eyebag.add(allTabBean.eyebag.name);
eyebag.add(allTabBean.eyebag.eyebagData.yes);
eyebag.add(allTabBean.eyebag.eyebagData.no);
List<String> eyeStyleleft = new List();
eyeStyleleft.add(allTabBean.eyestyleLeft.name);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.almonEyes);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.peach);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.fineCheng);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.deerEye);
eyeStyleleft.add(allTabBean.eyestyleLeft.eyestyleLeftData.dogEye);
List<String> eyeStyleright = new List();
eyeStyleright.add(allTabBean.eyestyleRight.name);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.almonEyes);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.peach);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.fineCheng);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.deerEye);
eyeStyleright.add(allTabBean.eyestyleRight.eyestyleRightData.dogEye);
List<String> eyeSpace = new List();
eyeSpace.add(allTabBean.eyespacing.name);
eyeSpace.add(allTabBean.eyespacing.eyespacingData.wide);
eyeSpace.add(allTabBean.eyespacing.eyespacingData.narrow);
eyeSpace.add(allTabBean.eyespacing.eyespacingData.appropriate);
List<String> heiyanquan = new List();
heiyanquan.add(allTabBean.heiyanquanLeft.name);
heiyanquan.add(allTabBean.heiyanquanLeft.heiyanquanLeftData.yes);
heiyanquan.add(allTabBean.heiyanquanLeft.heiyanquanLeftData.no);
List<String> heiyanquanR = new List();
heiyanquanR.add(allTabBean.heiyanquanRight.name);
heiyanquanR.add(allTabBean.heiyanquanRight.heiyanquanRightData.yes);
heiyanquanR.add(allTabBean.heiyanquanRight.heiyanquanRightData.no);
List<String> wocan = new List();
wocan.add(allTabBean.wocanLeft.name);
wocan.add(allTabBean.wocanLeft.wocanLeftData.yes);
wocan.add(allTabBean.wocanLeft.wocanLeftData.no);
List<String> wocanR = new List();
wocanR.add(allTabBean.wocanRight.name);
wocanR.add(allTabBean.wocanRight.wocanRightData.yes);
wocanR.add(allTabBean.wocanRight.wocanRightData.no);
List<String> yanwen = new List();
yanwen.add(allTabBean.yanwenLeft.name);
yanwen.add(allTabBean.yanwenLeft.yanwenLeftData.yes);
yanwen.add(allTabBean.yanwenLeft.yanwenLeftData.no);
List<String> yanwenR = new List();
yanwenR.add(allTabBean.yanwenRight.name);
yanwenR.add(allTabBean.yanwenRight.yanwenRightData.yes);
yanwenR.add(allTabBean.yanwenRight.yanwenRightData.no);
List<String> yuweiwen = new List();
yuweiwen.add(allTabBean.yuweiwenLeft.name);
yuweiwen.add(allTabBean.yuweiwenLeft.yuweiwenLeftData.yes);
yuweiwen.add(allTabBean.yuweiwenLeft.yuweiwenLeftData.no);
List<String> yuweiwenR = new List();
yuweiwenR.add(allTabBean.yuweiwenRight.name);
yuweiwenR.add(allTabBean.yuweiwenRight.yuweiwenRightData.yes);
yuweiwenR.add(allTabBean.yuweiwenRight.yuweiwenRightData.no);
List<String> yanpao = new List();
yanpao.add(allTabBean.zhongyanpaoLeft.name);
yanpao.add(allTabBean.zhongyanpaoLeft.zhongyanpaoLeftData.yes);
yanpao.add(allTabBean.zhongyanpaoLeft.zhongyanpaoLeftData.no);
List<String> yanpaoR = new List();
yanpaoR.add(allTabBean.zhongyanpaoRight.name);
yanpaoR.add(allTabBean.zhongyanpaoRight.zhongyanpaoRightData.yes);
yanpaoR.add(allTabBean.zhongyanpaoRight.zhongyanpaoRightData.no);
List<String> leigou = new List();
leigou.add(allTabBean.leigouLeft.name);
leigou.add(allTabBean.leigouLeft.leigouLeftData.yes);
leigou.add(allTabBean.leigouLeft.leigouLeftData.no);
List<String> leigouR = new List();
leigouR.add(allTabBean.leigouRight.name);
leigouR.add(allTabBean.leigouRight.leigouRightData.yes);
leigouR.add(allTabBean.leigouRight.leigouRightData.no);
eyeList.add(lefteye);
eyeList.add(righteye);
eyeList.add(eyeStyleleft);
eyeList.add(eyeStyleright);
eyeList.add(eyebag);
eyeList.add(eyeSpace);
eyeList.add(heiyanquan);
eyeList.add(heiyanquanR);
eyeList.add(wocan);
eyeList.add(wocanR);
eyeList.add(yanwen);
eyeList.add(yanwenR);
eyeList.add(yuweiwen);
eyeList.add(yuweiwenR);
eyeList.add(yanpao);
eyeList.add(yanpaoR);
eyeList.add(leigou);
eyeList.add(leigouR);
fixDataMap.putIfAbsent("眼睛部分", () => eyeList);
//======== 鼻子👃
List<List<String>> noseList = new List();
List<String> nose = new List();
nose.add(allTabBean.nose.name);
nose.add(allTabBean.nose.noseData.narrowNose);
nose.add(allTabBean.nose.noseData.standardNose);
nose.add(allTabBean.nose.noseData.widepNose);
nose.add(allTabBean.nose.noseData.wideNose);
noseList.add(nose);
fixDataMap.putIfAbsent("鼻子部分", () => noseList);
//====== 嘴唇👄
List<List<String>> mouthList = new List();
List<String> mouth = new List();
mouth.add(allTabBean.mouth.name);
mouth.add(allTabBean.mouth.mouthData.standard);
mouth.add(allTabBean.mouth.mouthData.thick);
mouth.add(allTabBean.mouth.mouthData.thin);
List<String> lip = new List();
lip.add(allTabBean.lip.name);
lip.add(allTabBean.lip.lipData.yes);
lip.add(allTabBean.lip.lipData.no);
lip.add(allTabBean.lip.lipData.notObvious);
List<String> lipscurved = new List();
lipscurved.add(allTabBean.lipscurved.name);
lipscurved.add(allTabBean.lipscurved.lipscurvedData.smile);
lipscurved.add(allTabBean.lipscurved.lipscurvedData.moderate);
lipscurved.add(allTabBean.lipscurved.lipscurvedData.attitude);
List<String> Speciallip = new List();
Speciallip.add(allTabBean.speciallip.name);
Speciallip.add(allTabBean.speciallip.speciallipData.cherryLip);
Speciallip.add(allTabBean.speciallip.speciallipData.supermodelLip);
mouthList.add(mouth);
mouthList.add(lip);
mouthList.add(lipscurved);
mouthList.add(Speciallip);
fixDataMap.putIfAbsent("嘴唇部分", () => mouthList);
//=======其他
List<List<String>> wrinkList = new List();
List<String> wrink = new List();
wrink.add(allTabBean.wrink.name);
wrink.add(allTabBean.wrink.wrinkData.yes);
wrink.add(allTabBean.wrink.wrinkData.no);
wrinkList.add(wrink);
fixDataMap.putIfAbsent("法令纹", () => wrinkList);
List<List<String>> checkboneList = new List();
List<String> checkbone = new List();
checkbone.add(allTabBean.checkbone.name);
checkbone.add(allTabBean.checkbone.checkboneData.high);
checkbone.add(allTabBean.checkbone.checkboneData.flat);
checkboneList.add(checkbone);
fixDataMap.putIfAbsent("颧骨部分", () => checkboneList);
List<List<String>> chinList = new List();
List<String> chin = new List();
chin.add(allTabBean.chin.name);
chin.add(allTabBean.chin.chinData.tip);
chin.add(allTabBean.chin.chinData.party);
chin.add(allTabBean.chin.chinData.round);
chin.add(allTabBean.chin.chinData.ass);
chinList.add(chin);
fixDataMap.putIfAbsent("下巴部分", () => chinList);
List<List<String>> faceList = new List();
List<String> face = new List();
face.add(allTabBean.face.name);
face.add(allTabBean.face.faceData.babyFace);
face.add(allTabBean.face.faceData.guazilian);
face.add(allTabBean.face.faceData.fanglian);
face.add(allTabBean.face.faceData.edanlian);
face.add(allTabBean.face.faceData.changxinglian);
face.add(allTabBean.face.faceData.lixinglian);
face.add(allTabBean.face.faceData.jingzhuan);
faceList.add(face);
fixDataMap.putIfAbsent("脸型相关", () => faceList);
return fixDataMap;
}
static Map<String, List<List<String>>> parseSelect(ImageAiBean value) {
Map<String, List<List<String>>> selectMap = Map();
List<List<String>> browList = new List();
if (value.anno.browsStyle != null && value.anno.browsStyle != "无结果") {
browList.add([EXPLAN["brows_style"], value.anno.browsStyle]);
}
if (value.anno.browsThickness != null &&
value.anno.browsThickness != "无结果") {
browList.add([EXPLAN["brows_thickness"], value.anno.browsThickness]);
}
if (value.anno.dense != null && value.anno.dense != "无结果") {
browList.add([EXPLAN["Dense"], value.anno.dense]);
}
if (value.anno.browDensity != null && value.anno.browDensity != "无结果") {
browList.add([EXPLAN["brow_density"], value.anno.browDensity]);
}
if (value.anno.browsSpacing != null && value.anno.browsSpacing != "无结果") {
browList.add([EXPLAN["brows_spacing"], value.anno.browsSpacing]);
}
if (value.anno.browShape != null && value.anno.browShape != "无结果") {
browList.add([EXPLAN["brow_shape"], value.anno.browShape]);
}
if (browList.isNotEmpty) {
selectMap.putIfAbsent("眉毛部分", () => browList);
}
List<List<String>> eyeList = new List();
if (value.anno.eyelidLeft != null && value.anno.eyelidLeft != "无结果") {
eyeList.add([EXPLAN["eyelid_left"], value.anno.eyelidLeft]);
}
if (value.anno.eyelidRight != null && value.anno.eyelidRight != "无结果") {
eyeList.add([EXPLAN["eyelid_right"], value.anno.eyelidRight]);
}
if (value.anno.eyeShapeRight != null && value.anno.eyeShapeRight != "无结果") {
eyeList.add([EXPLAN["eye_shape_right"], value.anno.eyeShapeRight]);
}
if (value.anno.eyeShapeLeft != null && value.anno.eyeShapeLeft != "无结果") {
eyeList.add([EXPLAN["eye_shape_left"], value.anno.eyeShapeLeft]);
}
if (value.anno.pouch != null && value.anno.pouch != "无结果") {
eyeList.add([EXPLAN["pouch"], value.anno.pouch]);
}
if (value.anno.eyeDistance != null && value.anno.eyeDistance != "无结果") {
eyeList.add([EXPLAN["eye_distance"], value.anno.eyeDistance]);
}
if (value.anno.heiyanquanLeft != null &&
value.anno.heiyanquanLeft != "无结果") {
eyeList.add([EXPLAN["heiyanquan_left"], value.anno.heiyanquanLeft]);
}
if (value.anno.wocanLeft != null && value.anno.wocanLeft != "无结果") {
eyeList.add([EXPLAN["wocan_left"], value.anno.wocanLeft]);
}
if (value.anno.yanwenLeft != null && value.anno.yanwenLeft != "无结果") {
eyeList.add([EXPLAN["yanwen_left"], value.anno.yanwenLeft]);
}
if (value.anno.yuweiwenLeft != null && value.anno.yuweiwenLeft != "无结果") {
eyeList.add([EXPLAN["yuweiwen_left"], value.anno.yuweiwenLeft]);
}
if (value.anno.zhongyanpaoLeft != null &&
value.anno.zhongyanpaoLeft != "无结果") {
eyeList.add([EXPLAN["zhongyanpao_left"], value.anno.zhongyanpaoLeft]);
}
if (value.anno.leigouLeft != null && value.anno.leigouLeft != "无结果") {
eyeList.add([EXPLAN["leigou_left"], value.anno.leigouLeft]);
}
if (value.anno.heiyanquanRight != null &&
value.anno.heiyanquanRight != "无结果") {
eyeList.add([EXPLAN["heiyanquan_right"], value.anno.heiyanquanRight]);
}
if (value.anno.wocanRight != null && value.anno.wocanRight != "无结果") {
eyeList.add([EXPLAN["wocan_right"], value.anno.wocanRight]);
}
if (value.anno.yanwenRight != null && value.anno.yanwenRight != "无结果") {
eyeList.add([EXPLAN["yanwen_right"], value.anno.yanwenRight]);
}
if (value.anno.yuweiwenRight != null && value.anno.yuweiwenRight != "无结果") {
eyeList.add([EXPLAN["yuweiwen_right"], value.anno.yuweiwenRight]);
}
if (value.anno.zhongyanpaoRight != null &&
value.anno.zhongyanpaoRight != "无结果") {
eyeList.add([EXPLAN["zhongyanpao_right"], value.anno.zhongyanpaoRight]);
}
if (value.anno.leigouRight != null && value.anno.leigouRight != "无结果") {
eyeList.add([EXPLAN["leigou_right"], value.anno.leigouRight]);
}
if (eyeList.isNotEmpty) {
selectMap.putIfAbsent("眼睛部分", () => eyeList);
}
List<List<String>> noseList = new List();
if (value.anno.nose != null && value.anno.nose != "无结果") {
noseList.add([EXPLAN["nose"], value.anno.nose]);
}
if (noseList.isNotEmpty) {
selectMap.putIfAbsent("鼻子部分", () => noseList);
}
List<List<String>> lipList = new List();
if (value.anno.lipThickness != null && value.anno.lipThickness != "无结果") {
lipList.add([EXPLAN["lip_thickness"], value.anno.lipThickness]);
}
if (value.anno.lipPeak != null && value.anno.lipPeak != "无结果") {
lipList.add([EXPLAN["lip_peak"], value.anno.lipPeak]);
}
if (value.anno.lipShape != null && value.anno.lipShape != "无结果") {
lipList.add([EXPLAN["lip_shape"], value.anno.lipShape]);
}
if (value.anno.lipRadian != null && value.anno.lipRadian != "无结果") {
lipList.add([EXPLAN["lip_radian"], value.anno.lipRadian]);
}
if (lipList.isNotEmpty) {
selectMap.putIfAbsent("嘴唇部分", () => lipList);
}
List<List<String>> wrinkList = new List();
if (value.anno.wrink != null && value.anno.wrink != "无结果") {
wrinkList.add([EXPLAN["wrink"], value.anno.wrink]);
}
if (wrinkList.isNotEmpty) {
selectMap.putIfAbsent("法令纹", () => wrinkList);
}
List<List<String>> cheekboneList = new List();
if (value.anno.cheekbone != null && value.anno.cheekbone != "无结果") {
cheekboneList.add([EXPLAN["cheekbone"], value.anno.cheekbone]);
}
if (cheekboneList.isNotEmpty) {
selectMap.putIfAbsent("颧骨部分", () => cheekboneList);
}
List<List<String>> chinList = new List();
if (value.anno.chinShape != null && value.anno.chinShape != "无结果") {
chinList.add([EXPLAN["chin_shape"], value.anno.chinShape]);
}
if (chinList.isNotEmpty) {
selectMap.putIfAbsent("下巴部分", () => chinList);
}
List<List<String>> faceList = new List();
if (value.anno.face != null && value.anno.face != "无结果") {
faceList.add([EXPLAN["face"], value.anno.face]);
}
if (faceList.isNotEmpty) {
selectMap.putIfAbsent("脸型相关", () => faceList);
}
return selectMap;
}
}
......@@ -19,7 +19,6 @@ import '../../../HomePage.dart';
class LoginModel extends BaseModel {
resign(BuildContext context, String text, String text2) {
Resp.getInstance().resign(text, text2).listen((value) {
Navigator.pop(context);
if (value != null && value.username != null) {
login(context, text, text2);
} else {
......@@ -36,19 +35,34 @@ class LoginModel extends BaseModel {
// CacheManager.getInstance().get(MEMORY_CACHE).save("userName", text);
// Navigator.push(context, CustomRoute(HomePage()));
Resp.getInstance().login(text, text2).listen((value) {
Navigator.pop(context);
if (value != null && value.token != null) {
CacheManager.getInstance().get(MEMORY_CACHE).save("token", value.token);
CacheManager.getInstance()
.get(MEMORY_CACHE)
.save("token", value.token);
CacheManager.getInstance().get(MEMORY_CACHE).save("userName", text);
CacheManager.getInstance().get(MEMORY_CACHE).save("userWorld", text2);
Resp.getInstance().getUserInfo().listen((info) {
CacheManager.getInstance().get(MEMORY_CACHE).save("uid", info.uid);
print("UID ${info.uid}");
Resp.getInstance().checkUser(info.uid).listen((check){
CacheManager.getInstance().get(MEMORY_CACHE).save("checkId", check.power);
Navigator.pop(context);
if (value != null && value.token != null) {
Toast.show(context, "登入成功");
// Navigator.push(context, CustomRoute(PicPage()));
// Navigator.push(context,
// CustomRoute(RouterCenterImpl().findHomeRouter()?.getHomePage()));
Navigator.push(context, CustomRoute(HomePage()));
} else {
Toast.show(context, "接口请求错误 ==> login");
}
}).onError((error){
Toast.show(context, error.toString());
print(error.toString());
Navigator.pop(context);
});
}).onError((error) {
Toast.show(context, error.toString());
print(error.toString());
Navigator.pop(context);
});
}).onError((error) {
Navigator.pop(context);
Toast.show(context, error.toString());
......
......@@ -5,11 +5,17 @@
import 'dart:convert';
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:example_flutter/UserModel/service/remote/api/UserApi.serv.dart';
import 'package:example_flutter/UserModel/service/remote/entity/UserBean.dart';
import 'package:example_flutter/UserModel/service/remote/entity/UserCheckBean.dart';
import 'package:example_flutter/UserModel/service/remote/entity/UserToken.dart';
import 'package:example_flutter/commonModel/GMBase.dart';
import 'package:flutter/foundation.dart';
import 'package:rxdart/rxdart.dart';
import 'remote/entity/UserInfoBean.dart';
class Resp {
static Resp _resp;
......@@ -29,4 +35,24 @@ class Resp {
Observable<UserBean> resign(String userName, String userWord) {
return UserApiImpl().resign(userName, userWord);
}
Observable<UserInfoBean> getUserInfo() {
return UserApiImpl().getUserInfo();
}
Observable<UserCheckBean> checkUser(int id) {
return Observable.fromFuture(DioUtil().getDio().get("check/${id}/"))
.flatMap((value) {
if (value != null &&
(value.statusCode >= 200 && value.statusCode < 300)) {
return Observable.fromFuture(compute(parseCheckBean, value.toString()));
} else {
return Observable.fromFuture(null);
}
});
}
}
UserCheckBean parseCheckBean(String value) {
return UserCheckBean.fromJson(json.decode(value));
}
......@@ -23,4 +23,5 @@ abstract class UserApi {
@Get("userinfo/")
UserInfoBean getUserInfo();
}
/*
* @author lsy
* @date 2019-12-09
**/
class UserCheckBean {
int userId;
int power;
UserCheckBean({this.userId, this.power});
UserCheckBean.fromJson(Map<String, dynamic> json) {
userId = json['user_id'];
power = json['power'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['user_id'] = this.userId;
data['power'] = this.power;
return data;
}
}
......@@ -21,8 +21,8 @@ Future<bool> saveString(String key, String value) {
return channel.invokeMethod("setString", {"key": key, "value": value});
}
void getString(BuildContext context,String key, Function(String str) fun) {
channel.invokeMethod("getString",{"key": key}).then((value) {
void getString(BuildContext context, String key, Function(String str) fun) {
channel.invokeMethod("getString", {"key": key}).then((value) {
fun(value);
}).catchError((error) {
Toast.show(context, error.toString());
......@@ -141,3 +141,49 @@ Widget loadingItem() {
Widget netErrorItem() {}
//TODO
Widget baseFlatButtonItem(VoidCallback callback, String text) {
return FlatButton(
padding: EdgeInsets.only(top: 2, bottom: 2),
color: Color.fromARGB(255, 236, 236, 236),
onPressed: callback,
child: baseText(text, 13, Colors.black),
);
}
Widget baseButton(VoidCallback press, EdgeInsetsGeometry margin, String text) {
return FlatButton(
onPressed: press,
child: Container(
margin: margin,
alignment: Alignment.center,
width: 100,
height: 39,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(2),
color: Colors.purple,
gradient: LinearGradient(colors: [
Color.fromARGB(255, 253, 113, 34),
Color.fromARGB(255, 253, 166, 41)
], begin: Alignment.centerRight, end: Alignment.centerLeft),
),
child: baseText(text, 15, Colors.white),
),
);
}
Widget baseDivideRow() {
return Container(
width: 1,
height: double.maxFinite,
color: Colors.black38,
);
}
Widget baseDivideColumn() {
return Container(
width: double.maxFinite,
height: 1,
color: Colors.black38,
);
}
/*
* @author lsy
* @date 2019-12-09
**/
class ExecManager {
int _maxExecOnecCount;
int nowExecOnceCount=0;
int allExecCount=0;
int nowExecCount=0;
Function(int completeIndex) callBack;
ExecManager(this._maxExecOnecCount,this.callBack);
List<IRunner> runner = new List();
void exec(IRunner iRunner) {
runner.add(iRunner);
allExecCount=runner.length;
int recordIndex= nowExecCount;
}
void realExec(int execIndex){
if(nowExecOnceCount<_maxExecOnecCount){
nowExecOnceCount++;
//exec
runner[execIndex].run();
callBack(execIndex);
nowExecCount++;
if(nowExecCount<allExecCount){
int recordCount=nowExecCount;
realExec(recordCount);
}
}
}
}
class ExecBean{
IRunner runner;
}
abstract class IRunner {
void run();
}
\ No newline at end of file
......@@ -64,7 +64,6 @@ class BaseDrawPickerState extends State<BaseDrawPicker>
alp = "0$alp";
}
String colorString = "0x${alp}000000";
print(colorString);
liveData.notifyView(int.parse(colorString));
});
controller.forward();
......
......@@ -7,14 +7,14 @@ PODS:
DEPENDENCIES:
- file_chooser (from `Flutter/ephemeral/.symlinks/plugins/file_chooser/macos`)
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`)
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64-release`)
- path_provider_fde (from `Flutter/ephemeral/.symlinks/plugins/path_provider_fde/macos`)
EXTERNAL SOURCES:
file_chooser:
:path: Flutter/ephemeral/.symlinks/plugins/file_chooser/macos
FlutterMacOS:
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64-release
path_provider_fde:
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_fde/macos
......
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