wurong
4 months ago
10 changed files with 404 additions and 183 deletions
@ -1,33 +0,0 @@
|
||||
class Contact { |
||||
int id; |
||||
|
||||
String userId; |
||||
|
||||
String nickName; |
||||
|
||||
String imageUrl; |
||||
|
||||
int state; |
||||
|
||||
int isDelete; |
||||
|
||||
Contact(this.id, this.userId, this.nickName, this.imageUrl, this.state, |
||||
this.isDelete); |
||||
|
||||
factory Contact.fromJson(Map<String, dynamic> json) => Contact( |
||||
json["id"], |
||||
json["userId"], |
||||
json["nickName"], |
||||
json["imageUrl"], |
||||
json["state"], |
||||
json["isDelete"]); |
||||
|
||||
Map<String, dynamic> toJson() => <String, dynamic>{ |
||||
"id": id, |
||||
"fromId": userId, |
||||
"toId": nickName, |
||||
"replyId": imageUrl, |
||||
"state": state, |
||||
"isDelete": isDelete == null ? 0 : isDelete |
||||
}; |
||||
} |
@ -0,0 +1,20 @@
|
||||
import 'package:intl/intl.dart'; |
||||
|
||||
class TimeFormatter { |
||||
static String formatTime(DateTime time) { |
||||
final now = DateTime.now(); |
||||
final diff = now.difference(time).inHours; |
||||
|
||||
if (diff < 24) { |
||||
return '刚刚'; // 24小时内显示为“刚刚” |
||||
} else if (diff < 48) { |
||||
return '昨天'; // 昨天 |
||||
} else if (diff < 72) { |
||||
return '前天'; // 前天 |
||||
} else if (time.year == now.year) { |
||||
return DateFormat('MM月dd日').format(time); // 今年内的日期 |
||||
} else { |
||||
return DateFormat('yyyy年MM月dd日').format(time); // 其他年份的日期 |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,61 @@
|
||||
/// mid : "1379254113602109440" |
||||
/// nickname : "哈哈" |
||||
/// avatar : "https://pos.upload.lotus-wallet.com/admin/2022/11/d501d2cd-ffc0-49f2-967c-2e463462f500.jpeg" |
||||
/// phone : "13052919193" |
||||
/// isFollow : null |
||||
/// createTime : null |
||||
|
||||
class ImUserList { |
||||
ImUserList({ |
||||
String mid, |
||||
String nickname, |
||||
num isDelete, |
||||
String avatar, |
||||
String phone, }){ |
||||
_mid = mid; |
||||
_nickname = nickname; |
||||
_isDelete = isDelete; |
||||
_avatar = avatar; |
||||
_phone = phone; |
||||
} |
||||
|
||||
ImUserList.fromJson(dynamic json) { |
||||
_mid = json['mid']; |
||||
_nickname = json['nickname']; |
||||
_isDelete = json['isDelete']; |
||||
_avatar = json['avatar']; |
||||
_phone = json['phone']; |
||||
} |
||||
String _mid; |
||||
String _nickname; |
||||
num _isDelete; |
||||
String _avatar; |
||||
String _phone; |
||||
ImUserList copyWith({ String mid, |
||||
String nickname, |
||||
num isDelete, |
||||
String avatar, |
||||
String phone, |
||||
}) => ImUserList( mid: mid ?? _mid, |
||||
nickname: nickname ?? _nickname, |
||||
isDelete: isDelete ?? _isDelete, |
||||
avatar: avatar ?? _avatar, |
||||
phone: phone ?? _phone, |
||||
); |
||||
String get mid => _mid; |
||||
String get nickname => _nickname; |
||||
num get isDelete => _isDelete; |
||||
String get avatar => _avatar; |
||||
String get phone => _phone; |
||||
|
||||
Map<String, dynamic> toJson() { |
||||
final map = <String, dynamic>{}; |
||||
map['mid'] = _mid; |
||||
map['nickname'] = _nickname; |
||||
map['isDelete'] = _isDelete; |
||||
map['avatar'] = _avatar; |
||||
map['phone'] = _phone; |
||||
return map; |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue