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. 70
      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> { class _AddFriend extends State<AddFriend> {
ApiService apiService; ApiService apiService;
final TextEditingController editingController = TextEditingController();
FocusNode _focusNode = FocusNode();
@override @override
void initState() { void initState() {
@ -29,7 +27,6 @@ class _AddFriend extends State<AddFriend> {
/// ///
@override @override
void dispose() { void dispose() {
_focusNode.unfocus();
super.dispose(); super.dispose();
} }
@ -70,7 +67,7 @@ class _AddFriend extends State<AddFriend> {
) )
], ],
),), ),),
friendGroupSearch(), addFriendSearch(),
Padding( Padding(
padding: EdgeInsets.only(left:18.w,bottom: 16.h), padding: EdgeInsets.only(left:18.w,bottom: 16.h),
child: Text( child: Text(
@ -250,42 +247,38 @@ class _AddFriend extends State<AddFriend> {
} }
/// ///
Widget friendGroupSearch() { Widget addFriendSearch() {
return Container( return GestureDetector(
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w,29.h), 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), padding: EdgeInsets.symmetric(vertical: 13.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFFDFCFC), color: Color(0xFFFDFCFC),
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
), ),
child: TextField( child: Row(
textInputAction: TextInputAction.search, children: [
onEditingComplete: () { Padding(
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), padding: EdgeInsets.only(left: 15.w, right: 5.w),
child: Image.asset( child: Image.asset(
"assets/image/icon_search.webp", "assets/image/icon_search.webp",
width: 14.h, width: 14.h,
height: 14.h, height: 14.h,
color: Color(0xFFB3B3B3), color: Color(0xFF353535),
), ),
), ),
prefixIconConstraints: BoxConstraints(), Text(
border: InputBorder.none, "搜索",
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 '../../community/release_dynamic.dart';
import '../../generated/l10n.dart'; import '../../generated/l10n.dart';
import '../../utils/font_weight.dart'; import '../../utils/font_weight.dart';
import '../view_widget/custom_image.dart';
import 'im_view/on_chat_message.dart'; import 'im_view/on_chat_message.dart';
import 'im_view/on_chat_msg_instance.dart'; import 'im_view/on_chat_msg_instance.dart';
@ -156,9 +157,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
OnChatMsgInstance.instance.onChatMessage = _tempOnChatMessage; OnChatMsgInstance.instance.onChatMessage = _tempOnChatMessage;
WidgetsBinding.instance.removeObserver(this); WidgetsBinding.instance.removeObserver(this);
commentFocus.removeListener(_focusNodeListener); commentFocus.removeListener(_focusNodeListener);
scrollController.dispose();
socketClient.removeCallback(_toUser.mid); socketClient.removeCallback(_toUser.mid);
} }
void _focusNodeListener() { void _focusNodeListener() {
@ -253,7 +253,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
// resizeToAvoidBottomInset: false, // resizeToAvoidBottomInset: false,
backgroundColor: Color(0xFFF6F6F6), backgroundColor: Color(0xFFF6F6F6),
appBar: MyAppBar( appBar: MyAppBar(
title: "哈哈哈哈", title: _toUser.nickname,
titleColor: Color(0xFF0D0D0D), titleColor: Color(0xFF0D0D0D),
titleSize: 17.sp, titleSize: 17.sp,
leading: true, leading: true,
@ -454,24 +454,19 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
), ),
/// not self /// not self
if (!isSelf && isText) if (!isSelf && !isText)
Padding( Padding(
padding: EdgeInsets.only(left: 17.w, right: 39.w), padding: EdgeInsets.only(left: 17.w, right: 39.w),
child: Row( child: Row(
children: [ children: [
// MImage( MImage(
// "", _toUser.avatar,
// isCircle: true, 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",
height: 44.h, height: 44.h,
width: 44.h, width: 44.h,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
), ),
SizedBox( SizedBox(
width: 12.w, width: 12.w,
@ -661,25 +656,25 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
SizedBox( SizedBox(
width: 12.w, width: 12.w,
), ),
// MImage( MImage(
// "", _toUser.avatar,
// isCircle: true, isCircle: true,
// width: 44, 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, // height: 44,
// fit: BoxFit.cover, // width: 44,
// errorSrc: "assets/image/default_user.webp",
// fadeSrc: "assets/image/default_user.webp",
// ), // ),
Image.asset(
"assets/image/fuka_zj.webp",
height: 44,
width: 44,
),
], ],
), ),
), ),
/// not self image /// not self image
if (!isSelf && !isText) if (!isSelf && !isText)
Padding( Padding(
padding: EdgeInsets.only(left: 17.w, right: 39.w, top: 20.h), 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,
),
),
);
}
}

70
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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.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:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../../retrofit/data/base_data.dart'; import '../../retrofit/data/base_data.dart';
@ -10,6 +11,7 @@ import '../../retrofit/data/page.dart';
import '../../retrofit/retrofit_api.dart'; import '../../retrofit/retrofit_api.dart';
import 'package:huixiang/im/database/message.dart'; import 'package:huixiang/im/database/message.dart';
import '../../utils/font_weight.dart';
import '../../view_widget/custom_image.dart'; import '../../view_widget/custom_image.dart';
import '../../view_widget/no_data_view.dart'; import '../../view_widget/no_data_view.dart';
@ -17,9 +19,7 @@ class FriendGroupList extends StatefulWidget {
final String isMyFans; final String isMyFans;
final String title; final String title;
FriendGroupList( FriendGroupList(Key key, this.isMyFans, this.title) : super(key: key);
Key key,this.isMyFans,this.title
) : super(key: key);
@override @override
State<StatefulWidget> createState() { State<StatefulWidget> createState() {
@ -29,9 +29,7 @@ class FriendGroupList extends StatefulWidget {
class _FriendGroupList extends State<FriendGroupList> { class _FriendGroupList extends State<FriendGroupList> {
ApiService apiService; ApiService apiService;
final TextEditingController editingController = TextEditingController();
RefreshController _refreshController; RefreshController _refreshController;
FocusNode _focusNode = FocusNode();
List<String> userIds = []; List<String> userIds = [];
List<Message> messages = []; List<Message> messages = [];
int pageNum = 1; int pageNum = 1;
@ -51,7 +49,6 @@ class _FriendGroupList extends State<FriendGroupList> {
/// ///
@override @override
void dispose() { void dispose() {
_focusNode.unfocus();
super.dispose(); super.dispose();
} }
@ -95,14 +92,11 @@ class _FriendGroupList extends State<FriendGroupList> {
list.clear(); list.clear();
} }
list.addAll(baseData.data.list); list.addAll(baseData.data.list);
if(!mounted) if (!mounted) return;
return;
setState(() {}); setState(() {});
} }
} }
/// ///
queryMutualFollowList() async { queryMutualFollowList() async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
@ -126,8 +120,7 @@ class _FriendGroupList extends State<FriendGroupList> {
list.clear(); list.clear();
} }
list.addAll(baseData.data.list); list.addAll(baseData.data.list);
if(!mounted) if (!mounted) return;
return;
setState(() {}); setState(() {});
} }
} }
@ -143,11 +136,13 @@ class _FriendGroupList extends State<FriendGroupList> {
? NoDataView( ? NoDataView(
src: "assets/image/guan_zhu.webp", src: "assets/image/guan_zhu.webp",
isShowBtn: false, isShowBtn: false,
text: widget.title == "好友"?"目前暂无${widget?.title ?? ""}":("目前暂无${widget?.title ?? ""}${widget?.title == "" ? text: widget.title == "好友"
"听说多发动态可以涨粉哦" :"可以在社群广场中关注自己喜欢的人哦"}~"), ? "目前暂无${widget?.title ?? ""}"
: ("目前暂无${widget?.title ?? ""}${widget?.title == "粉丝" ? "听说多发动态可以涨粉哦" : "可以在社群广场中关注自己喜欢的人哦"}~"),
fontSize: 16.sp, fontSize: 16.sp,
margin: EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w), margin: EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w),
):Expanded( )
: Expanded(
child: ListView.builder( child: ListView.builder(
itemCount: list.length ?? 0, itemCount: list.length ?? 0,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
@ -159,7 +154,10 @@ class _FriendGroupList extends State<FriendGroupList> {
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
'/router/chat_details_page', '/router/chat_details_page',
arguments: { arguments: {
"toId":list[position].mid, "toUser": ImUser(
avatar: list[position].avatar,
mid: list[position].mid,
nickname: list[position].nickname),
}, },
); );
}, },
@ -206,41 +204,37 @@ class _FriendGroupList extends State<FriendGroupList> {
/// ///
Widget friendGroupSearch() { Widget friendGroupSearch() {
return Container( return GestureDetector(
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w,24.h), 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), padding: EdgeInsets.symmetric(vertical: 13.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFFDFCFC), color: Color(0xFFFDFCFC),
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
), ),
child: TextField( child: Row(
textInputAction: TextInputAction.search, children: [
onEditingComplete: () { Padding(
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), padding: EdgeInsets.only(left: 15.w, right: 5.w),
child: Image.asset( child: Image.asset(
"assets/image/icon_search.webp", "assets/image/icon_search.webp",
width: 14.h, width: 14.h,
height: 14.h, height: 14.h,
color: Color(0xFFB3B3B3), color: Color(0xFF353535),
), ),
), ),
prefixIconConstraints: BoxConstraints(), Text(
border: InputBorder.none, "搜索",
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, "6": 0,
}; };
int state = 0; int state = 0;
final TextEditingController imEditingController = TextEditingController(); List<String> userIds = [];
Map<String, Message> lastMessageMap = {};
Map<String, int> unreadCountMap = {};
Map<String, ImUser> contactMap = {};
@override @override
void onMessage(txt) { void onMessage(txt) {
@ -85,11 +88,6 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
queryMsgStats(); queryMsgStats();
} }
List<String> userIds = [];
Map<String, Message> lastMessageMap = {};
Map<String, int> unreadCountMap = {};
Map<String, ImUser> contactMap = {};
loadMessageList() async { loadMessageList() async {
SharedPreferences shared = await SharedPreferences.getInstance(); SharedPreferences shared = await SharedPreferences.getInstance();
String userId = shared.getString("userId"); String userId = shared.getString("userId");
@ -122,7 +120,6 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
.where((element) => element != userId) .where((element) => element != userId)
.toList(); .toList();
List<ImUser> contacts = (await hxDatabase.queryImUser(userIds)) ?? []; List<ImUser> contacts = (await hxDatabase.queryImUser(userIds)) ?? [];
unreadCountMap = await hxDatabase.messageUnreadCount(userIds, userId); unreadCountMap = await hxDatabase.messageUnreadCount(userIds, userId);
lastMessageMap = messages.lGroupBy((p0) => p0.toId != userId ? p0.toId : p0.fromId).mGroupItem(key: (p1) => num.parse(p1.time)); 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(), chatList(),
// buildMessage(),fgg // buildMessage(),fgg
], ],
@ -356,39 +353,22 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
} }
/// ///
Widget imSearchItem() { Widget imPageSearch() {
return Container( return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap:(){
Navigator.of(context).pushNamed('/router/im_search');
},
child: Container(
margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0), margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0),
padding: EdgeInsets.symmetric(vertical: 13.h), padding: EdgeInsets.symmetric(vertical: 13.h),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFFFFFFFF), color: Color(0xFFFDFCFC),
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
), ),
], child: Row(
), children: [
child: TextField( Padding(
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(
padding: EdgeInsets.only(left: 15.w, right: 5.w), padding: EdgeInsets.only(left: 15.w, right: 5.w),
child: Image.asset( child: Image.asset(
"assets/image/icon_search.webp", "assets/image/icon_search.webp",
@ -397,9 +377,16 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
color: Color(0xFF353535), color: Color(0xFF353535),
), ),
), ),
prefixIconConstraints: BoxConstraints(), Text(
border: InputBorder.none, "搜索",
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_friend_group.dart';
import 'im/chat_setting.dart'; import 'im/chat_setting.dart';
import 'im/contact_share.dart'; import 'im/contact_share.dart';
import 'im/im_search.dart';
import 'login/login_store_select.dart'; import 'login/login_store_select.dart';
import 'login/new_login_page.dart'; import 'login/new_login_page.dart';
import 'login/phone_address_page.dart'; import 'login/phone_address_page.dart';
@ -625,5 +626,7 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
EditInvoicesInfo(arguments:arguments), EditInvoicesInfo(arguments:arguments),
'/router/invoices_detail_page': (context, {arguments}) => '/router/invoices_detail_page': (context, {arguments}) =>
InvoicesDetailPage(arguments: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:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../retrofit/data/im_user.dart';
import '../view_widget/my_tab.dart'; import '../view_widget/my_tab.dart';
class PersonalPage extends StatefulWidget { class PersonalPage extends StatefulWidget {
@ -862,7 +863,12 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver,Sing
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
Navigator.of(context) 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( child: Container(
padding: padding:
@ -1294,7 +1300,10 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver,Sing
onTap: () { onTap: () {
Navigator.of(context) Navigator.of(context)
.pushNamed('/router/chat_details_page', arguments: { .pushNamed('/router/chat_details_page', arguments: {
"toId": memberInfor.id, "toUser": ImUser(
avatar: memberInfor?.headimg,
mid: memberInfor?.id,
nickname: memberInfor?.nickname)
},); },);
}, },

Loading…
Cancel
Save