Commit 92480998 authored by 林生雨's avatar 林生雨

commit

parent ed07ea9f
......@@ -5,6 +5,10 @@
.packages
.pub/
Flutter/
Runner.xcworkspace/
.gradle/
.idea/
.vagrant/
.sconsign.dblite
......
......@@ -7,6 +7,7 @@ import 'dart:async';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:gengmei_flutter_plugin/ScanImagePlugn.dart';
import 'package:gengmei_flutter_plugin/gengmei_flutter_plugin.dart';
import 'package:gmalpha_flutter/AlbumModel/bean/DirBean.dart';
......@@ -19,6 +20,32 @@ import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
const String MainDir = "IsGengmeiAlbumAllImages";
const String MainDirExplain = "全部相片";
Map<String, List<ScanImageItem>> paseAlbum(Object event) {
var map = Map<String, List<dynamic>>.from(event);
var newMap = Map<String, List<ScanImageItem>>();
map.forEach((k, v) {
var list = List<Map>.from(v);
var scanList = List<ScanImageItem>();
list.forEach((listMap) {
var map2 = Map<String, dynamic>.from(listMap);
ScanImageItem item = new ScanImageItem();
item.path = map2["path"];
item.isVideo = map2["isVideo"] == "T" ? true : false;
item.during = map2["during"] ?? "0";
item.dataToken =
map2["dataToken"] == null ? 0 : int.parse(map2["dataToken"]);
scanList.add(item);
});
newMap[k] = scanList;
});
newMap.forEach((k, eachValue) {
eachValue.sort((a, b) {
return b.dataToken - a.dataToken;
});
});
return newMap;
}
class AlbumModel extends BaseModel {
LiveData<List<ScanImageItem>> albumLive = LiveData();
LiveData<int> selectSizeLive = LiveData();
......@@ -82,24 +109,35 @@ class AlbumModel extends BaseModel {
}
void _onEvent(Object event) {
var map = (event as Map);
if (_mainValue == null || _mainValue.length == 0) {
_mainValue = map;
} else {
_mainValue.forEach((k, itemList) {
var key = map[k];
if (key != null) {
for (int i = 0; i < itemList.length; i++) {
if (key[i] == null) {
continue;
if (Platform.isAndroid) {
var map = (event as Map);
if (_mainValue == null || _mainValue.length == 0) {
_mainValue = map;
} else {
_mainValue.forEach((k, itemList) {
var key = map[k];
if (key != null) {
for (int i = 0; i < itemList.length; i++) {
if (key[i] == null) {
continue;
}
itemList[i].path = key[i]["path"];
itemList[i].realPath = key[i]["realPath"];
}
itemList[i].path = key[i]["path"];
itemList[i].realPath = key[i]["realPath"];
}
}
});
}
albumLive.notifyView(_mainValue[_nowDirName]);
} else {
compute(paseAlbum, event).then((value) {
_mainValue = value;
_dirList.clear();
_mainValue.forEach((k, v) {
_dirList.add(DirBean(k, v.length, File(v[0].path)));
});
albumLive.notifyView(_mainValue[_nowDirName]);
});
}
albumLive.notifyView(_mainValue[_nowDirName]);
}
void _onError(Object error) {
......@@ -107,19 +145,30 @@ class AlbumModel extends BaseModel {
}
void initScanImages(BuildContext context) {
if (Platform.isAndroid) {
_listen = GengmeiFlutterPlugin.phoneImagesEvent
.receiveBroadcastStream()
.listen(_onEvent, onError: _onError);
}
titleData.notifyView(MainDirExplain);
_listen = GengmeiFlutterPlugin.phoneImagesEvent
.receiveBroadcastStream()
.listen(_onEvent, onError: _onError);
AlbumRepository.getInstance().scanPhoneImg().listen((value) {
if (value != null) {
_mainValue = value;
selectSizeLive.notifyView(_selectList.length + _selectVideoList.length);
value.forEach((key, eachValue) {
if (Platform.isIOS) {
eachValue.sort((a, b) {
if (a.dataToken == 0 && b.dataToken != 0) {
return -b.dataToken;
} else if (a.dataToken != 0 && b.dataToken == 0) {
return -a.dataToken;
} else if (a.dataToken == 0 && b.dataToken == 0) {
return 0;
} else {
return b.dataToken - a.dataToken;
}
});
}
if (eachValue != null && !eachValue.isEmpty) {
if (key == MainDir) {
titleData.notifyView(MainDirExplain);
_dirList.add(DirBean(
MainDirExplain, eachValue.length, File(eachValue[0].path)));
albumLive.notifyView(eachValue);
......@@ -301,6 +350,10 @@ class AlbumModel extends BaseModel {
});
}
int allSelectSize() {
return _selectList.length + _selectVideoList.length;
}
void iosAlbumGetImagePath(String path, int index) {}
void nativeCamera(BuildContext context) {
......@@ -325,7 +378,11 @@ class AlbumModel extends BaseModel {
list.insert(0, item);
}
_mainValue[MainDir].insert(0, item);
_selectList.add(item.realPath);
if (Platform.isAndroid) {
_selectList.add(item.realPath);
} else {
_selectList.add(item.path);
}
bool haveIt = false;
_dirList.forEach((it) {
if (it.dirName == foldName) {
......
......@@ -124,12 +124,13 @@ class AlbumState extends BasePage<AlbumPage>
return Center(
child: GestureDetector(
onTap: () {
if (data.data != null && data.data != 0) {
print("LSY ${_model.allSelectSize()}");
if(_model.allSelectSize()>0){
_model.onNext(context);
}
},
child: Container(
margin: EdgeInsets.fromLTRB(0, 0, 16, 0),
padding: EdgeInsets.fromLTRB(0, 0, 16, 0),
child: baseText(showText, 16, color),
)));
},
......
......@@ -75,74 +75,83 @@ class _MessagePageState extends BasePage<MessagePage> {
Widget build(BuildContext context) {
ScreenUtil.instance = ScreenUtil(width: 375, height: 667)..init(context);
return Scaffold(
appBar: AppBar(
leading: Container(
margin: EdgeInsets.only(left: ScreenUtil.instance.setWidth(16), top: ScreenUtil.instance.setHeight(16)),
child: messageTitle('消息'),
),
elevation: 0,
backgroundColor: ALColors.ColorFFFFFF,
),
appBar: MyBar(),
// appBar: AppBar(
// title: Row(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// messageTitle('消息'),
// Expanded(
// child: Container(),
// )
// ],
// ),
// leading: MaterialButton(
// onPressed: () {},
//// padding: EdgeInsets.only(left: ScreenUtil.instance.setWidth(16), top: ScreenUtil.instance.setHeight(16)),
// child: messageTitle('消息'),
// ),
// elevation: 0,
// ),
body: Container(
color: ALColors.ColorFFFFFF,
child: SmartRefresher(
enablePullDown: false,
enablePullUp: true,
footer: CustomFooter(
builder: (BuildContext context, LoadStatus mode) {
String body;
var loadingTS = TextStyle(
color: ALColors.Color999999,
fontSize: ScreenUtil().setSp(16));
if (mode == LoadStatus.idle) {
body = '上拉加载';
} else if (mode == LoadStatus.loading ||
mode == LoadStatus.canLoading) {
body = '加载中...';
} else if (mode == LoadStatus.failed) {
body = '加载失败!点击重试!';
} else {
body = '暂时无更多数据';
}
var loadingIndicator = Visibility(
visible: (mode == LoadStatus.loading ||
mode == LoadStatus.canLoading)
? true
: false,
child: SizedBox(
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation(ALColors.Color999999),
strokeWidth: 2),
width: ScreenUtil().setWidth(16),
height: ScreenUtil().setHeight(16)));
return _pad(
Row(
children: <Widget>[
loadingIndicator,
_pad(Text(body, style: loadingTS),
l: ScreenUtil().setWidth(10))
],
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
),
t: 20.0,
b: 20.0);
},
),
controller: _refreshController,
onLoading: () => _onLoading(context),
child: CustomScrollView(
slivers: <Widget>[
SliverToBoxAdapter(
child: topCard(),
),
getListView()
],
)
),
)
);
enablePullDown: false,
enablePullUp: true,
footer: CustomFooter(
builder: (BuildContext context, LoadStatus mode) {
String body;
var loadingTS = TextStyle(
color: ALColors.Color999999,
fontSize: ScreenUtil().setSp(16));
if (mode == LoadStatus.idle) {
body = '上拉加载';
} else if (mode == LoadStatus.loading ||
mode == LoadStatus.canLoading) {
body = '加载中...';
} else if (mode == LoadStatus.failed) {
body = '加载失败!点击重试!';
} else {
body = '暂时无更多数据';
}
var loadingIndicator = Visibility(
visible: (mode == LoadStatus.loading ||
mode == LoadStatus.canLoading)
? true
: false,
child: SizedBox(
child: CircularProgressIndicator(
valueColor:
AlwaysStoppedAnimation(ALColors.Color999999),
strokeWidth: 2),
width: ScreenUtil().setWidth(16),
height: ScreenUtil().setHeight(16)));
return _pad(
Row(
children: <Widget>[
loadingIndicator,
_pad(Text(body, style: loadingTS),
l: ScreenUtil().setWidth(10))
],
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
),
t: 20.0,
b: 20.0);
},
),
controller: _refreshController,
onLoading: () => _onLoading(context),
child: CustomScrollView(
slivers: <Widget>[
SliverToBoxAdapter(
child: topCard(),
),
getListView()
],
)),
));
}
Widget getListView() {
......@@ -153,18 +162,13 @@ class _MessagePageState extends BasePage<MessagePage> {
var dataList = data?.data?.data;
if (dataList == null) {
return SliverFillViewport(
delegate: SliverChildListDelegate([
Container()
])
);
delegate: SliverChildListDelegate([Container()]));
}
return SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return messageList(dataList[index]);
},
childCount: dataList.length
),
delegate:
SliverChildBuilderDelegate((BuildContext context, int index) {
return messageList(dataList[index]);
}, childCount: dataList.length),
);
});
}
......@@ -274,3 +278,29 @@ class _MessagePageState extends BasePage<MessagePage> {
return widget.fromPage;
}
}
class MyBar extends StatelessWidget implements PreferredSizeWidget {
@override
Size get preferredSize => Size.fromHeight(kToolbarHeight);
@override
Widget build(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
color: Colors.white,
margin: EdgeInsets.only(top: ScreenUtil.instance.setSp(16),
left: ScreenUtil.instance.setSp(16)),
child: messageTitle('消息'),
),
Expanded(
child: Container(
color: Colors.white,
),
)
],
);
}
}
......@@ -9,8 +9,10 @@ import 'package:gmalpha_flutter/res/value/ALColors.dart';
messageTitle(String text) {
return Text(text,
textScaleFactor: 1.0,
style: TextStyle(
color: ALColors.Color323232, fontSize: ScreenUtil().setSp(20)));
color: ALColors.Color323232,
fontSize: ScreenUtil.instance.setSp(20)));
}
var width = ScreenUtil.instance.setWidth(16);
......@@ -208,7 +210,10 @@ Widget messageList(Data list) {
onTap: () {
onClickButton('photo',
{'business_id': list.repliedContent.id.toString()});
jumpToNative('url_page', {"url": 'alpha://${content[list.repliedContent?.type]['openUrl']}'});
jumpToNative('url_page', {
"url":
'alpha://${content[list.repliedContent?.type]['openUrl']}'
});
// jumpToNative('url_page', {
// "url":
// 'alpha://topic_detail?topic_id=${list.repliedContent.topicId}'
......@@ -218,12 +223,12 @@ Widget messageList(Data list) {
width: ScreenUtil.instance.setWidth(48),
height: ScreenUtil.instance.setHeight(48),
child: Image.network(
list.repliedContent.content != null ? list.repliedContent.content : 'http://alpha.iyanzhi.com/topic/2019/08/16/63ef62d019-w',
width: ScreenUtil.instance.setWidth(48),
height: ScreenUtil.instance.setHeight(48)
),
)
)
list.repliedContent.content != null
? list.repliedContent.content
: 'http://alpha.iyanzhi.com/topic/2019/08/16/63ef62d019-w',
width: ScreenUtil.instance.setWidth(48),
height: ScreenUtil.instance.setHeight(48)),
))
],
));
}
......
......@@ -12,6 +12,7 @@ import 'package:cached_network_image/cached_network_image.dart';
import 'package:gmalpha_flutter/commonModel/base/BaseComponent.dart';
import 'package:gmalpha_flutter/commonModel/base/BasePage.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:gmalpha_flutter/res/GMRes.dart';
class ReputationsPage extends StatefulWidget {
ReputationsModel _model;
......@@ -42,8 +43,7 @@ class ReputationsState extends BasePage<ReputationsPage> {
screenWidth = MediaQuery.of(context).size.width;
return WillPopScope(
child: Scaffold(
appBar:
baseAppBarChangeTitle(
appBar: baseAppBarChangeTitle(
title: StreamBuilder<String>(
stream: _model.titleLive.stream,
initialData: _model.titleLive.data,
......@@ -88,11 +88,8 @@ class ReputationsState extends BasePage<ReputationsPage> {
if (index == 1) {
return Container(
margin: EdgeInsets.fromLTRB(19, 16, 19, 32),
child: Text(
data.data.data.introduce[0].answer,
style: TextStyle(
fontSize: 13, color: Color(0xff8E8E8E)),
));
child: baseText(data.data.data.introduce[0].answer,
13, ALColors.Color8E8E8E));
}
if (index == data.data.data.reputations.length + 2) {
//bottom margin
......@@ -222,6 +219,7 @@ class ReputationsState extends BasePage<ReputationsPage> {
Text MyText(double size, String text, int color) {
return Text(
text,
textScaleFactor: 1.0,
softWrap: true,
maxLines: 2,
overflow: TextOverflow.ellipsis,
......
......@@ -54,6 +54,7 @@ AppBar baseAppBarChangeTitle(
Text baseText(String text, double fontSize, Color color) {
return Text(
text,
textScaleFactor: 1.0,
style: TextStyle(fontSize: fontSize, color: color),
);
}
......
......@@ -9,6 +9,7 @@ import 'package:gmalpha_flutter/Error_Page.dart';
import 'package:gmalpha_flutter/TestPage.dart';
import 'commonModel/GMBase.dart';
import 'res/value/ALColors.dart';
void main() {
initParams(() {
......@@ -125,15 +126,15 @@ class _MyAppState extends State<MyApp> {
return MaterialApp(
title: 'Flutter Boost example',
debugShowCheckedModeBanner: false,
// routes: {
// '/': (context) {
// return TestPage();
// },
// },
routes: {
'/': (context) {
return TestPage();
},
},
builder: buildOnce,
theme: new ThemeData(
primaryColor: Colors.white,
backgroundColor: Color(0xFFEFEFEF),
backgroundColor: ALColors.ColorFFFFFF,
accentColor: Color(0xFF888888),
textTheme: TextTheme(
//设置Material的默认字体样式
......
......@@ -336,23 +336,37 @@ class UserLogoutPicker implements ICenterPicker {
child: Container(),
),
baseDivide(1, 0, ALColors.ColorE4E4E4),
GestureDetector(
onTap: sure,
child: Container(
alignment: Alignment.center,
height: 50,
width: double.maxFinite,
child: baseText("确定", 16, ALColors.Color0093FF),
)),
MaterialButton(
height: 50,
elevation: 0,
minWidth: double.maxFinite,
child: baseText("确定", 16, ALColors.Color0093FF),
onPressed: sure,
),
// GestureDetector(
// onTap: sure,
// child: Container(
// alignment: Alignment.center,
// height: 50,
// width: double.maxFinite,
// child: ,
// )),
baseDivide(1, 0, ALColors.ColorE4E4E4),
GestureDetector(
onTap: cancel,
child: Container(
height: 50,
alignment: Alignment.center,
width: double.maxFinite,
child: baseText("取消", 16, ALColors.Color999999),
)),
MaterialButton(
height: 50,
elevation: 0,
minWidth: double.maxFinite,
child: baseText("取消", 16, ALColors.Color999999),
onPressed: cancel,
)
// GestureDetector(
// onTap: cancel,
// child: Container(
// height: 50,
// alignment: Alignment.center,
// width: double.maxFinite,
// child: baseText("取消", 16, ALColors.Color999999),
// )),
],
));
}
......
......@@ -39,7 +39,7 @@ dependencies:
gengmei_flutter_plugin:
git:
url: 'git@git.wanmeizhensuo.com:linshengyu/flutter_plugin.git'
ref: "00b2ed0f616c59ba5352a1dd9a3ed1fe8b2d7cdb"
ref: "f5a11ea753541e0e4e7a6da6260e6f308f94ccf6"
protobuf: ^0.14.4
grpc: ^2.1.2
flutter_svg: ^0.14.1
......
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