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/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/im/database/message.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/main.dart';
import 'package:huixiang/retrofit/data/im_user.dart'; import 'package:huixiang/retrofit/data/im_user.dart';
import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart';
@ -68,7 +67,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
int copyIndex = 0; int copyIndex = 0;
String selfUserId = ""; String selfUserId = "";
ImUser _toUser; ImUser _toUser;
String conversation ; String conversation;
@override @override
void onMessage(txt) { void onMessage(txt) {
@ -125,7 +124,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
Future messageShowTime() async { Future messageShowTime() async {
List<Message> messagePages = await hxDatabase.queryTList(conversation); List<Message> messagePages = await hxDatabase.queryTList(conversation);
for (var value in messages) { 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; value.showTime = message != null;
} }
} }
@ -143,8 +143,10 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
} }
} }
if (apiService == null) if (apiService == null)
apiService = ApiService(Dio(), context: context, token: value.getString("token")); apiService =
BaseData<UserInfo> baseData = await apiService.queryInfo().catchError((onError) {}); ApiService(Dio(), context: context, token: value.getString("token"));
BaseData<UserInfo> baseData =
await apiService.queryInfo().catchError((onError) {});
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
setState(() { setState(() {
userInfo = baseData.data; userInfo = baseData.data;
@ -324,83 +326,84 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
} }
} }
return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.translucent, behavior: HitTestBehavior.translucent,
onTap: () { onTap: () {
FocusScope.of(context).requestFocus(FocusNode()); FocusScope.of(context).requestFocus(FocusNode());
setState(() { setState(() {
emojiShowing = false; needShowSmiley = false;
isKeyBoardShow = emojiShowing; emojiShowing = false;
moreShow = false; isKeyBoardShow = emojiShowing;
isKeyBoardShow = moreShow; moreShow = false;
}); isKeyBoardShow = moreShow;
}, });
child: Scaffold( },
// resizeToAvoidBottomInset: false, child: Scaffold(
backgroundColor: Color(0xFFF6F6F6), // resizeToAvoidBottomInset: false,
appBar: MyAppBar( backgroundColor: Color(0xFFF6F6F6),
title: _toUser.nickname, appBar: MyAppBar(
titleColor: Color(0xFF0D0D0D), title: _toUser.nickname,
titleSize: 17.sp, titleColor: Color(0xFF0D0D0D),
leading: true, titleSize: 17.sp,
leadingColor: Colors.black, leading: true,
action: GestureDetector( leadingColor: Colors.black,
behavior: HitTestBehavior.opaque, action: GestureDetector(
onTap: () async { behavior: HitTestBehavior.opaque,
await Navigator.of(context).pushNamed('/router/chat_setting', onTap: () async {
arguments: {"userId": _toUser.mid}); await Navigator.of(context).pushNamed('/router/chat_setting',
page = 0; arguments: {"userId": _toUser.mid});
refresh().then((value) { page = 0;
refreshState(); refresh().then((value) {
}); refreshState();
}, });
child: Container( },
alignment: Alignment.center, child: Container(
child: Icon( alignment: Alignment.center,
Icons.more_horiz, child: Icon(
color: Colors.black, Icons.more_horiz,
size: 30, color: Colors.black,
), size: 30,
), ),
), ),
), ),
body: Container( ),
child: Column( body: Container(
children: [ child: Column(
Expanded( children: [
child: SmartRefresher( Expanded(
enablePullDown: false, child: SmartRefresher(
enablePullUp: true, enablePullDown: false,
header: MyHeader(), enablePullUp: true,
reverse: true, header: MyHeader(),
physics: BouncingScrollPhysics(), reverse: true,
footer: CustomFooter( physics: BouncingScrollPhysics(),
loadStyle: LoadStyle.ShowWhenLoading, footer: CustomFooter(
builder: (BuildContext context, LoadStatus mode) { loadStyle: LoadStyle.ShowWhenLoading,
return SizedBox(); builder: (BuildContext context, LoadStatus mode) {
}, return SizedBox();
),
controller: refreshController,
onLoading: () {
refresh().then((value) {
refreshState();
});
}, },
child: Container( ),
alignment: Alignment.topCenter, controller: refreshController,
child: SingleChildScrollView( onLoading: () {
physics: BouncingScrollPhysics(), refresh().then((value) {
controller: scrollController, refreshState();
child: chatDetailsList(), });
), },
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 // position == messages.length-1
// ? // ?
AppUtils.milliTimeFormatter(DateTime.fromMillisecondsSinceEpoch( AppUtils.milliTimeFormatter(DateTime.fromMillisecondsSinceEpoch(
int.parse(messages[position].time))) int.parse(messages[position].time)))
// : AppUtils.getTimeDisplay( // : AppUtils.getTimeDisplay(
// DateTime.fromMillisecondsSinceEpoch( // DateTime.fromMillisecondsSinceEpoch(
// int.parse(messages[position].time)), // int.parse(messages[position].time)),
// DateTime.fromMillisecondsSinceEpoch( // DateTime.fromMillisecondsSinceEpoch(
// int.parse(messages[position+1].time))) // int.parse(messages[position+1].time)))
, ,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( 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 { listenerRefresh(Message message) async {
await sortConversation(lastMessageMap); await sortConversation(lastMessageMap);
await queryUnreadCount(conversationId); await queryUnreadCount(conversationIds);
debugPrint("messages_records : ${message.toJson()}"); debugPrint("messages_records : ${message.toJson()}");
if (contactMap[message.fromId] == null) { if (contactMap[message.fromId] == null) {
@ -134,14 +134,11 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
.map((e) => e.conversationId) .map((e) => e.conversationId)
.toSet() .toSet()
.toList(); .toList();
conversationIds.forEach((element) {
debugPrint("conversationIds: ${element}");
});
} }
/// update conversation unreadcount /// update conversation unreadcount
queryUnreadCount(conversationId) async { queryUnreadCount(conversationIds) async {
unreadCountMap = await hxDatabase.messageUnreadCount(conversationId); unreadCountMap = await hxDatabase.messageUnreadCount(conversationIds);
} }
/// update imuser info by mids /// update imuser info by mids
@ -366,7 +363,6 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
shrinkWrap: true, shrinkWrap: true,
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
children: conversationIds.map((e) { children: conversationIds.map((e) {
debugPrint("---conversationIds: ${e}");
int position = conversationIds.indexOf(e); int position = conversationIds.indexOf(e);
return ClipRRect( return ClipRRect(
// borderRadius: BorderRadius.all(Radius.circular(4)), // borderRadius: BorderRadius.all(Radius.circular(4)),

Loading…
Cancel
Save