Entities.dart 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import 'dart:convert';
  2. import 'package:azlistview/azlistview.dart';
  3. import 'package:prime_chat/basic/Method.dart';
  4. import 'Global.dart';
  5. /// 图片
  6. class RemoteImageInfo {
  7. // String originalName;
  8. final String path;
  9. final String fileServer;
  10. RemoteImageInfo({required this.path, this.fileServer = "$server/file/"});
  11. const RemoteImageInfo.mock()
  12. : path = "",
  13. fileServer = "";
  14. RemoteImageInfo.fromJson(Map<String, dynamic> json)
  15. :
  16. // this.originalName = json["originalName"],
  17. path = json["path"],
  18. fileServer = json["fileServer"];
  19. }
  20. class FriendInfo extends ISuspensionBean {
  21. String? tagIndex;
  22. final Profile profile;
  23. FriendInfo({required this.profile, this.tagIndex});
  24. @override
  25. String getSuspensionTag() => tagIndex ?? name.substring(0, 1);
  26. String get name => profile.name;
  27. // toJson() => {"username": username, "uid": uid};
  28. // @override
  29. // String toString() => jsonEncode(this);
  30. }
  31. /// 用户自己的信息
  32. class Profile {
  33. final String id;
  34. final String name;
  35. final RemoteImageInfo avatar;
  36. const Profile(
  37. {this.id = "",
  38. required this.name,
  39. this.avatar = const RemoteImageInfo.mock()});
  40. Profile.fromJson(Map<String, dynamic> json)
  41. : name = json["name"],
  42. id = json["userId"].toString(),
  43. avatar = RemoteImageInfo(path: json["avatar"]);
  44. }