Commit 10f5e357 authored by jinzhu's avatar jinzhu

update message

parent e5d152a5
......@@ -6,3 +6,4 @@ FLUTTER_BUILD_DIR=build
SYMROOT=${SOURCE_ROOT}/../build/ios
FLUTTER_BUILD_NAME=1.0.0
FLUTTER_BUILD_NUMBER=1
TRACK_WIDGET_CREATION=true
......@@ -7,7 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
2A7C125C0CACC37DDDEF23E4 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE75FECF4086195B9BF47D86 /* libPods-Runner.a */; };
741F496221355F47001E2961 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 741F495E21355F27001E2961 /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
741F496821356857001E2961 /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 741F496521356807001E2961 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
74974048213559DB008C567A /* Release.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 74974046213559DB008C567A /* Release.xcconfig */; };
......@@ -18,6 +17,7 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
F4B59E2763DCAA4495440064 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5FE6005870A0D0E3A5601A19 /* libPods-Runner.a */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
......@@ -36,12 +36,14 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
04D2BDC150FABDC4C5358AFF /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
36327579D1207B081B00156B /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
5FE6005870A0D0E3A5601A19 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
741F495E21355F27001E2961 /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = ../.ios/Flutter/engine/Flutter.framework; sourceTree = "<group>"; };
741F496521356807001E2961 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = ../.ios/Flutter/App.framework; sourceTree = "<group>"; };
74974046213559DB008C567A /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
74974047213559DB008C567A /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
7497404A213559E7008C567A /* Flutter.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Flutter.xcconfig; sourceTree = "<group>"; };
77720312324529448B0D5BC6 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = ../.ios/Flutter/Generated.xcconfig; sourceTree = "<group>"; };
......@@ -51,9 +53,7 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
A65AFB7C3DDA9ABA011CCED9 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
C143F97BFDD11D06C7EF5903 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
EE75FECF4086195B9BF47D86 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
BB03ECDE162B52BAAD85A64E /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
......@@ -61,21 +61,13 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2A7C125C0CACC37DDDEF23E4 /* libPods-Runner.a in Frameworks */,
F4B59E2763DCAA4495440064 /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
71DCB4CA2A1A6A7E42E2BAFA /* Frameworks */ = {
isa = PBXGroup;
children = (
EE75FECF4086195B9BF47D86 /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
741F49642135620F001E2961 /* Config */ = {
isa = PBXGroup;
children = (
......@@ -86,17 +78,6 @@
path = Config;
sourceTree = "<group>";
};
8C1AEB0F0BC9DA397EC309B1 /* Pods */ = {
isa = PBXGroup;
children = (
A65AFB7C3DDA9ABA011CCED9 /* Pods-Runner.debug.xcconfig */,
C143F97BFDD11D06C7EF5903 /* Pods-Runner.release.xcconfig */,
04D2BDC150FABDC4C5358AFF /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
......@@ -114,8 +95,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
8C1AEB0F0BC9DA397EC309B1 /* Pods */,
71DCB4CA2A1A6A7E42E2BAFA /* Frameworks */,
B060984A49FBDD6E9DE6C4EB /* Pods */,
C9370850595089E2AB93E9EB /* Frameworks */,
);
sourceTree = "<group>";
};
......@@ -149,6 +130,25 @@
name = "Supporting Files";
sourceTree = "<group>";
};
B060984A49FBDD6E9DE6C4EB /* Pods */ = {
isa = PBXGroup;
children = (
77720312324529448B0D5BC6 /* Pods-Runner.debug.xcconfig */,
BB03ECDE162B52BAAD85A64E /* Pods-Runner.release.xcconfig */,
36327579D1207B081B00156B /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
C9370850595089E2AB93E9EB /* Frameworks */ = {
isa = PBXGroup;
children = (
5FE6005870A0D0E3A5601A19 /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
......@@ -156,14 +156,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
9B452A89DACC7F6698A40547 /* [CP] Check Pods Manifest.lock */,
CCAE7C0D61C6E2B771D35496 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
741F496321355F47001E2961 /* Embed Frameworks */,
CA5E91095C72C451F5EDFD08 /* [CP] Embed Pods Frameworks */,
36EB38719BFA04781186EDC7 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
......@@ -223,6 +223,24 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
36EB38719BFA04781186EDC7 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/engine/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
......@@ -251,7 +269,7 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
9B452A89DACC7F6698A40547 /* [CP] Check Pods Manifest.lock */ = {
CCAE7C0D61C6E2B771D35496 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
......@@ -273,24 +291,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
CA5E91095C72C451F5EDFD08 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../Flutter/engine/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
......
......@@ -2,7 +2,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'package:gmalpha_flutter/macros/ALColors.dart';
import 'pages/message/home/message_home.dart';
// import 'simple_page_widgets.dart';
import 'package:gmalpha_flutter/netWork/DioUtil.dart';
import 'package:dio/dio.dart';
import 'comment_suggest.dart';
void main() {
......@@ -18,6 +20,7 @@ class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
_init();
FlutterBoost.singleton.registerPageBuilders({
// 'first': (pageName, params, _) => FirstRouteWidget(),
......@@ -32,10 +35,15 @@ class _MyAppState extends State<MyApp> {
// return FlutterRouteWidget();
// },
});
FlutterBoost.handleOnStartPage();
}
void _init() {
BaseOptions options = DioUtil.getDefOptions();
Map<String, dynamic> cookie = {'cookie': '_gm_token=4cabd51562739648; _gtid=fac513b6a2bf11e9acfd525400e5c7a38141; sessionid=7j7s902fmro0pvybwrp374khvva6l3xf;'};
HttpConfig config = new HttpConfig(options: options, nativeCookie:cookie);
DioUtil().setConfig(config);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
......
......@@ -2,7 +2,10 @@
import 'package:flutter/material.dart';
import 'package:gmalpha_flutter/model/message/replied_content.dart';
class Message {
// The base class for the different types of items the list can contain.
abstract class ListItem {}
class Message implements ListItem {
final int userId;
final String name;
final String icon;
......@@ -49,4 +52,13 @@ class Message {
}
}
class NotificationItem implements ListItem {
String icon;
String content;
int count;
String title;
NotificationItem(this.icon, this.content, this.count, this.title);
}
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:gmalpha_flutter/model/message/message.dart' as prefix0;
import 'package:gmalpha_flutter/pages/message/home/message_notification_item.dart';
import 'message_item.dart';
import 'package:dio/dio.dart';
import 'package:flutter/semantics.dart';
import 'package:gmalpha_flutter/model/message/message.dart';
import 'package:gmalpha_flutter/netWork/DioUtil.dart';
import 'package:gmalpha_flutter/toast/toast.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:flutter/semantics.dart';
class MessageHomePage extends StatefulWidget {
@override
......@@ -16,22 +17,13 @@ class MessageHomePage extends StatefulWidget {
class _MessageHomePageState extends State<MessageHomePage> with AutomaticKeepAliveClientMixin {
List<Message> messageList = List<Message>();
// List<Map> commentsList=[{'name': 'Burial', 'icon': 'http://alpha-s.gmeiapp.com/2018/12/23/921d3a004e-w', 'time': '1.560856220460315E9', 'content':'卖萌打滚求翻牌', 'replied_content': {'content': 'http://alpha.iyanzhi.com/2019/06/18/1833/5f4c9dd92dc7-thumb'}},
// {'name': '거짓말 ', 'icon': 'http://alpha-s.gmeiapp.com/2018/12/23/8179d48c63-w', 'time': '1.560856220460315E9', 'content':'小姐姐,作图app是啥', 'replied_content': {'content': 'http://alpha.iyanzhi.com/2019/06/18/1833/5f4c9dd92dc7-thumb'}},
// {'name': 'blugder ', 'icon': 'http://alpha-s.gmeiapp.com/2018/12/23/8179d48c63-w', 'time': '1.560856220460315E9', 'content':'拍照表情很自然', 'replied_content': {'content': 'http://alpha.iyanzhi.com/2019/06/18/1833/5f4c9dd92dc7-thumb'}},
// ];
List<ListItem> messageList = List<ListItem>();
List<ListItem> dataArr = List<ListItem>();
// GlobalKey<EasyRefreshState> _easyRefreshKey =new GlobalKey<EasyRefreshState>();
// GlobalKey<RefreshFooterState> _footerKey = new GlobalKey<RefreshFooterState>();
@override
bool get wantKeepAlive => true;
Future<List<Message>> _fetchMesssageList() async {
BaseOptions options = DioUtil.getDefOptions();
Map<String, dynamic> cookie = {'cookie': '_gm_token=4cabd51562739648; _gtid=fac513b6a2bf11e9acfd525400e5c7a38141; sessionid=7j7s902fmro0pvybwrp374khvva6l3xf;'};
HttpConfig config = new HttpConfig(options: options, nativeCookie:cookie);
DioUtil().setConfig(config);
Future<List<ListItem>> _fetchMesssageList() async {
List<Message> messageList = List<Message>();
print('aaaaa');
BaseResp<List> baseresp = await DioUtil().request<List>(Method.get, "api/v1/reply/my", queryParameters: {'page': 1, 'count': 10});
......@@ -47,6 +39,51 @@ class _MessageHomePageState extends State<MessageHomePage> with AutomaticKeepAli
return messageList;
}
Future<List<ListItem>> _fetchNewestInfo() async {
print('---------start----------');
List<ListItem> notiData = List<ListItem>();
BaseRespR noteResp = await DioUtil().requestR(Method.get, 'api/v1/push/newest/info');
Map noteData = noteResp.data;
String noteContent = noteData['content'];
NotificationItem noteItem = NotificationItem('images/message_noti', noteContent, 0, '通知');
notiData.add(noteItem);
BaseRespR likeResp = await DioUtil().requestR(Method.get, 'api/v1/message/unread',queryParameters: {'type': 0});
print(likeResp);
Map likeData = likeResp.data;
String likeContent = '还没有人给你Like哦~';
NotificationItem likeItem = NotificationItem('images/message_like', likeContent, likeData['count'], 'Like');
if (likeItem.count > 0) {
likeItem.content = '有${likeItem.content}个人Like了你';
}
notiData.add(likeItem);
BaseRespR attentionResp = await DioUtil().requestR(Method.get, 'api/v1/message/unread',queryParameters: {'type': 1});
Map attData = attentionResp.data;
String attContent = '还没有人给你关注哦~';
NotificationItem attItem = NotificationItem('images/message_att', attContent, attData['count'], '关注');
if (attItem.count > 0) {
attItem.content = '有${attItem.content}个人关注了你';
}
notiData.add(attItem);
// this.dataArr = dataArr;
return notiData;
}
Future<List<ListItem>> _fetchListData() async {
print('---------start---------');
List<ListItem> dataArr = List<ListItem>();
dataArr = await _fetchNewestInfo();
print(dataArr);
List<ListItem> messageData = await _fetchMesssageList();
messageData.forEach((item) {
dataArr.add(item);
});
print(dataArr);
print('---------end---------');
return dataArr;
}
@override
Widget build(BuildContext context) {
return new Scaffold(
......@@ -55,17 +92,17 @@ class _MessageHomePageState extends State<MessageHomePage> with AutomaticKeepAli
),
floatingActionButton: new FloatingActionButton(
onPressed: () {
_fetchListData();
},
child: new Icon(Icons.add_box),
elevation: 3.0,
highlightElevation: 2.0,
backgroundColor: Colors.red, // 红色
),
// body: ListView(children: _getListData()),
body: new Center(
child: FutureBuilder(
future: _fetchMesssageList(),
future: _fetchListData(),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
......@@ -84,13 +121,19 @@ class _MessageHomePageState extends State<MessageHomePage> with AutomaticKeepAli
Widget _createListView(BuildContext context, AsyncSnapshot snapshot) {
List<Message> messageList = snapshot.data;
List<ListItem> dataArr = snapshot.data;
return ListView.builder(
shrinkWrap: true,
key: new PageStorageKey('message-list'),
itemCount: messageList.length,
itemCount: dataArr.length,
itemBuilder: (BuildContext context, int index) {
return new MessageItem(onPressed: (){}, message:messageList[index]);
ListItem item = dataArr[index];
if (item is Message) {
return new MessageItem(onPressed: (){}, message:item);
} else if (item is NotificationItem){
return new MessageNotificationItem(onPressed: (){}, notification: item);
}
},
);
}
......
......@@ -62,6 +62,10 @@ flutter:
# like this:
assets:
- images/nav_back.png
- images/message_att.png
- images/message_like.png
- images/message_noti.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
......
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