SKInCallViewController+touch.m 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // SKInCallViewController+touch.m
  3. // SikeyComm
  4. //
  5. // Created by 刘振兴 on 2025/2/13.
  6. // Copyright © 2025 BaH Cy. All rights reserved.
  7. //
  8. #import "SKInCallViewController+touch.h"
  9. @implementation SKInCallViewController (touch)
  10. - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  11. //如果不在通话
  12. JCCallItem *activeCall = [VideoManager shared].mJuphoonCall.callItems.firstObject;
  13. if (!activeCall.video && activeCall.state != JCCallStateTalking)
  14. return;
  15. UITouch *touch = [touches anyObject];
  16. //当前的坐标,第一次触摸
  17. CGPoint point = [touch locationInView: self.view];
  18. self.mStartPoint = point;
  19. point = [self.smallView.layer convertPoint:point fromLayer:self.view.layer];
  20. if ([self.smallView.layer containsPoint:point]) {
  21. self.isTouchInSmallCanvas = YES;
  22. }
  23. else {
  24. self.isTouchInSmallCanvas = NO;
  25. }
  26. }
  27. - (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  28. //如果不在通话
  29. JCCallItem *activeCall = [VideoManager shared].mJuphoonCall.callItems.firstObject;
  30. if (!activeCall.video && activeCall.state != JCCallStateTalking)
  31. return;
  32. if (!self.isTouchInSmallCanvas)
  33. return;
  34. UITouch *touch = [touches anyObject];
  35. CGPoint movePoint = [touch locationInView: self.view];
  36. CGPoint offsetPoint = CGPointMake(movePoint.x - self.mStartPoint.x, movePoint.y - self.mStartPoint.y);
  37. if (offsetPoint.x == 0 && offsetPoint.y == 0)
  38. return;
  39. self.isMoveInSmallCanvas = YES;
  40. CGRect canvasRect = self.smallView.frame;
  41. CGPoint endPoint = CGPointMake(canvasRect.origin.x + offsetPoint.x, canvasRect.origin.y + offsetPoint.y);
  42. //避免超框
  43. if (endPoint.x < 0.0) {
  44. endPoint.x = 0.0;
  45. }
  46. if (endPoint.y < SCREEN_STATUS_HEIGHT) {
  47. endPoint.y = SCREEN_STATUS_HEIGHT;
  48. }
  49. if (endPoint.x + canvasRect.size.width > SCREEN_WIDTH) {
  50. endPoint.x = SCREEN_WIDTH - canvasRect.size.width;
  51. }
  52. if (endPoint.y + canvasRect.size.height > SCREEN_HEIGHT) {
  53. endPoint.y = SCREEN_HEIGHT - canvasRect.size.height;
  54. }
  55. [self.smallView setOrigin:endPoint];
  56. self.mStartPoint = movePoint;
  57. }
  58. - (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  59. //如果不在通话
  60. JCCallItem *activeCall = [VideoManager shared].mJuphoonCall.callItems.firstObject;
  61. if (!activeCall.video && activeCall.state != JCCallStateTalking)
  62. return;
  63. self.isTouchInSmallCanvas = NO;
  64. self.isMoveInSmallCanvas = NO;
  65. self.mStartPoint = CGPointMake(0, 0);
  66. }
  67. - (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
  68. //如果不在通话
  69. JCCallItem *activeCall = [VideoManager shared].mJuphoonCall.callItems.firstObject;
  70. if (!activeCall.video && activeCall.state != JCCallStateTalking)
  71. return;
  72. self.isTouchInSmallCanvas = NO;
  73. self.isMoveInSmallCanvas = NO;
  74. self.mStartPoint = CGPointMake(0, 0);
  75. }
  76. @end