Browse Source

Merge remote-tracking branch 'origin/wr_202303' into wr_202303

# Conflicts:
#	lib/im/chat_details_page.dart
wr_202303
wurong 4 months ago
parent
commit
4730856f68
  1. 161
      lib/im/chat_details_page.dart
  2. 10
      lib/im/im_view/im_page.dart

161
lib/im/chat_details_page.dart

@ -10,7 +10,6 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/im/database/message.dart';
import 'package:huixiang/im/im_view/w_popup_menu.dart';
import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/data/im_user.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
@ -68,7 +67,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
int copyIndex = 0;
String selfUserId = "";
ImUser _toUser;
String conversation ;
String conversation;
@override
void onMessage(txt) {
@ -125,7 +124,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
Future messageShowTime() async {
List<Message> messagePages = await hxDatabase.queryTList(conversation);
for (var value in messages) {
Message message = messagePages.firstWhere((element) => value.id == element.id, orElse: () => null);
Message message = messagePages
.firstWhere((element) => value.id == element.id, orElse: () => null);
value.showTime = message != null;
}
}
@ -143,8 +143,10 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}
}
if (apiService == null)
apiService = ApiService(Dio(), context: context, token: value.getString("token"));
BaseData<UserInfo> baseData = await apiService.queryInfo().catchError((onError) {});
apiService =
ApiService(Dio(), context: context, token: value.getString("token"));
BaseData<UserInfo> baseData =
await apiService.queryInfo().catchError((onError) {});
if (baseData != null && baseData.isSuccess) {
setState(() {
userInfo = baseData.data;
@ -324,83 +326,84 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}
}
return GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
setState(() {
emojiShowing = false;
isKeyBoardShow = emojiShowing;
moreShow = false;
isKeyBoardShow = moreShow;
});
},
child: Scaffold(
// resizeToAvoidBottomInset: false,
backgroundColor: Color(0xFFF6F6F6),
appBar: MyAppBar(
title: _toUser.nickname,
titleColor: Color(0xFF0D0D0D),
titleSize: 17.sp,
leading: true,
leadingColor: Colors.black,
action: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () async {
await Navigator.of(context).pushNamed('/router/chat_setting',
arguments: {"userId": _toUser.mid});
page = 0;
refresh().then((value) {
refreshState();
});
},
child: Container(
alignment: Alignment.center,
child: Icon(
Icons.more_horiz,
color: Colors.black,
size: 30,
),
behavior: HitTestBehavior.translucent,
onTap: () {
FocusScope.of(context).requestFocus(FocusNode());
setState(() {
needShowSmiley = false;
emojiShowing = false;
isKeyBoardShow = emojiShowing;
moreShow = false;
isKeyBoardShow = moreShow;
});
},
child: Scaffold(
// resizeToAvoidBottomInset: false,
backgroundColor: Color(0xFFF6F6F6),
appBar: MyAppBar(
title: _toUser.nickname,
titleColor: Color(0xFF0D0D0D),
titleSize: 17.sp,
leading: true,
leadingColor: Colors.black,
action: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () async {
await Navigator.of(context).pushNamed('/router/chat_setting',
arguments: {"userId": _toUser.mid});
page = 0;
refresh().then((value) {
refreshState();
});
},
child: Container(
alignment: Alignment.center,
child: Icon(
Icons.more_horiz,
color: Colors.black,
size: 30,
),
),
),
body: Container(
child: Column(
children: [
Expanded(
child: SmartRefresher(
enablePullDown: false,
enablePullUp: true,
header: MyHeader(),
reverse: true,
physics: BouncingScrollPhysics(),
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus mode) {
return SizedBox();
},
),
controller: refreshController,
onLoading: () {
refresh().then((value) {
refreshState();
});
),
body: Container(
child: Column(
children: [
Expanded(
child: SmartRefresher(
enablePullDown: false,
enablePullUp: true,
header: MyHeader(),
reverse: true,
physics: BouncingScrollPhysics(),
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus mode) {
return SizedBox();
},
child: Container(
alignment: Alignment.topCenter,
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
controller: scrollController,
child: chatDetailsList(),
),
),
controller: refreshController,
onLoading: () {
refresh().then((value) {
refreshState();
});
},
child: Container(
alignment: Alignment.topCenter,
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
controller: scrollController,
child: chatDetailsList(),
),
),
flex: 1,
),
input()
],
),
flex: 1,
),
input()
],
),
),
),
);
}
@ -445,12 +448,12 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
// position == messages.length-1
// ?
AppUtils.milliTimeFormatter(DateTime.fromMillisecondsSinceEpoch(
int.parse(messages[position].time)))
// : AppUtils.getTimeDisplay(
// DateTime.fromMillisecondsSinceEpoch(
// int.parse(messages[position].time)),
// DateTime.fromMillisecondsSinceEpoch(
// int.parse(messages[position+1].time)))
int.parse(messages[position].time)))
// : AppUtils.getTimeDisplay(
// DateTime.fromMillisecondsSinceEpoch(
// int.parse(messages[position].time)),
// DateTime.fromMillisecondsSinceEpoch(
// int.parse(messages[position+1].time)))
,
textAlign: TextAlign.center,
style: TextStyle(

10
lib/im/im_view/im_page.dart

@ -102,7 +102,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
listenerRefresh(Message message) async {
await sortConversation(lastMessageMap);
await queryUnreadCount(conversationId);
await queryUnreadCount(conversationIds);
debugPrint("messages_records : ${message.toJson()}");
if (contactMap[message.fromId] == null) {
@ -134,14 +134,11 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
.map((e) => e.conversationId)
.toSet()
.toList();
conversationIds.forEach((element) {
debugPrint("conversationIds: ${element}");
});
}
/// update conversation unreadcount
queryUnreadCount(conversationId) async {
unreadCountMap = await hxDatabase.messageUnreadCount(conversationId);
queryUnreadCount(conversationIds) async {
unreadCountMap = await hxDatabase.messageUnreadCount(conversationIds);
}
/// update imuser info by mids
@ -366,7 +363,6 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
children: conversationIds.map((e) {
debugPrint("---conversationIds: ${e}");
int position = conversationIds.indexOf(e);
return ClipRRect(
// borderRadius: BorderRadius.all(Radius.circular(4)),

Loading…
Cancel
Save