Browse Source

置顶处理;

清空记录处理;
时间显示处理;
搜索页面处理;
wr_202303
wurong 4 months ago
parent
commit
03cb5df501
  1. 1
      lib/community/community_view/community_dynamic.dart
  2. 4
      lib/im/SocketClient.dart
  3. 133
      lib/im/chat_details_page.dart
  4. 92
      lib/im/chat_setting.dart
  5. 4
      lib/im/database/hx_database.dart
  6. 40
      lib/im/im_search.dart
  7. 54
      lib/im/im_view/im_page.dart
  8. 2
      lib/main.dart
  9. 1
      lib/mine/fans_page.dart
  10. 1
      lib/mine/follow_page.dart
  11. 1
      lib/mine/mine_page.dart
  12. 20
      lib/mine/personal_page.dart
  13. 12
      lib/retrofit/data/im_user.dart
  14. 1
      lib/union/union_list.dart
  15. 55
      lib/utils/flutter_utils.dart
  16. 1
      lib/web/web_view/comment_list.dart

1
lib/community/community_view/community_dynamic.dart

@ -174,6 +174,7 @@ class _CommunityDynamic extends State<CommunityDynamic> {
"memberId": (widget.article.author == widget.userId) "memberId": (widget.article.author == widget.userId)
? "0" ? "0"
: widget.article.author, : widget.article.author,
"inletType":0
}); });
widget.exitFull(); widget.exitFull();
} }

4
lib/im/SocketClient.dart

@ -19,7 +19,8 @@ class SocketClient {
connect() async { connect() async {
shared = await SharedPreferences.getInstance(); shared = await SharedPreferences.getInstance();
await Socket.connect('192.168.10.129', 9090).then((value) { //47.93.216.24:9090 线 192.168.10.129:9090
await Socket.connect('47.93.216.24', 9090).then((value) {
debugPrint("socket-connect"); debugPrint("socket-connect");
_socket = value; _socket = value;
_socket.listen((data) { _socket.listen((data) {
@ -38,6 +39,7 @@ class SocketClient {
}, onError: (Object error, StackTrace stackTrace) { }, onError: (Object error, StackTrace stackTrace) {
debugPrint("socket-listen-error: $error, stackTrace: $stackTrace"); debugPrint("socket-listen-error: $error, stackTrace: $stackTrace");
reconnect();
}, onDone: () { }, onDone: () {
debugPrint("socket-listen-down: down"); debugPrint("socket-listen-down: down");
}); });

133
lib/im/chat_details_page.dart

@ -97,19 +97,20 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
} }
Future refresh() async { Future refresh() async {
List<Message> messagePage = await hxDatabase.queryUList(_toUser.mid, page: page + 1, pageSize: 10); List<Message> messagePage =
if (messagePage.isEmpty) { await hxDatabase.queryUList(_toUser.mid, page: page + 1, pageSize: 10);
refreshController.loadNoData();
return;
} else {
refreshController.loadComplete();
}
page += 1; page += 1;
if (page == 1) { if (page == 1) {
messages = messagePage; messages = messagePage;
} else { } else {
messages.addAll(messagePage); messages.addAll(messagePage);
} }
if (messagePage.isEmpty) {
refreshController.loadNoData();
return;
} else {
refreshController.loadComplete();
}
return Future.value(); return Future.value();
} }
@ -155,7 +156,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
void jumpToBottom() { void jumpToBottom() {
Future.delayed(const Duration(milliseconds: 100), () { Future.delayed(const Duration(milliseconds: 100), () {
scrollController.position.jumpTo(scrollController.position.maxScrollExtent); scrollController.position
.jumpTo(scrollController.position.maxScrollExtent);
}); });
} }
@ -326,11 +328,16 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
leadingColor: Colors.black, leadingColor: Colors.black,
action: GestureDetector( action: GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () async {
setState(() { await Navigator.of(context).pushNamed('/router/chat_setting',
Navigator.of(context).pushNamed('/router/chat_setting',arguments: {"userId": _toUser.mid}); arguments: {"userId": _toUser.mid});
copyIndex = 0; page = 0;
refresh().then((value) {
refreshState();
}); });
// setState(() {
// copyIndex = 0;
// });
}, },
child: Container( child: Container(
alignment: Alignment.center, alignment: Alignment.center,
@ -355,9 +362,10 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
footer: CustomFooter( footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading, loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus mode) { builder: (BuildContext context, LoadStatus mode) {
return (messages.length == 0) // return (messages.length == 0)
? Container() // ? Container()
: MyFooter(mode); // : MyFooter(mode);
return SizedBox();
}, },
), ),
controller: refreshController, controller: refreshController,
@ -367,10 +375,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}); });
}, },
child: SingleChildScrollView( child: SingleChildScrollView(
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
controller: scrollController, controller: scrollController,
child: chatDetailsList() child: chatDetailsList()),
),
), ),
flex: 1, flex: 1,
), ),
@ -378,8 +385,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
], ],
), ),
), ),
) ));
);
} }
/// ///
@ -397,18 +403,19 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
onTap: () { onTap: () {
setState(() { setState(() {
copyIndex = 0; copyIndex = 0;
FocusScope.of(context).requestFocus(FocusNode());
}); });
}, },
child: chatDetailsItem(messages[position]), child: chatDetailsItem(position),
); );
}, },
), ),
); );
} }
Widget chatDetailsItem(Message message) { Widget chatDetailsItem(position) {
bool isSelf = message.fromId == selfUserId; bool isSelf = messages[position].fromId == selfUserId;
bool isText = message.msgType == 1; bool isText = messages[position].msgType == 1;
return Container( return Container(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: 32.h, top: 32.h,
@ -416,8 +423,16 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
child: Column( child: Column(
children: [ children: [
Text( Text(
AppUtils.timeFormatter( // position == messages.length-1
DateTime.fromMillisecondsSinceEpoch(int.parse(message.time))), // ?
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)))
,
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
color: Color(0xFFA29E9E), color: Color(0xFFA29E9E),
@ -537,15 +552,24 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
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( GestureDetector(
_toUser.avatar, behavior: HitTestBehavior.opaque,
isCircle: true, onTap: () {
height: 44.h, Navigator.of(context).pushNamed('/router/personal_page',
width: 44.h, arguments: {
fit: BoxFit.cover, "memberId": _toUser?.mid ?? "",
errorSrc: "assets/image/default_1.webp", "inletType": 1
fadeSrc: "assets/image/default_1.webp", });
), },
child: 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( SizedBox(
width: 12.w, width: 12.w,
), ),
@ -576,7 +600,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}); });
}, },
child: Text( child: Text(
tex = message.content, tex = messages[position].content,
textAlign: TextAlign.left, textAlign: TextAlign.left,
style: TextStyle( style: TextStyle(
height: 1.2.h, height: 1.2.h,
@ -686,7 +710,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
padding: EdgeInsets.only(left: 36.w, right: 16.w), padding: EdgeInsets.only(left: 36.w, right: 16.w),
child: Row( child: Row(
children: [ children: [
if (message.state == 3) if (messages[position].state == 3)
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100), borderRadius: BorderRadius.circular(100),
@ -705,7 +729,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
), ),
), ),
), ),
if (message.state == 3) if (messages[position].state == 3)
SizedBox( SizedBox(
width: 12.w, width: 12.w,
), ),
@ -736,7 +760,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}); });
}, },
child: Text( child: Text(
tex = message.content, tex = messages[position].content,
textAlign: TextAlign.left, textAlign: TextAlign.left,
style: TextStyle( style: TextStyle(
height: 1.2.h, height: 1.2.h,
@ -752,20 +776,21 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
SizedBox( SizedBox(
width: 12.w, width: 12.w,
), ),
MImage( GestureDetector(
userInfo?.headimg ?? "", behavior: HitTestBehavior.opaque,
isCircle: true, onTap: () {
height: 44.h, Navigator.of(context).pushNamed('/router/personal_page',
width: 44.h, arguments: {"memberId": "0", "inletType": 1});
fit: BoxFit.cover, },
errorSrc: "assets/image/default_1.webp", child: MImage(
fadeSrc: "assets/image/default_1.webp", userInfo?.headimg ?? "",
), isCircle: true,
// Image.asset( height: 44.h,
// "assets/image/fuka_zj.webp", width: 44.h,
// height: 44, fit: BoxFit.cover,
// width: 44, errorSrc: "assets/image/default_1.webp",
// ), fadeSrc: "assets/image/default_1.webp",
)),
], ],
), ),
), ),

92
lib/im/chat_setting.dart

@ -11,6 +11,7 @@ import 'package:flutter/cupertino.dart';
import '../../generated/l10n.dart'; import '../../generated/l10n.dart';
import '../../utils/font_weight.dart'; import '../../utils/font_weight.dart';
import '../main.dart'; import '../main.dart';
import '../retrofit/data/im_user.dart';
class ChatSetting extends StatefulWidget { class ChatSetting extends StatefulWidget {
final Map<String, dynamic> arguments; final Map<String, dynamic> arguments;
@ -23,13 +24,20 @@ class ChatSetting extends StatefulWidget {
} }
} }
class _ChatSetting extends State<ChatSetting>{ class _ChatSetting extends State<ChatSetting> {
ApiService apiService; ImUser imUser;
bool topSetting = false;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
initData();
}
void initData() async {
imUser = await hxDatabase.queryImUserById(widget.arguments["userId"]);
setState(() {
});
} }
@override @override
@ -37,7 +45,7 @@ class _ChatSetting extends State<ChatSetting>{
return Scaffold( return Scaffold(
backgroundColor: Color(0xFFF9FAF7), backgroundColor: Color(0xFFF9FAF7),
appBar: MyAppBar( appBar: MyAppBar(
title:"聊天设置", title: "聊天设置",
titleColor: Colors.black, titleColor: Colors.black,
titleSize: 18.sp, titleSize: 18.sp,
background: Colors.white, background: Colors.white,
@ -50,7 +58,7 @@ class _ChatSetting extends State<ChatSetting>{
Container( Container(
color: Colors.white, color: Colors.white,
margin: EdgeInsets.symmetric(vertical: 14.h), margin: EdgeInsets.symmetric(vertical: 14.h),
padding: EdgeInsets.symmetric(horizontal: 16.w,vertical: 14.h), padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 14.h),
child: Column( child: Column(
children: [ children: [
Row( Row(
@ -61,52 +69,60 @@ class _ChatSetting extends State<ChatSetting>{
"置顶聊天", "置顶聊天",
style: TextStyle( style: TextStyle(
color: Color(0xFF353535), color: Color(0xFF353535),
fontSize:15.sp, fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold, fontWeight: MyFontWeight.semi_bold,
), ),
), ),
CupertinoSwitch( CupertinoSwitch(
value: (topSetting), value: ((imUser?.isTop ?? 0) == 1),
activeColor: Color(0xFF32A060), activeColor: Color(0xFF32A060),
onChanged: (bool value) { onChanged: (bool value) async {
setState((){ if (imUser == null) return;
topSetting = !topSetting; imUser.isTop = value ? 1 : 0;
}); await hxDatabase
.insertOrUpdateImUser(imUser.toJson());
setState(() {});
}, },
), ),
], ],
), ),
SizedBox(height:31.h,), SizedBox(
GestureDetector(child: height: 31.h,
Row( ),
mainAxisAlignment: MainAxisAlignment.spaceBetween, GestureDetector(
crossAxisAlignment: CrossAxisAlignment.end, behavior: HitTestBehavior.opaque,
children: [ child: Row(
Text( mainAxisAlignment: MainAxisAlignment.spaceBetween,
"清空聊天记录", crossAxisAlignment: CrossAxisAlignment.end,
style: TextStyle( children: [
color: Color(0xFF353535), Text(
fontSize:15.sp, "清空聊天记录",
fontWeight: MyFontWeight.semi_bold, style: TextStyle(
color: Color(0xFF353535),
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
),
), ),
), Image.asset(
Image.asset( "assets/image/icon_right_z.webp",
"assets/image/icon_right_z.webp", height: 16,
height:16, width: 16,
width:16, color: Colors.black,
color: Colors.black, ),
), ],
], ),
),onTap: ()async{ onTap: () async {
// await hxDatabase.deleteByUser(widget.arguments["userId"]??""); await hxDatabase
// SmartDialog.showToast("删除成功", .deleteByUser(widget.arguments["userId"] ?? "");
// alignment: Alignment.center); SmartDialog.showToast("删除成功",
},) alignment: Alignment.center);
},
)
], ],
), ),
), ),
Expanded(child: Expanded(
Container( child: Container(
color: Colors.white, color: Colors.white,
)) ))
], ],

4
lib/im/database/hx_database.dart

@ -27,6 +27,10 @@ class HxDatabase {
'CREATE TABLE IF NOT EXISTS `ImUser` (`id` INTEGER, `mid` VARCHAR(20), `nickname` VARCHAR(20), `avatar` VARCHAR(200), `phone` VARCHAR(200), `isDelete` INTEGER, PRIMARY KEY (`id`))'); 'CREATE TABLE IF NOT EXISTS `ImUser` (`id` INTEGER, `mid` VARCHAR(20), `nickname` VARCHAR(20), `avatar` VARCHAR(200), `phone` VARCHAR(200), `isDelete` INTEGER, PRIMARY KEY (`id`))');
}, onConfigure: (database) async { }, onConfigure: (database) async {
await database.execute('PRAGMA foreign_keys = ON'); await database.execute('PRAGMA foreign_keys = ON');
try {
await database.execute(
'ALTER TABLE ImUser ADD COLUMN isTop INTEGER DEFAULT 0');
}catch (e){}
}, onUpgrade: (database, startVersion, endVersion) async { }, onUpgrade: (database, startVersion, endVersion) async {
await runMigrations(database, startVersion, endVersion, _migrations); await runMigrations(database, startVersion, endVersion, _migrations);
}, onOpen: (Database db) { }, onOpen: (Database db) {

40
lib/im/im_search.dart

@ -7,6 +7,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import '../generated/l10n.dart';
import '../retrofit/data/base_data.dart'; import '../retrofit/data/base_data.dart';
import '../retrofit/data/im_user.dart'; import '../retrofit/data/im_user.dart';
import '../retrofit/retrofit_api.dart'; import '../retrofit/retrofit_api.dart';
@ -30,10 +31,14 @@ class _ImSearch extends State<ImSearch> {
int searchState = 0; int searchState = 0;
int textType = 0; int textType = 0;
int searchUserIndex = 0; int searchUserIndex = 0;
String selfUserId = "";
@override @override
void initState() { void initState() {
super.initState(); super.initState();
SharedPreferences.getInstance().then((value) {
selfUserId = value.getString("userId");
});
} }
/// ///
@ -81,8 +86,7 @@ class _ImSearch extends State<ImSearch> {
backgroundColor: Color(0xFFFFFFFF), backgroundColor: Color(0xFFFFFFFF),
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: MyAppBar( appBar: MyAppBar(
title: "", title: "搜索",
leading: true,
leadingColor: Colors.black, leadingColor: Colors.black,
background: Color(0xFFFFFFFF), background: Color(0xFFFFFFFF),
), ),
@ -90,7 +94,33 @@ class _ImSearch extends State<ImSearch> {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
imSearch(), Row(
crossAxisAlignment:CrossAxisAlignment.center,
mainAxisAlignment:MainAxisAlignment.center,
children: [
Expanded(child: imSearch()),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap:(){
Navigator.of(context).pop();
},
child: Container(
margin: EdgeInsets.only(top:8.h,bottom:29.h),
alignment: Alignment.center,
padding: EdgeInsets.only(right: 16.w),
child: Text(
S.of(context).quxiao,
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFFA29E9E),
fontSize:14.sp,
fontWeight: MyFontWeight.medium,
),
)
),
)
],
),
searchState == 2 ? searchState == 2 ?
Center( Center(
child: Text( child: Text(
@ -130,8 +160,10 @@ class _ImSearch extends State<ImSearch> {
searchUserIndex = position; searchUserIndex = position;
}); });
Navigator.of(context).pushNamed('/router/personal_page', arguments: { Navigator.of(context).pushNamed('/router/personal_page', arguments: {
"memberId":searchUser[searchUserIndex].mid ?? "", "memberId":(searchUser[searchUserIndex].mid ?? "") == selfUserId ? "0":searchUser[searchUserIndex].mid,
"inletType":0
}); });
FocusScope.of(context).requestFocus(FocusNode());
}, },
child: imSearchItem(searchUser[position]), child: imSearchItem(searchUser[position]),
); );

54
lib/im/im_view/im_page.dart

@ -1,5 +1,6 @@
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:huixiang/constant.dart'; import 'package:huixiang/constant.dart';
import 'package:huixiang/generated/l10n.dart'; import 'package:huixiang/generated/l10n.dart';
@ -46,6 +47,8 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
Map<String, Message> lastMessageMap = {}; Map<String, Message> lastMessageMap = {};
Map<String, int> unreadCountMap = {}; Map<String, int> unreadCountMap = {};
Map<String, ImUser> contactMap = {}; Map<String, ImUser> contactMap = {};
int slIndex = 0;
int insertIndex = 0;
@override @override
void onMessage(txt) { void onMessage(txt) {
@ -80,7 +83,7 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
if (userIds.contains(message.fromId)) { if (userIds.contains(message.fromId)) {
userIds.remove(message.fromId); userIds.remove(message.fromId);
} }
userIds.insert(0, message.fromId); userIds.insert(insertIndex, message.fromId);
lastMessageMap[message.fromId] = message; lastMessageMap[message.fromId] = message;
@ -161,6 +164,15 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
} }
} }
contactMap = contacts.lGroupBy((p0) => p0.mid).mGroupItem(); contactMap = contacts.lGroupBy((p0) => p0.mid).mGroupItem();
List<String> topUserIds = [],notTopUserIds = [];
contactMap.forEach((key, value) {
if(value.isTop == 1)
topUserIds.add(key);
else
notTopUserIds.add(key);
});
insertIndex = topUserIds.length;
this.userIds = topUserIds..addAll(notTopUserIds);
} }
/// update one conversation last message ,and update conversation sort /// update one conversation last message ,and update conversation sort
@ -385,7 +397,9 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap:(){ onTap:(){
Navigator.of(context).pushNamed('/router/im_search'); Navigator.of(context).pushNamed('/router/im_search').then((value) {
_refresh();
});
}, },
child: Container( child: Container(
margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0), margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0),
@ -429,24 +443,24 @@ class _IMPage extends State<IMPage> implements OnChatMessage {
physics: NeverScrollableScrollPhysics(), physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return GestureDetector( return GestureDetector(
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
if (userIds[position] == sharedPreferences.getString("userId")) { if (userIds[position] == sharedPreferences.getString("userId")) {
SmartDialog.showToast("不能跟自己聊天", alignment: Alignment.center); SmartDialog.showToast("不能跟自己聊天", alignment: Alignment.center);
return; return;
} }
Navigator.of(context).pushNamed( Navigator.of(context).pushNamed(
'/router/chat_details_page', '/router/chat_details_page',
arguments: { arguments: {
"toUser": contactMap[userIds[position]], "toUser": contactMap[userIds[position]],
}, },
).then((value) { ).then((value) {
unreadCountMap[userIds[position]] = 0; unreadCountMap[userIds[position]] = 0;
updateLastMessage(userIds[position]); updateLastMessage(userIds[position]);
}); _refresh();
}, });
child: chatItem(userIds[position]), },
); child: chatItem(userIds[position]));
}, },
), ),
); );

2
lib/main.dart

@ -517,7 +517,7 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
'/router/chat_details_page': (context, {arguments}) => '/router/chat_details_page': (context, {arguments}) =>
ChatDetailsPage(arguments: arguments), ChatDetailsPage(arguments: arguments),
'/router/chat_setting': (context, {arguments}) => '/router/chat_setting': (context, {arguments}) =>
ChatSetting(), ChatSetting(arguments:arguments),
'/router/chat_friend_group': (context, {arguments}) => '/router/chat_friend_group': (context, {arguments}) =>
ChatFriendGroup(), ChatFriendGroup(),
'/router/add_friend': (context, {arguments}) => '/router/add_friend': (context, {arguments}) =>

1
lib/mine/fans_page.dart

@ -154,6 +154,7 @@ class _FansPage extends State<FansPage>
Navigator.of(context) Navigator.of(context)
.pushNamed('/router/personal_page', arguments: { .pushNamed('/router/personal_page', arguments: {
"memberId": list.mid ?? "", "memberId": list.mid ?? "",
"inletType":0
});}, });},
child: Padding( child: Padding(
padding: EdgeInsets.only(right: 8.w), padding: EdgeInsets.only(right: 8.w),

1
lib/mine/follow_page.dart

@ -148,6 +148,7 @@ class _FollowPage extends State<FollowPage> with SingleTickerProviderStateMixin,
Navigator.of(context) Navigator.of(context)
.pushNamed('/router/personal_page', arguments: { .pushNamed('/router/personal_page', arguments: {
"memberId": list.mid ?? "", "memberId": list.mid ?? "",
"inletType":0
});}, });},
child: Padding( child: Padding(
padding: EdgeInsets.only(right: 8.w), padding: EdgeInsets.only(right: 8.w),

1
lib/mine/mine_page.dart

@ -65,6 +65,7 @@ class MinePageState extends State<MinePage> with AutomaticKeepAliveClientMixin {
: await Navigator.of(context) : await Navigator.of(context)
.pushNamed('/router/personal_page', arguments: { .pushNamed('/router/personal_page', arguments: {
"memberId": "0", "memberId": "0",
"inletType":0
}); });
setState(() {}); setState(() {});
} }

20
lib/mine/personal_page.dart

@ -1307,14 +1307,18 @@ class _PersonalPage extends State<PersonalPage> with WidgetsBindingObserver,Sing
SmartDialog.showToast("不能跟自己聊天", alignment: Alignment.center); SmartDialog.showToast("不能跟自己聊天", alignment: Alignment.center);
return; return;
} }
Navigator.of(context) if(widget.arguments["inletType"] == 1){
.pushNamed('/router/chat_details_page', arguments: { //inletType = 10bug
"toUser": ImUser( Navigator.of(context).pop();
avatar: memberInfor?.headimg, }else{
mid: memberInfor?.id, Navigator.of(context)
nickname: memberInfor?.nickname) .pushNamed('/router/chat_details_page', arguments: {
},); "toUser": ImUser(
avatar: memberInfor?.headimg,
mid: memberInfor?.id,
nickname: memberInfor?.nickname)
},);
}
}, },
child: Container( child: Container(
width:110.w, width:110.w,

12
lib/retrofit/data/im_user.dart

@ -10,11 +10,13 @@ class ImUser {
String mid, String mid,
String nickname, String nickname,
num isDelete, num isDelete,
num isTop,
String avatar, String avatar,
String phone, }){ String phone, }){
_mid = mid; _mid = mid;
_nickname = nickname; _nickname = nickname;
_isDelete = isDelete; _isDelete = isDelete;
_isTop = isTop;
_avatar = avatar; _avatar = avatar;
_phone = phone; _phone = phone;
} }
@ -23,36 +25,46 @@ class ImUser {
_mid = json['mid']; _mid = json['mid'];
_nickname = json['nickname']; _nickname = json['nickname'];
_isDelete = json['isDelete']; _isDelete = json['isDelete'];
_isTop = json['isTop'];
_avatar = json['avatar']; _avatar = json['avatar'];
_phone = json['phone']; _phone = json['phone'];
} }
String _mid; String _mid;
String _nickname; String _nickname;
num _isDelete; num _isDelete;
num _isTop;
String _avatar; String _avatar;
String _phone; String _phone;
ImUser copyWith({ String mid, ImUser copyWith({ String mid,
String nickname, String nickname,
num isDelete, num isDelete,
num isTop,
String avatar, String avatar,
String phone, String phone,
}) => ImUser( mid: mid ?? _mid, }) => ImUser( mid: mid ?? _mid,
nickname: nickname ?? _nickname, nickname: nickname ?? _nickname,
isDelete: isDelete ?? _isDelete, isDelete: isDelete ?? _isDelete,
isTop: isTop ?? _isTop,
avatar: avatar ?? _avatar, avatar: avatar ?? _avatar,
phone: phone ?? _phone, phone: phone ?? _phone,
); );
String get mid => _mid; String get mid => _mid;
String get nickname => _nickname; String get nickname => _nickname;
num get isDelete => _isDelete; num get isDelete => _isDelete;
num get isTop => _isTop;
String get avatar => _avatar; String get avatar => _avatar;
String get phone => _phone; String get phone => _phone;
set isTop(num value) {
_isTop = value;
}
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final map = <String, dynamic>{}; final map = <String, dynamic>{};
map['mid'] = _mid; map['mid'] = _mid;
map['nickname'] = _nickname; map['nickname'] = _nickname;
map['isDelete'] = _isDelete; map['isDelete'] = _isDelete;
map['isTop'] = _isTop;
map['avatar'] = _avatar; map['avatar'] = _avatar;
map['phone'] = _phone; map['phone'] = _phone;
return map; return map;

1
lib/union/union_list.dart

@ -129,6 +129,7 @@ class _UnionList extends State<UnionList> with AutomaticKeepAliveClientMixin {
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
{ {
//uiui仿商城模式
// if (storeList[position].storeName == "一心回乡商城") { // if (storeList[position].storeName == "一心回乡商城") {
// Navigator.of(context).pushNamed( // Navigator.of(context).pushNamed(
// '/router/shopping_mall_home', // '/router/shopping_mall_home',

55
lib/utils/flutter_utils.dart

@ -293,17 +293,64 @@ class AppUtils {
static String timeFormatter(DateTime time) { static String timeFormatter(DateTime time) {
final now = DateTime.now(); final now = DateTime.now();
final diff = now.difference(time).inHours; final diff = now.difference(time).inHours;
final diff2 = now.difference(time).inDays;
if (diff < 24) { if (diff < 24) {
return '刚刚'; // 24 return DateFormat('HH:mm').format(time); // 24
} else if (diff < 48) { } else if (diff < 48) {
return '昨天'; // return '昨天 ${DateFormat('HH:mm').format(time)}'; // +
} else if (diff < 72) { } else if (diff < 72 && diff2<7) {
return '前天'; // return DateFormat('${DateFormat('EEEE').format(time)}').format(time);// 72
} else if (time.year == now.year) { } else if (time.year == now.year) {
return DateFormat('MM月dd日').format(time); // return DateFormat('MM月dd日').format(time); //
} else { } else {
return DateFormat('yyyy年MM月dd日').format(time); // return DateFormat('yyyy年MM月dd日').format(time); //
} }
} }
///
static String milliTimeFormatter(DateTime time) {
final now = DateTime.now();
final diff = now.difference(time).inHours;
if (diff < 24) {
return DateFormat('HH:mm').format(time); // 24
} else if (diff < 48) {
return '昨天 ${DateFormat('HH:mm').format(time)}'; // +
} else if (diff < 72) {
return DateFormat('${DateFormat('EEEE').format(time)}').format(time) + " ${DateFormat('HH:mm').format(time)}";// 72+
} else if (time.year == now.year) {
return DateFormat('MM月dd日').format(time) + " ${DateFormat('HH:mm').format(time)}"; // +
} else {
return DateFormat('yyyy年MM月dd日').format(time) + " ${DateFormat('HH:mm').format(time)}"; // +
}
}
///
static String getTimeDisplay(DateTime previousTime, DateTime currentTime) {
final diffInMinutes = (currentTime.difference(previousTime)).inMinutes;
if (diffInMinutes < 5) {
// 5
return '';
} else if (currentTime.year == DateTime.now().year) {
//
if (currentTime.day == DateTime.now().day) {
//
return DateFormat('HH:mm').format(currentTime);
} else if (currentTime.day == DateTime.now().day - 1) {
//
return '昨天 ${DateFormat('HH:mm').format(currentTime)}';
} else if ((currentTime.day - DateTime.now().day).abs() < 7) {
//
return '${DateFormat('EEEE').format(currentTime)} ${DateFormat('HH:mm').format(currentTime)}';
} else {
//
return DateFormat('MM/dd').format(currentTime);
}
} else {
//
return DateFormat('yyyy/MM/dd').format(currentTime);
}
}
} }

1
lib/web/web_view/comment_list.dart

@ -259,6 +259,7 @@ class CommentListState extends State<CommentList> {
Navigator.of(context) Navigator.of(context)
.pushNamed('/router/personal_page', arguments: { .pushNamed('/router/personal_page', arguments: {
"memberId": memberList.createUser, "memberId": memberList.createUser,
"inletType":0
}); });
}); });
}, },

Loading…
Cancel
Save