Hibok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

54 lines
1.3 KiB

  1. import 'package:chat/data/constants.dart';
  2. import 'package:chat/generated/i18n.dart';
  3. import 'package:chat/utils/LoadingDialog.dart';
  4. import 'package:oktoast/oktoast.dart';
  5. class BlacklistMgr {
  6. //我拉黑的用户id
  7. static Set<int> myBlacklistSet = new Set();
  8. //拉黑我的用户Id
  9. static Set<int> blacklistMeSet = new Set();
  10. //--------------------我的黑名单相关操作
  11. static addMyBlackList(int userId) {
  12. myBlacklistSet.add(userId);
  13. }
  14. static removeMyBalckList(int userId) {
  15. myBlacklistSet.remove(userId);
  16. }
  17. static bool isInMyblaklist(int userId) {
  18. return myBlacklistSet.contains(userId);
  19. }
  20. //------------------被拉黑名单相关操作
  21. static addBlackListMe(int userId) {
  22. blacklistMeSet.add(userId);
  23. }
  24. static removeBalckListMe(int userId) {
  25. blacklistMeSet.remove(userId);
  26. }
  27. static bool isBlaklistMe(int userId) {
  28. return blacklistMeSet.contains(userId);
  29. }
  30. //判断是否被别人拉黑或者拉黑别人
  31. static bool isBlack(int userId) {
  32. if (isBlaklistMe(userId)) {
  33. showToast(I18n.of(Constants.getCurrentContext()).you_are_blaklisted);
  34. return true;
  35. }
  36. if (BlacklistMgr.isInMyblaklist(userId)) {
  37. showToast(I18n.of(Constants.getCurrentContext()).reject_message);
  38. return true;
  39. }
  40. return false;
  41. }
  42. }