Browse Source

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

wr_202303
zsw 4 months ago
parent
commit
0b295c4d14
  1. 47
      lib/im/add_friend.dart
  2. 51
      lib/im/chat_details_page.dart
  3. 111
      lib/im/im_search.dart
  4. 82
      lib/im/im_view/friend_groip_list.dart
  5. 63
      lib/im/im_view/im_page.dart
  6. 3
      lib/main.dart
  7. 13
      lib/mine/personal_page.dart

47
lib/im/add_friend.dart

@ -18,8 +18,6 @@ class AddFriend extends StatefulWidget {
class _AddFriend extends State<AddFriend> {
ApiService apiService;
final TextEditingController editingController = TextEditingController();
FocusNode _focusNode = FocusNode();
@override
void initState() {
@ -29,7 +27,6 @@ class _AddFriend extends State<AddFriend> {
///
@override
void dispose() {
_focusNode.unfocus();
super.dispose();
}
@ -70,7 +67,7 @@ class _AddFriend extends State<AddFriend> {
)
],
),),
friendGroupSearch(),
addFriendSearch(),
Padding(
padding: EdgeInsets.only(left:18.w,bottom: 16.h),
child: Text(
@ -250,42 +247,38 @@ class _AddFriend extends State<AddFriend> {
}
///
Widget friendGroupSearch() {
return Container(
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w,29.h),
Widget addFriendSearch() {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap:(){Navigator.of(context).pushNamed('/router/im_search');},
child: Container(
margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0),
padding: EdgeInsets.symmetric(vertical: 13.h),
decoration: BoxDecoration(
color: Color(0xFFFDFCFC),
borderRadius: BorderRadius.circular(4),
),
child: TextField(
textInputAction: TextInputAction.search,
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode());
},
controller: editingController,
style: TextStyle(
fontSize: 14.sp,
),
decoration: InputDecoration(
hintText: "搜索",
hintStyle: TextStyle(
fontSize: 14.sp,
color: Color(0xFFA29E9E),
),
isCollapsed: true,
prefixIcon: Padding(
child: Row(
children: [
Padding(
padding: EdgeInsets.only(left: 15.w, right: 5.w),
child: Image.asset(
"assets/image/icon_search.webp",
width: 14.h,
height: 14.h,
color: Color(0xFFB3B3B3),
color: Color(0xFF353535),
),
),
prefixIconConstraints: BoxConstraints(),
border: InputBorder.none,
Text(
"搜索",
style: TextStyle(
color: Color(0xFFA29E9E),
fontSize: 16.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)
),
);
}

51
lib/im/chat_details_page.dart

@ -18,6 +18,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import '../../community/release_dynamic.dart';
import '../../generated/l10n.dart';
import '../../utils/font_weight.dart';
import '../view_widget/custom_image.dart';
import 'im_view/on_chat_message.dart';
import 'im_view/on_chat_msg_instance.dart';
@ -156,9 +157,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
OnChatMsgInstance.instance.onChatMessage = _tempOnChatMessage;
WidgetsBinding.instance.removeObserver(this);
commentFocus.removeListener(_focusNodeListener);
scrollController.dispose();
socketClient.removeCallback(_toUser.mid);
}
void _focusNodeListener() {
@ -253,7 +253,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
// resizeToAvoidBottomInset: false,
backgroundColor: Color(0xFFF6F6F6),
appBar: MyAppBar(
title: "哈哈哈哈",
title: _toUser.nickname,
titleColor: Color(0xFF0D0D0D),
titleSize: 17.sp,
leading: true,
@ -454,24 +454,19 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
),
/// not self
if (!isSelf && isText)
if (!isSelf && !isText)
Padding(
padding: EdgeInsets.only(left: 17.w, right: 39.w),
child: Row(
children: [
// MImage(
// "",
// isCircle: true,
// width: 44,
// height: 44,
// fit: BoxFit.cover,
// errorSrc: "assets/image/default_user.webp",
// fadeSrc: "assets/image/default_user.webp",
// ),
Image.asset(
"assets/image/fuka_zj.webp",
MImage(
_toUser.avatar,
isCircle: true,
height: 44.h,
width: 44.h,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
),
SizedBox(
width: 12.w,
@ -661,25 +656,25 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
SizedBox(
width: 12.w,
),
// MImage(
// "",
// isCircle: true,
// width: 44,
MImage(
_toUser.avatar,
isCircle: true,
height: 44.h,
width: 44.h,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
),
// Image.asset(
// "assets/image/fuka_zj.webp",
// height: 44,
// fit: BoxFit.cover,
// errorSrc: "assets/image/default_user.webp",
// fadeSrc: "assets/image/default_user.webp",
// width: 44,
// ),
Image.asset(
"assets/image/fuka_zj.webp",
height: 44,
width: 44,
),
],
),
),
/// not self image
/// not self image
if (!isSelf && !isText)
Padding(
padding: EdgeInsets.only(left: 17.w, right: 39.w, top: 20.h),

111
lib/im/im_search.dart

@ -0,0 +1,111 @@
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../retrofit/retrofit_api.dart';
import '../view_widget/my_appbar.dart';
class ImSearch extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _ImSearch();
}
}
class _ImSearch extends State<ImSearch> {
ApiService apiService;
final TextEditingController editingController = TextEditingController();
FocusNode _focusNode = FocusNode();
@override
void initState() {
super.initState();
}
///
@override
void dispose() {
_focusNode.unfocus();
super.dispose();
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap:(){
FocusScope.of(context).requestFocus(FocusNode());
},
child: Scaffold(
backgroundColor: Color(0xFFFFFFFF),
resizeToAvoidBottomInset: false,
appBar: MyAppBar(
title: "",
leading: true,
leadingColor: Colors.black,
background: Color(0xFFFFFFFF),
),
body: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
imSearch(),
// Expanded(
// child: ListView.builder(
// itemCount: 10,
// physics: BouncingScrollPhysics(),
// shrinkWrap: true,
// itemBuilder: (context, position) {
// return imSearch();
// },
// )),
],
),
),
),
);
}
///
Widget imSearch() {
return Container(
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w,29.h),
padding: EdgeInsets.symmetric(vertical: 13.h),
decoration: BoxDecoration(
color: Color(0xFFFDFCFC),
borderRadius: BorderRadius.circular(4),
),
child: TextField(
textInputAction: TextInputAction.search,
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode());
},
controller: editingController,
style: TextStyle(
fontSize: 14.sp,
),
decoration: InputDecoration(
hintText: "搜索",
hintStyle: TextStyle(
fontSize: 14.sp,
color: Color(0xFFA29E9E),
),
isCollapsed: true,
prefixIcon: Padding(
padding: EdgeInsets.only(left: 15.w, right: 5.w),
child: Image.asset(
"assets/image/icon_search.webp",
width: 14.h,
height: 14.h,
color: Color(0xFFB3B3B3),
),
),
prefixIconConstraints: BoxConstraints(),
border: InputBorder.none,
),
),
);
}
}

82
lib/im/im_view/friend_groip_list.dart

@ -2,6 +2,7 @@ import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/retrofit/data/im_user.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../retrofit/data/base_data.dart';
@ -10,6 +11,7 @@ import '../../retrofit/data/page.dart';
import '../../retrofit/retrofit_api.dart';
import 'package:huixiang/im/database/message.dart';
import '../../utils/font_weight.dart';
import '../../view_widget/custom_image.dart';
import '../../view_widget/no_data_view.dart';
@ -17,9 +19,7 @@ class FriendGroupList extends StatefulWidget {
final String isMyFans;
final String title;
FriendGroupList(
Key key,this.isMyFans,this.title
) : super(key: key);
FriendGroupList(Key key, this.isMyFans, this.title) : super(key: key);
@override
State<StatefulWidget> createState() {
@ -29,9 +29,7 @@ class FriendGroupList extends StatefulWidget {
class _FriendGroupList extends State<FriendGroupList> {
ApiService apiService;
final TextEditingController editingController = TextEditingController();
RefreshController _refreshController;
FocusNode _focusNode = FocusNode();
List<String> userIds = [];
List<Message> messages = [];
int pageNum = 1;
@ -41,9 +39,9 @@ class _FriendGroupList extends State<FriendGroupList> {
void initState() {
super.initState();
// loadMessageList();
if( widget.isMyFans == ""){
if (widget.isMyFans == "") {
queryMutualFollowList();
} else{
} else {
queryFollowList();
}
}
@ -51,7 +49,6 @@ class _FriendGroupList extends State<FriendGroupList> {
///
@override
void dispose() {
_focusNode.unfocus();
super.dispose();
}
@ -95,14 +92,11 @@ class _FriendGroupList extends State<FriendGroupList> {
list.clear();
}
list.addAll(baseData.data.list);
if(!mounted)
return;
if (!mounted) return;
setState(() {});
}
}
///
queryMutualFollowList() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
@ -126,8 +120,7 @@ class _FriendGroupList extends State<FriendGroupList> {
list.clear();
}
list.addAll(baseData.data.list);
if(!mounted)
return;
if (!mounted) return;
setState(() {});
}
}
@ -143,11 +136,13 @@ class _FriendGroupList extends State<FriendGroupList> {
? NoDataView(
src: "assets/image/guan_zhu.webp",
isShowBtn: false,
text: widget.title == "好友"?"目前暂无${widget?.title ?? ""}":("目前暂无${widget?.title ?? ""}${widget?.title == "" ?
"听说多发动态可以涨粉哦" :"可以在社群广场中关注自己喜欢的人哦"}~"),
text: widget.title == "好友"
? "目前暂无${widget?.title ?? ""}"
: ("目前暂无${widget?.title ?? ""}${widget?.title == "粉丝" ? "听说多发动态可以涨粉哦" : "可以在社群广场中关注自己喜欢的人哦"}~"),
fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h,left: 60.w,right: 60.w),
):Expanded(
margin: EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w),
)
: Expanded(
child: ListView.builder(
itemCount: list.length ?? 0,
physics: BouncingScrollPhysics(),
@ -155,15 +150,18 @@ class _FriendGroupList extends State<FriendGroupList> {
itemBuilder: (context, position) {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap:(){
onTap: () {
Navigator.of(context).pushNamed(
'/router/chat_details_page',
arguments: {
"toId":list[position].mid,
"toUser": ImUser(
avatar: list[position].avatar,
mid: list[position].mid,
nickname: list[position].nickname),
},
);
},
child:friendGroupItem(list[position]),
child: friendGroupItem(list[position]),
);
},
)),
@ -174,7 +172,7 @@ class _FriendGroupList extends State<FriendGroupList> {
Widget friendGroupItem(ListData list) {
return Container(
margin: EdgeInsets.only(left:16.w,right:16.w,bottom: 24.h),
margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 24.h),
child: Row(children: [
Container(
decoration: BoxDecoration(
@ -206,41 +204,37 @@ class _FriendGroupList extends State<FriendGroupList> {
///
Widget friendGroupSearch() {
return Container(
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w,24.h),
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap:(){Navigator.of(context).pushNamed('/router/im_search');},
child: Container(
margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0),
padding: EdgeInsets.symmetric(vertical: 13.h),
decoration: BoxDecoration(
color: Color(0xFFFDFCFC),
borderRadius: BorderRadius.circular(4),
),
child: TextField(
textInputAction: TextInputAction.search,
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode());
},
controller: editingController,
style: TextStyle(
fontSize: 14.sp,
),
decoration: InputDecoration(
hintText: "搜索",
hintStyle: TextStyle(
fontSize: 14.sp,
color: Color(0xFFA29E9E),
),
isCollapsed: true,
prefixIcon: Padding(
child: Row(
children: [
Padding(
padding: EdgeInsets.only(left: 15.w, right: 5.w),
child: Image.asset(
"assets/image/icon_search.webp",
width: 14.h,
height: 14.h,
color: Color(0xFFB3B3B3),
color: Color(0xFF353535),
),
),
prefixIconConstraints: BoxConstraints(),
border: InputBorder.none,
Text(
"搜索",
style: TextStyle(
color: Color(0xFFA29E9E),
fontSize: 16.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)
),
);
}

63
lib/im/im_view/im_page.dart

@ -51,7 +51,10 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
"6": 0,
};
int state = 0;
final TextEditingController imEditingController = TextEditingController();
List<String> userIds = [];
Map<String, Message> lastMessageMap = {};
Map<String, int> unreadCountMap = {};
Map<String, ImUser> contactMap = {};
@override
void onMessage(txt) {
@ -85,11 +88,6 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
queryMsgStats();
}
List<String> userIds = [];
Map<String, Message> lastMessageMap = {};
Map<String, int> unreadCountMap = {};
Map<String, ImUser> contactMap = {};
loadMessageList() async {
SharedPreferences shared = await SharedPreferences.getInstance();
String userId = shared.getString("userId");
@ -122,7 +120,6 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
.where((element) => element != userId)
.toList();
List<ImUser> contacts = (await hxDatabase.queryImUser(userIds)) ?? [];
unreadCountMap = await hxDatabase.messageUnreadCount(userIds, userId);
lastMessageMap = messages.lGroupBy((p0) => p0.toId != userId ? p0.toId : p0.fromId).mGroupItem(key: (p1) => num.parse(p1.time));
@ -343,7 +340,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
],
),
),
imSearchItem(),
imPageSearch(),
chatList(),
// buildMessage(),fgg
],
@ -356,39 +353,22 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
}
///
Widget imSearchItem() {
return Container(
Widget imPageSearch() {
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap:(){
Navigator.of(context).pushNamed('/router/im_search');
},
child: Container(
margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0),
padding: EdgeInsets.symmetric(vertical: 13.h),
decoration: BoxDecoration(
color: Color(0xFFFFFFFF),
color: Color(0xFFFDFCFC),
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
),
],
),
child: TextField(
textInputAction: TextInputAction.search,
onEditingComplete: () {
FocusScope.of(context).requestFocus(FocusNode());
},
controller: imEditingController,
style: TextStyle(
fontSize: 14.sp,
),
decoration: InputDecoration(
hintText: "搜索",
hintStyle: TextStyle(
fontSize: 14.sp,
color: Color(0xFFA29E9E),
),
isCollapsed: true,
prefixIcon: Padding(
child: Row(
children: [
Padding(
padding: EdgeInsets.only(left: 15.w, right: 5.w),
child: Image.asset(
"assets/image/icon_search.webp",
@ -397,9 +377,16 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
color: Color(0xFF353535),
),
),
prefixIconConstraints: BoxConstraints(),
border: InputBorder.none,
Text(
"搜索",
style: TextStyle(
color: Color(0xFFA29E9E),
fontSize: 16.sp,
fontWeight: MyFontWeight.regular,
),
),
],
)
),
);
}

3
lib/main.dart

@ -152,6 +152,7 @@ import 'im/chat_details_page.dart';
import 'im/chat_friend_group.dart';
import 'im/chat_setting.dart';
import 'im/contact_share.dart';
import 'im/im_search.dart';
import 'login/login_store_select.dart';
import 'login/new_login_page.dart';
import 'login/phone_address_page.dart';
@ -625,5 +626,7 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
EditInvoicesInfo(arguments:arguments),
'/router/invoices_detail_page': (context, {arguments}) =>
InvoicesDetailPage(arguments:arguments),
'/router/im_search': (context, {arguments}) =>
ImSearch(),
};

13
lib/mine/personal_page.dart

@ -26,6 +26,7 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../retrofit/data/im_user.dart';
import '../view_widget/my_tab.dart';
class PersonalPage extends StatefulWidget {
@ -862,7 +863,12 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver,Sing
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context)
.pushNamed('/router/chat_details_page');
.pushNamed('/router/chat_details_page',arguments:{
"toUser": ImUser(
avatar: memberInfor?.headimg,
mid: memberInfor?.id,
nickname: memberInfor?.nickname)
});
},
child: Container(
padding:
@ -1294,7 +1300,10 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver,Sing
onTap: () {
Navigator.of(context)
.pushNamed('/router/chat_details_page', arguments: {
"toId": memberInfor.id,
"toUser": ImUser(
avatar: memberInfor?.headimg,
mid: memberInfor?.id,
nickname: memberInfor?.nickname)
},);
},

Loading…
Cancel
Save