SKChatViewController+more.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //
  2. // SKChatViewController+more.m
  3. // SikeyComm
  4. //
  5. // Created by 刘振兴 on 2024/1/30.
  6. // Copyright © 2024 BaH Cy. All rights reserved.
  7. //
  8. #import "SKChatViewController+more.h"
  9. #import "SKChatMembersViewController.h"
  10. #import "SKChatViewController+permission.h"
  11. @implementation SKChatViewController (more)
  12. - (void)initMoreButton {
  13. if ([self.mSessionModel getSessionType] == 0) {
  14. self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"chat_group_members"] style:UIBarButtonItemStylePlain target:self action:@selector(showMembers)];
  15. } else {
  16. ChildModel* model = [[DataManager shared] getChild:[self.mSessionModel getChildId]];
  17. if ([model.device isBind]) {
  18. UIBarButtonItem* button1 = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"chat_mms_call"] style: UIBarButtonItemStylePlain target:self action:@selector(showCall)];
  19. UIBarButtonItem* button2 = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"chat_video"] style: UIBarButtonItemStylePlain target:self action:@selector(showVideo)];
  20. [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects: button1,button2,nil]];
  21. }
  22. }
  23. }
  24. - (void)showCall {
  25. ChildModel* model = [[DataManager shared] getChild:[self.mSessionModel getChildId]];
  26. if ([EUtil isInForbiddenTime:model.device]) {
  27. UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:NSLocalizedString(@"In.Forbidden.Time.No.Call", nil) preferredStyle:UIAlertControllerStyleAlert];
  28. [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Confirm", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  29. }]];
  30. [self presentViewController:alert animated:YES completion:nil];
  31. } else {
  32. NSString* phoneNum = model.phoneNumber;
  33. if (phoneNum == nil || [phoneNum length] <= 0 ) {
  34. [EasyTextView showInfoText:NSLocalizedString(@"Not.Bind.Mobile.Number", nil)];//@"当前未绑定手机号"];
  35. return;
  36. }
  37. //E164
  38. NSString* nationCode = [DataManager shared].mSelectChildModel.areaCode;
  39. phoneNum = [EUtil parsePhoneNumber:phoneNum countryCode:nationCode];
  40. phoneNum = [@"tel://" stringByAppendingString:phoneNum];
  41. if (![[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:phoneNum]]) {
  42. [EasyTextView showInfoText:NSLocalizedString(@"Call.With.Wrong.Simulator", nil)];//@"呼叫号码不正确或当前设备不支持"];
  43. } else {
  44. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNum] options:@{} completionHandler:^(BOOL success) {
  45. }];
  46. }
  47. }
  48. }
  49. - (void)showVideo {
  50. if ([self checkRecordPermission]) {
  51. [self onNoRecordRight];
  52. return;
  53. }
  54. @weakify(self);
  55. UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"SKChat.Video.Title", nil) message:NSLocalizedString(@"SKChat.Video.Content", nil) preferredStyle:UIAlertControllerStyleAlert];
  56. [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Cancel", nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
  57. }]];
  58. [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"SK.Confirm", nil) style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
  59. [weak_self showVideoEx];
  60. }]];
  61. [self presentViewController:alert animated:YES completion:nil];
  62. }
  63. - (void)showVideoEx {
  64. ChildModel* childModel = [[DataManager shared] getChild:[self.mSessionModel getChildId]];
  65. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  66. [[VideoManager shared] videoStart:self.mSessionModel.sid ticket:childModel.device.ticket dial:1];
  67. });
  68. }
  69. - (void)showMembers {
  70. //如果键盘弹起中
  71. [self.mOperationView resignBoard];
  72. SKChatMembersViewController *controller = [[self storyboard] instantiateViewControllerWithIdentifier:@"SKChatMembersVC"];
  73. controller.mChildId = [self.mSessionModel getChildId];
  74. controller.mSessionModel = self.mSessionModel;
  75. [self pushViewController:controller animated:YES];
  76. }
  77. @end