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)
? "0"
: widget.article.author,
"inletType":0
});
widget.exitFull();
}

4
lib/im/SocketClient.dart

@ -19,7 +19,8 @@ class SocketClient {
connect() async {
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");
_socket = value;
_socket.listen((data) {
@ -38,6 +39,7 @@ class SocketClient {
}, onError: (Object error, StackTrace stackTrace) {
debugPrint("socket-listen-error: $error, stackTrace: $stackTrace");
reconnect();
}, onDone: () {
debugPrint("socket-listen-down: down");
});

133
lib/im/chat_details_page.dart

@ -97,19 +97,20 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
}
Future refresh() async {
List<Message> messagePage = await hxDatabase.queryUList(_toUser.mid, page: page + 1, pageSize: 10);
if (messagePage.isEmpty) {
refreshController.loadNoData();
return;
} else {
refreshController.loadComplete();
}
List<Message> messagePage =
await hxDatabase.queryUList(_toUser.mid, page: page + 1, pageSize: 10);
page += 1;
if (page == 1) {
messages = messagePage;
} else {
messages.addAll(messagePage);
}
if (messagePage.isEmpty) {
refreshController.loadNoData();
return;
} else {
refreshController.loadComplete();
}
return Future.value();
}
@ -155,7 +156,8 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
void jumpToBottom() {
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,
action: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
setState(() {
Navigator.of(context).pushNamed('/router/chat_setting',arguments: {"userId": _toUser.mid});
copyIndex = 0;
onTap: () async {
await Navigator.of(context).pushNamed('/router/chat_setting',
arguments: {"userId": _toUser.mid});
page = 0;
refresh().then((value) {
refreshState();
});
// setState(() {
// copyIndex = 0;
// });
},
child: Container(
alignment: Alignment.center,
@ -355,9 +362,10 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
footer: CustomFooter(
loadStyle: LoadStyle.ShowWhenLoading,
builder: (BuildContext context, LoadStatus mode) {
return (messages.length == 0)
? Container()
: MyFooter(mode);
// return (messages.length == 0)
// ? Container()
// : MyFooter(mode);
return SizedBox();
},
),
controller: refreshController,
@ -367,10 +375,9 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
});
},
child: SingleChildScrollView(
physics: BouncingScrollPhysics(),
controller: scrollController,
child: chatDetailsList()
),
physics: BouncingScrollPhysics(),
controller: scrollController,
child: chatDetailsList()),
),
flex: 1,
),
@ -378,8 +385,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
],
),
),
)
);
));
}
///
@ -397,18 +403,19 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
onTap: () {
setState(() {
copyIndex = 0;
FocusScope.of(context).requestFocus(FocusNode());
});
},
child: chatDetailsItem(messages[position]),
child: chatDetailsItem(position),
);
},
),
);
}
Widget chatDetailsItem(Message message) {
bool isSelf = message.fromId == selfUserId;
bool isText = message.msgType == 1;
Widget chatDetailsItem(position) {
bool isSelf = messages[position].fromId == selfUserId;
bool isText = messages[position].msgType == 1;
return Container(
padding: EdgeInsets.only(
top: 32.h,
@ -416,8 +423,16 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
child: Column(
children: [
Text(
AppUtils.timeFormatter(
DateTime.fromMillisecondsSinceEpoch(int.parse(message.time))),
// 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)))
,
textAlign: TextAlign.center,
style: TextStyle(
color: Color(0xFFA29E9E),
@ -537,15 +552,24 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
padding: EdgeInsets.only(left: 17.w, right: 39.w),
child: Row(
children: [
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",
),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed('/router/personal_page',
arguments: {
"memberId": _toUser?.mid ?? "",
"inletType": 1
});
},
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(
width: 12.w,
),
@ -576,7 +600,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
});
},
child: Text(
tex = message.content,
tex = messages[position].content,
textAlign: TextAlign.left,
style: TextStyle(
height: 1.2.h,
@ -686,7 +710,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
padding: EdgeInsets.only(left: 36.w, right: 16.w),
child: Row(
children: [
if (message.state == 3)
if (messages[position].state == 3)
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
@ -705,7 +729,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
),
),
),
if (message.state == 3)
if (messages[position].state == 3)
SizedBox(
width: 12.w,
),
@ -736,7 +760,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
});
},
child: Text(
tex = message.content,
tex = messages[position].content,
textAlign: TextAlign.left,
style: TextStyle(
height: 1.2.h,
@ -752,20 +776,21 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
SizedBox(
width: 12.w,
),
MImage(
userInfo?.headimg ?? "",
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,
// width: 44,
// ),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () {
Navigator.of(context).pushNamed('/router/personal_page',
arguments: {"memberId": "0", "inletType": 1});
},
child: MImage(
userInfo?.headimg ?? "",
isCircle: true,
height: 44.h,
width: 44.h,
fit: BoxFit.cover,
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 '../../utils/font_weight.dart';
import '../main.dart';
import '../retrofit/data/im_user.dart';
class ChatSetting extends StatefulWidget {
final Map<String, dynamic> arguments;
@ -23,13 +24,20 @@ class ChatSetting extends StatefulWidget {
}
}
class _ChatSetting extends State<ChatSetting>{
ApiService apiService;
bool topSetting = false;
class _ChatSetting extends State<ChatSetting> {
ImUser imUser;
@override
void initState() {
super.initState();
initData();
}
void initData() async {
imUser = await hxDatabase.queryImUserById(widget.arguments["userId"]);
setState(() {
});
}
@override
@ -37,7 +45,7 @@ class _ChatSetting extends State<ChatSetting>{
return Scaffold(
backgroundColor: Color(0xFFF9FAF7),
appBar: MyAppBar(
title:"聊天设置",
title: "聊天设置",
titleColor: Colors.black,
titleSize: 18.sp,
background: Colors.white,
@ -50,7 +58,7 @@ class _ChatSetting extends State<ChatSetting>{
Container(
color: Colors.white,
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(
children: [
Row(
@ -61,52 +69,60 @@ class _ChatSetting extends State<ChatSetting>{
"置顶聊天",
style: TextStyle(
color: Color(0xFF353535),
fontSize:15.sp,
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
),
),
CupertinoSwitch(
value: (topSetting),
value: ((imUser?.isTop ?? 0) == 1),
activeColor: Color(0xFF32A060),
onChanged: (bool value) {
setState((){
topSetting = !topSetting;
});
onChanged: (bool value) async {
if (imUser == null) return;
imUser.isTop = value ? 1 : 0;
await hxDatabase
.insertOrUpdateImUser(imUser.toJson());
setState(() {});
},
),
],
),
SizedBox(height:31.h,),
GestureDetector(child:
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"清空聊天记录",
style: TextStyle(
color: Color(0xFF353535),
fontSize:15.sp,
fontWeight: MyFontWeight.semi_bold,
SizedBox(
height: 31.h,
),
GestureDetector(
behavior: HitTestBehavior.opaque,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"清空聊天记录",
style: TextStyle(
color: Color(0xFF353535),
fontSize: 15.sp,
fontWeight: MyFontWeight.semi_bold,
),
),
),
Image.asset(
"assets/image/icon_right_z.webp",
height:16,
width:16,
color: Colors.black,
),
],
),onTap: ()async{
// await hxDatabase.deleteByUser(widget.arguments["userId"]??"");
// SmartDialog.showToast("删除成功",
// alignment: Alignment.center);
},)
Image.asset(
"assets/image/icon_right_z.webp",
height: 16,
width: 16,
color: Colors.black,
),
],
),
onTap: () async {
await hxDatabase
.deleteByUser(widget.arguments["userId"] ?? "");
SmartDialog.showToast("删除成功",
alignment: Alignment.center);
},
)
],
),
),
Expanded(child:
Container(
Expanded(
child: Container(
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`))');
}, onConfigure: (database) async {
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 {
await runMigrations(database, startVersion, endVersion, _migrations);
}, 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:shared_preferences/shared_preferences.dart';
import '../generated/l10n.dart';
import '../retrofit/data/base_data.dart';
import '../retrofit/data/im_user.dart';
import '../retrofit/retrofit_api.dart';
@ -30,10 +31,14 @@ class _ImSearch extends State<ImSearch> {
int searchState = 0;
int textType = 0;
int searchUserIndex = 0;
String selfUserId = "";
@override
void initState() {
super.initState();
SharedPreferences.getInstance().then((value) {
selfUserId = value.getString("userId");
});
}
///
@ -81,8 +86,7 @@ class _ImSearch extends State<ImSearch> {
backgroundColor: Color(0xFFFFFFFF),
resizeToAvoidBottomInset: false,
appBar: MyAppBar(
title: "",
leading: true,
title: "搜索",
leadingColor: Colors.black,
background: Color(0xFFFFFFFF),
),
@ -90,7 +94,33 @@ class _ImSearch extends State<ImSearch> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
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 ?
Center(
child: Text(
@ -130,8 +160,10 @@ class _ImSearch extends State<ImSearch> {
searchUserIndex = position;
});
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]),
);

54
lib/im/im_view/im_page.dart

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

2
lib/main.dart

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

1
lib/mine/fans_page.dart

@ -154,6 +154,7 @@ class _FansPage extends State<FansPage>
Navigator.of(context)
.pushNamed('/router/personal_page', arguments: {
"memberId": list.mid ?? "",
"inletType":0
});},
child: Padding(
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)
.pushNamed('/router/personal_page', arguments: {
"memberId": list.mid ?? "",
"inletType":0
});},
child: Padding(
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)
.pushNamed('/router/personal_page', arguments: {
"memberId": "0",
"inletType":0
});
setState(() {});
}

20
lib/mine/personal_page.dart

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

12
lib/retrofit/data/im_user.dart

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

1
lib/union/union_list.dart

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

55
lib/utils/flutter_utils.dart

@ -293,17 +293,64 @@ class AppUtils {
static String timeFormatter(DateTime time) {
final now = DateTime.now();
final diff = now.difference(time).inHours;
final diff2 = now.difference(time).inDays;
if (diff < 24) {
return '刚刚'; // 24
return DateFormat('HH:mm').format(time); // 24
} else if (diff < 48) {
return '昨天'; //
} else if (diff < 72) {
return '前天'; //
return '昨天 ${DateFormat('HH:mm').format(time)}'; // +
} else if (diff < 72 && diff2<7) {
return DateFormat('${DateFormat('EEEE').format(time)}').format(time);// 72
} else if (time.year == now.year) {
return DateFormat('MM月dd日').format(time); //
} else {
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)
.pushNamed('/router/personal_page', arguments: {
"memberId": memberList.createUser,
"inletType":0
});
});
},

Loading…
Cancel
Save