JXCopyRoomVC.m 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. //
  2. // JXCopyRoomVC.m
  3. // shiku_im
  4. //
  5. // Created by 1 on 2019/6/5.
  6. // Copyright © 2019年 Reese. All rights reserved.
  7. //
  8. #import "JXCopyRoomVC.h"
  9. #import "JXChatViewController.h"
  10. #import "JXRoomPool.h"
  11. @interface JXCopyRoomVC ()
  12. @property (nonatomic, strong) UIImageView *iconV;
  13. @end
  14. @implementation JXCopyRoomVC
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. self.isGotoBack = YES;
  18. self.heightFooter = 0;
  19. self.heightHeader = JX_SCREEN_TOP;
  20. [self createHeadAndFoot];
  21. self.title = Localized(@"JX_One-clickReplicationNewGroups");
  22. [self setupViews];
  23. [g_notify addObserver:self selector:@selector(headImageNotification:) name:kGroupHeadImageModifyNotifaction object:nil];
  24. }
  25. -(void)dealloc {
  26. [g_notify removeObserver:self];
  27. }
  28. -(void)headImageNotification:(NSNotification *)notification{
  29. NSDictionary * groupDict = notification.object;
  30. UIImage * hImage = groupDict[@"groupHeadImage"];
  31. _iconV.image = hImage;
  32. }
  33. - (void)setupViews {
  34. self.tableBody.backgroundColor = HEXCOLOR(0xF2F2F2);
  35. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 20, JX_SCREEN_WIDTH, 160)];
  36. view.backgroundColor = [UIColor whiteColor];
  37. [self.tableBody addSubview:view];
  38. _iconV = [[UIImageView alloc] initWithFrame:CGRectMake(JX_SCREEN_WIDTH/2-30, 20, 60, 60)];
  39. _iconV.layer.masksToBounds = YES;
  40. _iconV.layer.cornerRadius = 30.f;
  41. [view addSubview:_iconV];
  42. [g_server getRoomHeadImageSmall:self.room.roomJid roomId:self.room.roomId imageView:_iconV];
  43. UILabel *name = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_iconV.frame)+10, JX_SCREEN_WIDTH, 20)];
  44. name.font = SYSFONT(15);
  45. name.text = self.room.name;
  46. name.textAlignment = NSTextAlignmentCenter;
  47. [view addSubview:name];
  48. UILabel *numLab = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(name.frame)+10, JX_SCREEN_WIDTH, 20)];
  49. numLab.font = SYSFONT(15);
  50. numLab.text = [NSString stringWithFormat:@"%ld%@",self.room.members.count,Localized(@"JXLiveVC_countPeople")];
  51. numLab.textAlignment = NSTextAlignmentCenter;
  52. numLab.textColor = [UIColor grayColor];
  53. [view addSubview:numLab];
  54. UILabel *tint = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(view.frame)+10, 100, 20)];
  55. tint.font = SYSFONT(15);
  56. tint.textColor = [UIColor grayColor];
  57. tint.text = Localized(@"JX_Reminder");
  58. [self.tableBody addSubview:tint];
  59. tint = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(tint.frame)+5, JX_SCREEN_WIDTH-30, 40)];
  60. tint.font = SYSFONT(15);
  61. tint.textColor = [UIColor grayColor];
  62. tint.numberOfLines = 0;
  63. tint.text = [NSString stringWithFormat:@"%@\n%@",Localized(@"JX_ReminderContent"),Localized(@"JX_ReminderContent_2")];
  64. [self.tableBody addSubview:tint];
  65. UIButton *sureBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  66. sureBtn.frame = CGRectMake(15, CGRectGetMaxY(tint.frame)+30, JX_SCREEN_WIDTH-30, 40);
  67. sureBtn.backgroundColor = THEMECOLOR;
  68. [sureBtn setTitle:Localized(@"JX_ConfirmReplication") forState:UIControlStateNormal];
  69. [sureBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  70. [sureBtn addTarget:self action:@selector(onCopyRoom) forControlEvents:UIControlEventTouchUpInside];
  71. sureBtn.titleLabel.font = SYSFONT(16);
  72. sureBtn.layer.masksToBounds = YES;
  73. sureBtn.layer.cornerRadius = 7.f;
  74. [self.tableBody addSubview:sureBtn];
  75. }
  76. - (void)onCopyRoom {
  77. [g_server copyRoom:self.room.roomId toView:self];
  78. }
  79. -(void) didServerResultSucces:(JXConnection*)aDownload dict:(NSDictionary*)dict array:(NSArray*)array1{
  80. [_wait stop];
  81. if ([aDownload.action isEqualToString:act_copyRoom]) {
  82. [g_navigation popToRootViewController];
  83. roomData * roomdata = [[roomData alloc] init];
  84. [roomdata getDataFromDict:dict];
  85. JXChatViewController *sendView=[JXChatViewController alloc];
  86. sendView.title = self.room.name;
  87. sendView.roomJid = roomdata.roomJid;
  88. sendView.roomId = roomdata.roomId;
  89. sendView.chatRoom = [[JXXMPP sharedInstance].roomPool joinRoom:roomdata.roomJid title:self.room.name lastDate:nil isNew:NO];
  90. sendView.room = roomdata;
  91. JXUserObject *user = [[JXUserObject alloc] init];
  92. [user getDataFromDict:dict];
  93. sendView.chatPerson = user;
  94. sendView.chatPerson.userId = roomdata.roomJid;
  95. sendView.chatPerson.userNickname = self.room.name;
  96. user.userNickname = _room.name;
  97. user.userId = roomdata.roomJid;
  98. user.userDescription = roomdata.desc;
  99. user.roomId = roomdata.roomId;
  100. user.content = Localized(@"JX_WelcomeGroupChat");
  101. user.showRead = [NSNumber numberWithBool:roomdata.showRead];
  102. user.showMember = [NSNumber numberWithBool:roomdata.showMember];
  103. user.allowSendCard = [NSNumber numberWithBool:roomdata.allowSendCard];
  104. user.allowInviteFriend = [NSNumber numberWithBool:roomdata.allowInviteFriend];
  105. user.allowUploadFile = [NSNumber numberWithBool:roomdata.allowUploadFile];
  106. user.allowSpeakCourse = [NSNumber numberWithBool:roomdata.allowSpeakCourse];
  107. user.isNeedVerify = [NSNumber numberWithBool:roomdata.isNeedVerify];
  108. user.createUserId = [NSString stringWithFormat:@"%ld",roomdata.userId];
  109. [user insertRoom];
  110. sendView = [sendView init];
  111. [g_navigation pushViewController:sendView animated:YES];
  112. }
  113. }
  114. -(int) didServerResultFailed:(JXConnection*)aDownload dict:(NSDictionary*)dict{
  115. [_wait stop];
  116. return show_error;
  117. }
  118. -(int) didServerConnectError:(JXConnection*)aDownload error:(NSError *)error{//error为空时,代表超时
  119. [_wait stop];
  120. return show_error;
  121. }
  122. -(void) didServerConnectStart:(JXConnection*)aDownload{
  123. [_wait start];
  124. }
  125. @end