Browse Source

FEATURE | Calls ios

master
Vitalik 8 months ago
parent
commit
1d8030aa12
  1. 10
      .env.production
  2. 2
      android/app/build.gradle
  3. 2
      android/app/src/main/AndroidManifest.xml
  4. 12
      ios/taskme2.xcodeproj/project.pbxproj
  5. 6
      src/api/calls/requests.interfaces.ts
  6. 4
      src/api/calls/requests.ts
  7. 1
      src/api/notifications/requests.interfaces.ts
  8. 132
      src/config/fontello.json
  9. 6
      src/config/index.ts
  10. 21
      src/modules/calls/components/call-background.component.tsx
  11. 4
      src/modules/calls/components/call-btn.component.tsx
  12. 1
      src/modules/calls/hooks/index.ts
  13. 15
      src/modules/calls/hooks/use-call-data.hook.ts
  14. 31
      src/modules/calls/hooks/use-call-status.hook.ts
  15. 72
      src/modules/calls/hooks/use-call-streams.hook.ts
  16. 2
      src/modules/calls/hooks/use-calls-history.hook.ts
  17. 113
      src/modules/calls/screens/call/atoms/calling.atom.tsx
  18. 66
      src/modules/calls/screens/call/index.tsx
  19. 2
      src/modules/calls/services/call.service.ts
  20. 23
      src/modules/calls/services/callkeep.service.ts
  21. 8
      src/modules/calls/services/calls-events.service.ts
  22. 53
      src/modules/calls/services/peer-connection.service.ts
  23. 1
      src/services/system/voip-notification.service.ts
  24. 52
      src/shared/components/plugins/timmer.component.tsx
  25. 4
      src/shared/events/index.ts
  26. 2
      src/shared/interfaces/call.inteface.ts

10
.env.production

@ -1,3 +1,7 @@ @@ -1,3 +1,7 @@
API_URL=https://tasks-api.rwsbank.com.ua
SOCKET_URL=https://tasks-api.rwsbank.com.ua
ONE_SIGNAL_KEY=5e1a5e18-33e5-4ed3-8423-45b1abc354c6
# API_URL=https://tasks-api.rwsbank.com.ua
# SOCKET_URL=https://tasks-api.rwsbank.com.ua
# ONE_SIGNAL_KEY=5e1a5e18-33e5-4ed3-8423-45b1abc354c6
API_URL=https://taskme-api.work-jetup.site
SOCKET_URL=https://taskme-api.work-jetup.site
ONE_SIGNAL_KEY=8b9066f5-8c3f-49f7-bef4-c5ab621f9d27

2
android/app/build.gradle

@ -25,7 +25,7 @@ android { @@ -25,7 +25,7 @@ android {
applicationId "com.app.task_me"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 225
versionCode 227
versionName "2.3"
resValue "string", "build_config_package", "com.app.task_me"
}

2
android/app/src/main/AndroidManifest.xml

@ -48,7 +48,7 @@ @@ -48,7 +48,7 @@
/>
<meta-data android:name="com.onesignal.BadgeCount" android:value="DISABLE" />
<meta-data android:name="com.onesignal.messaging.default_notification_icon" android:resource="@mipmap/ic_launcher" />
<activity
android:name=".MainActivity"
android:label="@string/app_name"

12
ios/taskme2.xcodeproj/project.pbxproj

@ -734,7 +734,7 @@ @@ -734,7 +734,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2Stage.Release.entitlements;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_TEAM = HQ3J3TDPR2;
HEADER_SEARCH_PATHS = (
"$(inherited)",
@ -843,7 +843,7 @@ @@ -843,7 +843,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.2;
MARKETING_VERSION = 2.3;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
@ -1014,7 +1014,7 @@ @@ -1014,7 +1014,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2.entitlements;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_TEAM = HQ3J3TDPR2;
ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = (
@ -1124,7 +1124,7 @@ @@ -1124,7 +1124,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.2;
MARKETING_VERSION = 2.3;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
@ -1152,7 +1152,7 @@ @@ -1152,7 +1152,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2.entitlements;
CURRENT_PROJECT_VERSION = 22;
CURRENT_PROJECT_VERSION = 27;
DEVELOPMENT_TEAM = HQ3J3TDPR2;
HEADER_SEARCH_PATHS = (
"$(inherited)",
@ -1261,7 +1261,7 @@ @@ -1261,7 +1261,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.2;
MARKETING_VERSION = 2.3;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",

6
src/api/calls/requests.interfaces.ts

@ -6,7 +6,7 @@ export interface IStartCallPayload { @@ -6,7 +6,7 @@ export interface IStartCallPayload {
}
export interface IAnswerCallPayload {
callId: number
callId: string
rtcMessage: any
}
@ -17,11 +17,11 @@ export interface IIceCandidatePayload { @@ -17,11 +17,11 @@ export interface IIceCandidatePayload {
}
export interface ICancelCallPayload {
callId: number
callId: string
}
export interface IFinishCallPayload {
callId: number
callId: string
}
export interface ICallsListResponse {

4
src/api/calls/requests.ts

@ -34,6 +34,6 @@ export const deleteCallHistoryReq = (callId: number) => { @@ -34,6 +34,6 @@ export const deleteCallHistoryReq = (callId: number) => {
return api.delete(`calls/history/${callId}`, null, '')
}
export const getIncomeDataReq = (callId: string) => {
return api.post(`calls/income/${callId}`, {}, {}, '')
export const getIncomeDataReq = (callId: string, targetDeviceId: string) => {
return api.post(`calls/income/${callId}`, { targetDeviceId }, {}, '')
}

1
src/api/notifications/requests.interfaces.ts

@ -2,4 +2,5 @@ export interface ISaveDevicePayload { @@ -2,4 +2,5 @@ export interface ISaveDevicePayload {
deviceUuid: string
notificationUserId: string
isVoip?: boolean
isDev?: boolean
}

132
src/config/fontello.json

@ -1071,22 +1071,130 @@ @@ -1071,22 +1071,130 @@
]
},
{
"uid": "72109d2fb3088d0e66ea6a9204297651",
"css": "spin1",
"code": 59467,
"src": "fontelico"
"uid": "53a6bafbfe847db39c1bb76b531f199b",
"css": "camerarotate",
"code": 59543,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M812.5 218.8H704.2L651 138.9C648.1 134.6 644.3 131.1 639.7 128.7 635.2 126.3 630.1 125 625 125H375C369.9 125 364.8 126.3 360.3 128.7 355.7 131.1 351.9 134.6 349 138.9L295.7 218.8H187.5C162.6 218.8 138.8 228.6 121.2 246.2 103.6 263.8 93.8 287.6 93.8 312.5V750C93.8 774.9 103.6 798.7 121.2 816.3 138.8 833.9 162.6 843.8 187.5 843.8H812.5C837.4 843.8 861.2 833.9 878.8 816.3 896.4 798.7 906.3 774.9 906.3 750V312.5C906.3 287.6 896.4 263.8 878.8 246.2 861.2 228.6 837.4 218.8 812.5 218.8ZM843.8 750C843.8 758.3 840.5 766.2 834.6 772.1 828.7 778 820.8 781.3 812.5 781.3H187.5C179.2 781.3 171.3 778 165.4 772.1 159.5 766.2 156.3 758.3 156.3 750V312.5C156.3 304.2 159.5 296.3 165.4 290.4 171.3 284.5 179.2 281.3 187.5 281.3H312.5C317.6 281.3 322.7 280 327.3 277.6 331.8 275.1 335.7 271.6 338.5 267.3L391.7 187.5H608.2L661.5 267.3C664.3 271.6 668.2 275.1 672.7 277.6 677.3 280 682.4 281.3 687.5 281.3H812.5C820.8 281.3 828.7 284.5 834.6 290.4 840.5 296.3 843.8 304.2 843.8 312.5V750ZM687.5 375V468.8C687.5 477 684.2 485 678.3 490.8 672.5 496.7 664.5 500 656.3 500H562.5C554.2 500 546.3 496.7 540.4 490.8 534.5 485 531.3 477 531.3 468.8 531.3 460.5 534.5 452.5 540.4 446.7 546.3 440.8 554.2 437.5 562.5 437.5H582.6C561 418.6 533.6 407.7 504.9 406.5 476.3 405.4 448.1 414.1 425 431.2 418.4 436.2 410.1 438.3 401.9 437.2 393.7 436 386.3 431.6 381.3 425 376.3 418.4 374.1 410.1 375.3 401.9 376.5 393.6 380.8 386.2 387.5 381.3 422.2 355.4 464.8 342.3 508.1 344.2 551.3 346 592.6 362.8 625 391.5V375C625 366.7 628.3 358.8 634.2 352.9 640 347 648 343.8 656.3 343.8 664.5 343.8 672.5 347 678.3 352.9 684.2 358.8 687.5 366.7 687.5 375ZM618.7 606.3C623.7 612.9 625.8 621.2 624.7 629.4 623.5 637.6 619.2 645 612.5 650 577.8 675.9 535.2 689 491.9 687.1 448.7 685.2 407.4 668.5 375 639.7V656.3C375 664.5 371.7 672.5 365.8 678.3 360 684.2 352 687.5 343.8 687.5 335.5 687.5 327.5 684.2 321.7 678.3 315.8 672.5 312.5 664.5 312.5 656.3V562.5C312.5 554.2 315.8 546.3 321.7 540.4 327.5 534.5 335.5 531.3 343.8 531.3H437.5C445.8 531.3 453.7 534.5 459.6 540.4 465.5 546.3 468.8 554.2 468.8 562.5 468.8 570.8 465.5 578.7 459.6 584.6 453.7 590.5 445.8 593.8 437.5 593.8H417.4C439 612.7 466.4 623.6 495.1 624.7 523.7 625.9 551.9 617.2 575 600 581.6 595.1 589.9 592.9 598.1 594.1 606.3 595.3 613.7 599.6 618.7 606.3Z",
"width": 1000
},
"search": [
"camerarotate"
]
},
{
"uid": "28117bfad09f00d820d825e8415874ce",
"css": "microphone",
"code": 59544,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M500 687.5C549.7 687.4 597.4 667.7 632.5 632.5 667.7 597.4 687.4 549.7 687.5 500V250C687.5 200.3 667.7 152.6 632.6 117.4 597.4 82.3 549.7 62.5 500 62.5 450.3 62.5 402.6 82.3 367.4 117.4 332.3 152.6 312.5 200.3 312.5 250V500C312.6 549.7 332.3 597.4 367.5 632.5 402.6 667.7 450.3 687.4 500 687.5ZM375 250C375 216.8 388.2 185.1 411.6 161.6 435.1 138.2 466.8 125 500 125 533.2 125 564.9 138.2 588.4 161.6 611.8 185.1 625 216.8 625 250V500C625 533.2 611.8 564.9 588.4 588.4 564.9 611.8 533.2 625 500 625 466.8 625 435.1 611.8 411.6 588.4 388.2 564.9 375 533.2 375 500V250ZM531.3 810.9V906.3C531.3 914.5 528 922.5 522.1 928.3 516.2 934.2 508.3 937.5 500 937.5 491.7 937.5 483.8 934.2 477.9 928.3 472 922.5 468.8 914.5 468.8 906.3V810.9C391.7 803.1 320.3 767 268.4 709.5 216.4 652.1 187.6 577.4 187.5 500 187.5 491.7 190.8 483.8 196.7 477.9 202.5 472 210.5 468.8 218.8 468.8 227 468.8 235 472 240.8 477.9 246.7 483.8 250 491.7 250 500 250 566.3 276.3 629.9 323.2 676.8 370.1 723.7 433.7 750 500 750 566.3 750 629.9 723.7 676.8 676.8 723.7 629.9 750 566.3 750 500 750 491.7 753.3 483.8 759.2 477.9 765 472 773 468.8 781.3 468.8 789.5 468.8 797.5 472 803.3 477.9 809.2 483.8 812.5 491.7 812.5 500 812.4 577.4 783.6 652.1 731.6 709.5 679.7 767 608.3 803.1 531.3 810.9Z",
"width": 1000
},
"search": [
"microphone"
]
},
{
"uid": "1ad2c90540e5ec91691ff2f4d88a7007",
"css": "microphoneslash",
"code": 59545,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M835.6 822.7L210.6 135.2C207.9 132.1 204.5 129.6 200.8 127.8 197.1 126 193 125 188.9 124.8 184.8 124.5 180.7 125.1 176.8 126.5 172.9 127.9 169.3 130.1 166.2 132.8 163.2 135.6 160.7 139 158.9 142.7 157.2 146.5 156.2 150.5 156 154.7 155.8 158.8 156.5 162.9 157.9 166.8 159.4 170.7 161.5 174.2 164.4 177.3L312.5 340.2V500C312.5 533.7 321.6 566.7 338.7 595.6 355.9 624.6 380.5 648.4 410.1 664.5 439.6 680.6 472.9 688.5 506.5 687.4 540.2 686.2 572.9 676 601.2 657.8L643.7 704.7C606.2 731 562.3 746.5 516.6 749.6 470.9 752.6 425.3 743.1 384.7 721.9 344.1 700.8 310 669 286.3 629.8 262.5 590.7 250 545.8 250 500 250 491.7 246.7 483.8 240.8 477.9 235 472 227 468.8 218.7 468.8 210.5 468.8 202.5 472 196.6 477.9 190.8 483.8 187.5 491.7 187.5 500 187.6 577.4 216.4 652.1 268.3 709.5 320.3 767 391.7 803.1 468.7 810.9V906.3C468.7 914.5 472 922.5 477.9 928.3 483.8 934.2 491.7 937.5 500 937.5 508.3 937.5 516.2 934.2 522.1 928.3 528 922.5 531.2 914.5 531.2 906.3V810.9C587.3 805.3 640.8 784.7 686 751.1L789.4 864.8C792.1 867.9 795.4 870.4 799.2 872.2 802.9 874 806.9 875 811.1 875.2 815.2 875.5 819.3 874.9 823.2 873.5 827.1 872.1 830.7 869.9 833.8 867.2 836.8 864.4 839.3 861 841.1 857.3 842.8 853.5 843.8 849.5 844 845.3 844.1 841.2 843.5 837.1 842.1 833.2 840.6 829.3 838.4 825.8 835.6 822.7ZM500 625C466.8 625 435 611.8 411.6 588.4 388.2 564.9 375 533.2 375 500V408.9L558.3 610.6C540.3 620.1 520.3 625 500 625ZM340.5 151.5C361.9 116.8 394.1 90 432.1 75.2 470.1 60.5 511.9 58.5 551.2 69.6 590.4 80.8 625 104.4 649.6 137 674.2 169.5 687.5 209.2 687.5 250V486.1C687.5 494.3 684.2 502.3 678.3 508.2 672.5 514 664.5 517.3 656.2 517.3 648 517.3 640 514 634.1 508.2 628.3 502.3 625 494.3 625 486.1V250C625 222.8 616.1 196.3 599.7 174.6 583.3 152.9 560.3 137.1 534.1 129.7 507.9 122.3 480 123.6 454.7 133.4 429.3 143.3 407.9 161.2 393.6 184.3 391.5 188 388.7 191.2 385.4 193.7 382 196.2 378.2 198.1 374.2 199.1 370.1 200.2 365.9 200.4 361.7 199.7 357.6 199.1 353.6 197.6 350 195.4 346.4 193.2 343.4 190.3 340.9 186.9 338.5 183.5 336.8 179.6 335.9 175.5 335 171.4 335 167.1 335.7 163 336.5 158.9 338.1 155 340.5 151.5ZM733 590.9C744.3 561.9 750 531.1 750 500 750 491.7 753.3 483.8 759.1 477.9 765 472 773 468.8 781.2 468.8 789.5 468.8 797.5 472 803.3 477.9 809.2 483.8 812.5 491.7 812.5 500 812.5 538.9 805.3 577.4 791.2 613.6 789.7 617.5 787.5 621.1 784.7 624.2 781.9 627.2 778.5 629.7 774.7 631.4 770.9 633.1 766.8 634 762.6 634.1 758.5 634.2 754.3 633.5 750.5 632 746.6 630.5 743 628.2 740.1 625.3 737.1 622.4 734.7 619 733.1 615.1 731.4 611.3 730.6 607.2 730.6 603 730.6 598.9 731.4 594.7 733 590.9Z",
"width": 1000
},
"search": [
"microphoneslash"
]
},
{
"uid": "5d2d07f112b8de19f2c0dbfec3e42c05",
"css": "spin5",
"code": 59468,
"src": "fontelico"
"uid": "358fe4a46e6b5245a22bf5133d10a31a",
"css": "phonedisconnect",
"code": 59547,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M931.7 442.1C697.7 208.2 302.4 208.2 68.4 442.1-14.9 525.4-22.9 648.3 48.9 740.9 55.1 748.9 63.1 755.3 72.2 759.8 81.3 764.2 91.3 766.5 101.5 766.5 109.7 766.5 117.8 765 125.4 762L329.6 689.7 330.8 689.2C341.1 685.1 350.2 678.4 357.3 669.9 364.4 661.4 369.3 651.2 371.4 640.3L396 517.3C463.1 494.2 535.9 494 603 516.9L628.9 640.8C631.1 651.6 636 661.6 643.1 670.1 650.2 678.5 659.2 685 669.4 689.1L670.6 689.6 874.8 762C888.1 767.2 902.8 767.9 916.6 764.1 930.3 760.3 942.5 752.2 951.4 740.9 1023 648.3 1014.9 525.4 931.7 442.1ZM898.6 699.9L897.4 699.4 694 627.2 668.1 503.2C665.8 492 660.6 481.6 653 473 645.5 464.4 635.8 457.8 625 454 543.5 426.1 455 426.3 373.6 454.6 362.7 458.5 353 465.1 345.5 473.9 338 482.7 332.8 493.2 330.6 504.6L306 627.5 102.7 699.3C102.2 699.3 101.9 699.8 101.5 700 50.2 633.7 55.7 549 115.5 489.2 219.7 385.1 359.9 332.9 500 332.9 640.1 332.9 780.3 385 884.5 489.2 944.2 549 950 633.7 898.6 699.9Z",
"width": 1000
},
"search": [
"phonedisconnect"
]
},
{
"uid": "9bd60140934a1eb9236fd7a8ab1ff6ba",
"css": "spin4",
"code": 59469,
"src": "fontelico"
"uid": "94ec722039c9819f635c7f9f92c1a702",
"css": "phonecall",
"code": 59546,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M594.8 148.2C595.9 144.2 597.7 140.5 600.2 137.2 602.7 134 605.8 131.2 609.4 129.2 612.9 127.1 616.8 125.8 620.9 125.3 625 124.7 629.1 125 633.1 126.1 691 141.2 743.9 171.5 786.2 213.8 828.5 256.1 858.8 309 873.9 366.9 875 370.9 875.3 375 874.7 379.1 874.2 383.2 872.9 387.1 870.8 390.6 868.8 394.2 866 397.3 862.8 399.8 859.5 402.3 855.8 404.1 851.8 405.2 849.2 405.9 846.5 406.2 843.8 406.3 836.9 406.3 830.2 404 824.7 399.8 819.3 395.6 815.3 389.7 813.6 383 801.2 335.8 776.5 292.6 742 258 707.4 223.5 664.2 198.8 617 186.4 613 185.4 609.3 183.6 606 181.1 602.7 178.6 600 175.5 597.9 171.9 595.9 168.3 594.6 164.4 594 160.3 593.5 156.3 593.7 152.1 594.8 148.2ZM585.7 311.4C639.6 325.8 674.2 360.4 688.6 414.3 690.3 421 694.3 426.8 699.7 431 705.2 435.2 711.9 437.5 718.8 437.5 721.5 437.5 724.2 437.1 726.8 436.4 730.8 435.4 734.5 433.6 737.8 431.1 741 428.6 743.8 425.4 745.8 421.9 747.9 418.3 749.2 414.4 749.7 410.3 750.3 406.3 750 402.1 748.9 398.2 728.9 323.3 676.7 271.1 601.8 251.1 597.9 250 593.7 249.7 589.7 250.3 585.6 250.8 581.7 252.1 578.1 254.2 574.6 256.3 571.5 259 569 262.2 566.5 265.5 564.6 269.2 563.6 273.2 562.5 277.1 562.2 281.3 562.8 285.4 563.3 289.4 564.7 293.3 566.7 296.9 568.8 300.5 571.5 303.6 574.8 306.1 578 308.6 581.7 310.4 585.7 311.4ZM905.8 683.9C898.8 736.8 872.8 785.4 832.7 820.6 792.5 855.8 740.9 875.1 687.5 875 377.3 875 125 622.7 125 312.5 124.9 259.1 144.2 207.5 179.4 167.3 214.6 127.2 263.2 101.2 316.1 94.2 329.5 92.6 343 95.3 354.7 102 366.4 108.7 375.7 119 381 131.4L463.5 315.6V316.1C467.6 325.5 469.3 335.9 468.5 346.1 467.6 356.4 464.2 366.4 458.6 375 457.9 376.1 457.1 377 456.3 378L375 474.4C404.3 533.9 466.4 595.5 526.7 624.8L621.8 543.9C622.7 543.2 623.7 542.4 624.7 541.8 633.3 536 643.3 532.5 653.6 531.5 664 530.6 674.4 532.2 683.9 536.3L684.5 536.5 868.5 619C880.9 624.3 891.2 633.5 897.9 645.2 904.7 656.9 907.4 670.5 905.8 683.9ZM843.8 676.1C843.8 676.1 843.5 676.1 843.3 676.1L659.7 593.9 564.6 674.8C563.7 675.5 562.7 676.3 561.7 677 552.7 683 542.3 686.5 531.5 687.3 520.8 688.1 510 686 500.2 681.4 427 646.1 354.1 573.7 318.7 501.3 314 491.6 311.9 480.9 312.6 470.1 313.3 459.4 316.7 449 322.6 440 323.3 438.9 324 437.9 324.8 437L406.3 340.4 324.2 156.8C324.2 156.7 324.2 156.5 324.2 156.4 286.3 161.3 251.6 179.9 226.4 208.6 201.2 237.4 187.4 274.3 187.5 312.5 187.6 445.1 240.4 572.2 334.1 665.9 427.8 759.6 554.9 812.4 687.5 812.5 725.7 812.6 762.6 798.9 791.4 773.7 820.1 748.6 838.7 713.9 843.8 676.1V676.1Z",
"width": 1000
},
"search": [
"phonecall"
]
},
{
"uid": "05e52a7d3e3b0d2b94c4876d9e5dfc89",
"css": "speakerhigh",
"code": 59548,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M607.5 96.9C602.2 94.4 596.3 93.3 590.5 93.9 584.7 94.5 579.2 96.8 574.6 100.4L301.8 312.5H125C108.4 312.5 92.5 319.1 80.8 330.8 69.1 342.5 62.5 358.4 62.5 375V625C62.5 641.6 69.1 657.5 80.8 669.2 92.5 680.9 108.4 687.5 125 687.5H301.8L574.6 899.7C579.2 903.2 584.7 905.5 590.5 906.1 596.4 906.7 602.2 905.6 607.5 903.1 612.7 900.5 617.2 896.5 620.3 891.5 623.4 886.6 625 880.9 625 875V125C625 119.1 623.4 113.4 620.3 108.4 617.2 103.5 612.7 99.5 607.5 96.9ZM125 375H281.3V625H125V375ZM562.5 811.1L343.8 641V359L562.5 188.9V811.1ZM773.4 396.7C798.6 425.3 812.4 462 812.4 500 812.4 538 798.6 574.8 773.4 603.3 767.9 609.4 760.2 613 752 613.5 743.9 613.9 735.8 611.1 729.7 605.7 723.5 600.3 719.7 592.6 719.2 584.5 718.6 576.3 721.2 568.2 726.6 562 741.6 544.8 750 522.8 750 500 750 477.2 741.6 455.2 726.6 438.1 721.2 431.8 718.6 423.7 719.2 415.5 719.7 407.4 723.5 399.7 729.7 394.3 735.8 388.9 743.9 386.1 752 386.6 760.2 387 767.9 390.7 773.4 396.7ZM968.8 500C968.8 576.9 940.5 651.1 889.2 708.4 883.6 714.4 875.9 718 867.7 718.4 859.5 718.8 851.5 715.9 845.4 710.4 839.3 705 835.6 697.3 835 689.1 834.5 680.9 837.2 672.9 842.6 666.7 883.6 620.8 906.3 561.5 906.3 500 906.3 438.5 883.6 379.2 842.6 333.4 839.8 330.3 837.6 326.7 836.2 322.8 834.8 319 834.2 314.8 834.4 310.7 834.5 306.5 835.6 302.5 837.3 298.7 839.1 295 841.6 291.6 844.7 288.9 847.8 286.1 851.4 284 855.3 282.6 859.3 281.3 863.4 280.7 867.5 281 871.7 281.2 875.7 282.3 879.4 284.1 883.2 286 886.5 288.5 889.2 291.7 940.5 348.9 968.8 423.1 968.8 500Z",
"width": 1000
},
"search": [
"speakerhigh"
]
},
{
"uid": "718023bb162b1c3ec56f8c02da0efc9d",
"css": "speakerslash",
"code": 59549,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M210.6 135.2C207.9 132.1 204.5 129.6 200.8 127.8 197.1 126 193.1 125 188.9 124.8 184.8 124.5 180.7 125.1 176.8 126.5 172.9 127.9 169.3 130.1 166.2 132.8 163.2 135.6 160.7 139 158.9 142.7 157.2 146.5 156.2 150.5 156 154.7 155.9 158.8 156.5 162.9 157.9 166.8 159.4 170.7 161.6 174.2 164.4 177.3L287.3 312.5H125C108.4 312.5 92.5 319.1 80.8 330.8 69.1 342.5 62.5 358.4 62.5 375V625C62.5 641.6 69.1 657.5 80.8 669.2 92.5 680.9 108.4 687.5 125 687.5H301.8L574.6 899.7C579.2 903.2 584.7 905.5 590.5 906.1 596.4 906.7 602.2 905.6 607.5 903.1 612.7 900.5 617.2 896.5 620.3 891.5 623.4 886.6 625 880.9 625 875V683.9L789.4 864.8C792.1 867.9 795.5 870.4 799.2 872.2 802.9 874 806.9 875 811.1 875.2 815.2 875.5 819.3 874.9 823.2 873.5 827.1 872.1 830.7 869.9 833.8 867.2 836.8 864.4 839.3 861 841.1 857.3 842.8 853.5 843.8 849.5 844 845.3 844.1 841.2 843.5 837.1 842.1 833.2 840.6 829.3 838.4 825.8 835.6 822.7L210.6 135.2ZM125 375H281.3V625H125V375ZM562.5 811.1L343.8 641V374.6L562.5 615.2V811.1ZM726.6 562C741.6 544.9 750 522.9 750 500 750 477.2 741.6 455.2 726.6 438.1 723.7 435 721.5 431.4 720 427.5 718.6 423.6 717.9 419.4 718.1 415.2 718.3 411 719.3 406.9 721.2 403.1 723 399.4 725.5 396 728.7 393.2 731.8 390.5 735.5 388.3 739.5 387 743.4 385.7 747.6 385.2 751.8 385.5 756 385.9 760.1 387 763.8 389 767.5 390.9 770.8 393.6 773.4 396.8 798.6 425.3 812.4 462.1 812.4 500.1 812.4 538.1 798.6 574.8 773.4 603.4 770.7 606.4 767.4 609 763.7 610.8 760.1 612.6 756 613.6 751.9 613.9 747.9 614.1 743.7 613.6 739.9 612.2 736 610.9 732.4 608.8 729.3 606.1 726.2 603.4 723.7 600.1 721.9 596.4 720.1 592.7 719.1 588.7 718.8 584.6 718.5 580.5 719.1 576.4 720.4 572.5 721.8 568.7 723.8 565.1 726.6 562ZM413.4 265.1C410.9 261.9 409.1 258.2 408 254.2 406.9 250.3 406.6 246.1 407.1 242.1 407.6 238 408.9 234 410.9 230.5 413 226.9 415.7 223.8 418.9 221.3L574.6 100.2C579.2 96.6 584.8 94.3 590.6 93.7 596.4 93.1 602.3 94.2 607.6 96.8 612.8 99.4 617.2 103.4 620.3 108.4 623.4 113.4 625 119.1 625 125V417.3C625 425.6 621.7 433.5 615.8 439.4 610 445.3 602 448.6 593.8 448.6 585.5 448.6 577.5 445.3 571.7 439.4 565.8 433.5 562.5 425.6 562.5 417.3V188.9L457.3 270.9C450.7 276 442.4 278.2 434.2 277.2 426 276.1 418.5 271.8 413.4 265.3V265.1ZM968.8 500C968.8 576.9 940.5 651.1 889.2 708.4 883.6 714.4 875.9 718 867.7 718.4 859.5 718.8 851.5 715.9 845.4 710.4 839.3 705 835.6 697.3 835 689.1 834.5 680.9 837.2 672.9 842.6 666.7 883.6 620.8 906.3 561.5 906.3 500 906.3 438.5 883.6 379.2 842.6 333.4 839.8 330.3 837.6 326.7 836.2 322.8 834.8 319 834.2 314.8 834.4 310.7 834.5 306.5 835.6 302.5 837.3 298.7 839.1 295 841.6 291.6 844.7 288.9 847.8 286.1 851.4 284 855.3 282.6 859.3 281.3 863.4 280.7 867.5 281 871.7 281.2 875.7 282.3 879.4 284.1 883.2 286 886.5 288.5 889.2 291.7 940.5 348.9 968.8 423.1 968.8 500Z",
"width": 1000
},
"search": [
"speakerslash"
]
},
{
"uid": "9a3a4d2c12618c81513553060faae3c8",
"css": "videocamera",
"code": 59550,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M983.5 285.2C978.5 282.5 972.9 281.2 967.2 281.5 961.6 281.8 956.1 283.5 951.4 286.7L812.5 379.1V281.3C812.5 264.7 805.9 248.8 794.2 237.1 782.5 225.3 766.6 218.8 750 218.8H125C108.4 218.8 92.5 225.3 80.8 237.1 69.1 248.8 62.5 264.7 62.5 281.3V718.8C62.5 735.3 69.1 751.2 80.8 762.9 92.5 774.7 108.4 781.3 125 781.3H750C766.6 781.3 782.5 774.7 794.2 762.9 805.9 751.2 812.5 735.3 812.5 718.8V621.1L951.4 713.7C956.6 717.1 962.6 718.8 968.8 718.8 977 718.8 985 715.5 990.8 709.6 996.7 703.7 1000 695.8 1000 687.5V312.5C1000 306.9 998.4 301.4 995.5 296.6 992.6 291.7 988.4 287.8 983.5 285.2ZM750 718.8H125V281.3H750V718.8ZM937.5 629.1L812.5 545.8V454.2L937.5 371.1V629.1Z",
"width": 1000
},
"search": [
"videocamera"
]
},
{
"uid": "e706d4c2e9aca4b4cc85220853f346ae",
"css": "videocameraslash",
"code": 59551,
"src": "custom_icons",
"selected": true,
"svg": {
"path": "M983.5 285.2C978.5 282.5 972.9 281.2 967.2 281.5 961.6 281.8 956.1 283.5 951.4 286.7L812.5 379.1V281.3C812.5 264.7 805.9 248.8 794.2 237.1 782.5 225.3 766.6 218.8 750 218.8H441.6C433.4 218.8 425.4 222 419.5 227.9 413.7 233.8 410.4 241.7 410.4 250 410.4 258.3 413.7 266.2 419.5 272.1 425.4 278 433.4 281.3 441.6 281.3H750V623.6C750 631.8 753.3 639.8 759.2 645.7 765 651.5 773 654.8 781.3 654.8 789.5 654.8 797.5 651.5 803.3 645.7 809.2 639.8 812.5 631.8 812.5 623.6V621.1L951.4 713.7C956.6 717.1 962.6 718.8 968.8 718.8 977 718.8 985 715.5 990.8 709.6 996.7 703.7 1000 695.8 1000 687.5V312.5C1000 306.9 998.4 301.4 995.5 296.6 992.6 291.7 988.4 287.8 983.5 285.2ZM937.5 629.1L812.5 545.8V454.2L937.5 371.1V629.1ZM210.6 135.2C207.9 132.1 204.5 129.6 200.8 127.8 197.1 126 193.1 125 188.9 124.8 184.8 124.5 180.7 125.1 176.8 126.5 172.9 127.9 169.3 130.1 166.2 132.8 163.2 135.6 160.7 139 158.9 142.7 157.2 146.5 156.2 150.5 156 154.7 155.9 158.8 156.5 162.9 157.9 166.8 159.4 170.7 161.6 174.2 164.4 177.3L202.1 218.8H125C108.4 218.8 92.5 225.3 80.8 237.1 69.1 248.8 62.5 264.7 62.5 281.3V718.8C62.5 735.3 69.1 751.2 80.8 762.9 92.5 774.7 108.4 781.3 125 781.3H713.4L789.4 864.8C792.1 867.9 795.5 870.4 799.2 872.2 802.9 874 806.9 875 811.1 875.2 815.2 875.5 819.3 874.9 823.2 873.5 827.1 872.1 830.7 869.9 833.8 867.2 836.8 864.4 839.3 861 841.1 857.3 842.8 853.5 843.8 849.5 844 845.3 844.1 841.2 843.5 837.1 842.1 833.2 840.6 829.3 838.4 825.8 835.6 822.7L210.6 135.2ZM125 718.8V281.3H258.9L656.6 718.8H125Z",
"width": 1000
},
"search": [
"videocameraslash"
]
}
]
}

6
src/config/index.ts

@ -2,8 +2,10 @@ import Config from 'react-native-config' @@ -2,8 +2,10 @@ import Config from 'react-native-config'
import { fonts } from './fonts'
export const dynamicConfig = {
baseUrl: 'http://192.168.0.150:3000', // Config.API_URL,
socketUrl: 'http://192.168.0.150:3000', //Config.SOCKET_URL,
// baseUrl: 'http://192.168.0.150:3000', // Config.API_URL,
// socketUrl: 'http://192.168.0.150:3000', //Config.SOCKET_URL,]
baseUrl: Config.API_URL,
socketUrl: Config.SOCKET_URL,
oneSignalKey: Config.ONE_SIGNAL_KEY,
appStoreUrl: 'https://apps.apple.com/ua/app/task-me/id1482240685?l=uk',
googlePlayUrl:

21
src/modules/calls/components/call-background.component.tsx

@ -8,6 +8,7 @@ interface IProps { @@ -8,6 +8,7 @@ interface IProps {
avatarImageUrl: string
title: string
subtitle?: string
subtitleComponent?: JSX.Element
fullComponent?: JSX.Element
showAvatar?: boolean
@ -22,6 +23,7 @@ export const CallBackground: FC<PropsWithChildren<IProps>> = ({ @@ -22,6 +23,7 @@ export const CallBackground: FC<PropsWithChildren<IProps>> = ({
fullComponent,
showAvatar = true,
needOverlay = true,
subtitleComponent,
}) => {
const { styles } = useTheme(createStyles)
@ -57,9 +59,13 @@ export const CallBackground: FC<PropsWithChildren<IProps>> = ({ @@ -57,9 +59,13 @@ export const CallBackground: FC<PropsWithChildren<IProps>> = ({
{ backgroundColor: needOverlay ? 'rgba(0,0,0,.3)' : null },
]}>
<Txt style={styles.title}>{title}</Txt>
{subtitle ? (
<Txt style={styles.subtitle}>{subtitle}</Txt>
) : null}
<View style={styles.subtitleView}>
{subtitle ? (
<Txt style={styles.subtitle}>{subtitle}</Txt>
) : (
subtitleComponent
)}
</View>
{children}
</View>
@ -102,11 +108,16 @@ const createStyles = (theme: PartialTheme) => @@ -102,11 +108,16 @@ const createStyles = (theme: PartialTheme) =>
title: {
fontSize: $size(30),
color: '#fff',
marginBottom: $size(30),
marginBottom: $size(15),
},
subtitle: {
color: '#fff',
marginBottom: $size(30),
},
subtitleView: {
height: 50,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
},
txtPreviewBlock: {
width: $size(130),

4
src/modules/calls/components/call-btn.component.tsx

@ -12,6 +12,7 @@ interface IProps { @@ -12,6 +12,7 @@ interface IProps {
iconName: string
onPress: () => void
bgColor: string
iconColor?: string
style?: ViewStyle
isAnimated?: boolean
}
@ -22,6 +23,7 @@ export const CallBtn: FC<IProps> = ({ @@ -22,6 +23,7 @@ export const CallBtn: FC<IProps> = ({
bgColor = 'rgba(255,255,255,.2)',
style,
isAnimated = true,
iconColor = '#fff',
}) => {
const [animation] = useState(new Animated.Value(0))
@ -68,7 +70,7 @@ export const CallBtn: FC<IProps> = ({ @@ -68,7 +70,7 @@ export const CallBtn: FC<IProps> = ({
<TouchableOpacity
onPress={onPress}
style={[styles.btn, { backgroundColor: bgColor }, style]}>
<IconComponent name={iconName} size={20} color="#fff" />
<IconComponent name={iconName} size={20} color={iconColor} />
</TouchableOpacity>
</Animated.View>
)

1
src/modules/calls/hooks/index.ts

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
export * from './use-call-data.hook'
export * from './use-call-from.hook'
export * from './use-call-status.hook'
export * from './use-call-streams.hook'
export * from './use-calls-history.hook'

15
src/modules/calls/hooks/use-call-data.hook.ts

@ -12,7 +12,8 @@ export interface CallDataStore { @@ -12,7 +12,8 @@ export interface CallDataStore {
peerConnection: RTCPeerConnection
mod: CallMod
targetUserId?: number
callId?: number
callId?: string
callStartAt?: number
remoteRTCMessage?: any
icecandidates: any[]
connectedStatus: RTCIceConnectionState
@ -22,13 +23,14 @@ export interface CallDataStore { @@ -22,13 +23,14 @@ export interface CallDataStore {
incomeCall: (
targetUserId: number,
remoteRTCMessage: any,
callId: number,
callId: string,
peerConnection: RTCPeerConnection,
) => void
addIcecanidate: (item: any) => void
cleanIcecandidates: () => void
setConnectedStatus: (connectedStatus: RTCIceConnectionState) => void
setCallId: (callId: number) => void
setCallId: (callId: string) => void
setStartAt: (callStartAt: number) => void
}
export const useCallDataStore = create<CallDataStore>()(set => ({
@ -38,6 +40,7 @@ export const useCallDataStore = create<CallDataStore>()(set => ({ @@ -38,6 +40,7 @@ export const useCallDataStore = create<CallDataStore>()(set => ({
callId: null,
remoteRTCMessage: null,
icecandidates: [],
callStartAt: 0,
connectedStatus: null,
@ -45,7 +48,7 @@ export const useCallDataStore = create<CallDataStore>()(set => ({ @@ -45,7 +48,7 @@ export const useCallDataStore = create<CallDataStore>()(set => ({
set({ mod })
},
setCallId(callId: number) {
setCallId(callId: string) {
set({ callId })
},
@ -77,6 +80,10 @@ export const useCallDataStore = create<CallDataStore>()(set => ({ @@ -77,6 +80,10 @@ export const useCallDataStore = create<CallDataStore>()(set => ({
setConnectedStatus(connectedStatus) {
set({ connectedStatus })
},
setStartAt(callStartAt) {
set({ callStartAt: callStartAt })
},
}))
export const callDataStoreHelper = {

31
src/modules/calls/hooks/use-call-status.hook.ts

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
import { useMemo } from 'react'
import { useCallDataStore } from './use-call-data.hook'
const rtcStatusLabel: Record<RTCIceConnectionState, string> = {
new: "З'єднання",
checking: '',
closed: '',
completed: '',
disconnected: '',
failed: '',
connected: '',
}
export const useCallStatus = () => {
const connectedStatus = useCallDataStore(s => s.connectedStatus)
const label = useMemo(() => {
if (['new', 'checking'].includes(connectedStatus)) {
return "З'єднання"
}
if (['completed', 'connected'].includes(connectedStatus)) {
return null
}
return "З'єднання"
}, [connectedStatus])
return {
connectedStatus,
label,
}
}

72
src/modules/calls/hooks/use-call-streams.hook.ts

@ -1,17 +1,30 @@ @@ -1,17 +1,30 @@
import { useEffect, useMemo, useState } from 'react'
import { MediaStream, mediaDevices } from 'react-native-webrtc'
import { create } from 'zustand'
import { peerConnectionService } from '../services'
import { useEventsListener } from '@/shared'
export interface ICallStreamsStore {
localStream: MediaStream
remoteStream: MediaStream
isMicOn: boolean
isCameraOn: boolean
remoteVideoOn: boolean
setLocalStream: (localStream: MediaStream) => void
setRemoteStream: (remoteStream: MediaStream) => void
setMicOn: (isMicOn: boolean) => void
setCameraOn: (isCameraOn: boolean) => void
setRemoveVideoOn: (removeVideoOn: boolean) => void
}
const callsStreamStore = create<ICallStreamsStore>()(set => ({
localStream: null,
remoteStream: null,
isMicOn: true,
isCameraOn: true,
remoteVideoOn: true,
setLocalStream(localStream) {
set({ localStream })
@ -20,6 +33,17 @@ const callsStreamStore = create<ICallStreamsStore>()(set => ({ @@ -20,6 +33,17 @@ const callsStreamStore = create<ICallStreamsStore>()(set => ({
setRemoteStream(remoteStream) {
set({ remoteStream })
},
setMicOn(isMicOn) {
set({ isMicOn })
},
setCameraOn(isCameraOn) {
set({ isCameraOn })
},
setRemoveVideoOn(remoteVideoOn) {
set({ remoteVideoOn })
},
}))
export const useCallsStream = callsStreamStore
@ -44,3 +68,51 @@ export const initCallsMediaDevices = async (peerConnection: any) => { @@ -44,3 +68,51 @@ export const initCallsMediaDevices = async (peerConnection: any) => {
console.log('eerror')
}
}
export const useLocalStream = () => {
const localMicOn = callsStreamsCtr().isMicOn
const isCameraOn = callsStreamsCtr().isCameraOn
const localStream = callsStreamsCtr().localStream
function toogleMic() {
callsStreamsCtr().setMicOn(!localMicOn)
localStream.getAudioTracks().forEach(track => {
localMicOn ? (track.enabled = false) : (track.enabled = true)
})
peerConnectionService.sendMessage({
type: 'changeMicro',
value: !localMicOn,
})
}
function toogleCamera() {
callsStreamsCtr().setCameraOn(!isCameraOn)
localStream.getVideoTracks().forEach(track => {
isCameraOn ? (track.enabled = false) : (track.enabled = true)
})
peerConnectionService.sendMessage({
type: 'changeVideo',
value: !isCameraOn,
})
}
return {
localMicOn,
localStream,
toogleMic,
isCameraOn,
toogleCamera,
}
}
export const useRemoteStream = () => {
const remoteVideoOn = callsStreamStore(s => s.remoteVideoOn)
useEventsListener('call-channel/changeVideo', ({ value }) => {
console.log('value', value)
callsStreamsCtr().setRemoveVideoOn(value)
})
return { isRemoteCameraOn: remoteVideoOn }
}

2
src/modules/calls/hooks/use-calls-history.hook.ts

@ -6,7 +6,7 @@ import moment from 'moment' @@ -6,7 +6,7 @@ import moment from 'moment'
import { CallTypesEnum } from '../enums'
export interface ICallListItem {
callId: number
callId: string
date: string
title: string
avatarUrl?: string

113
src/modules/calls/screens/call/atoms/calling.atom.tsx

@ -6,99 +6,56 @@ import { RTCView } from 'react-native-webrtc' @@ -6,99 +6,56 @@ import { RTCView } from 'react-native-webrtc'
interface IProps {
localStream: any
remoteStream: any
isRemoteCameraOn?: boolean
}
export const CallingAtom: FC<IProps> = ({ localStream, remoteStream }) => {
export const CallingAtom: FC<IProps> = ({
localStream,
remoteStream,
isRemoteCameraOn,
}) => {
return (
<View
style={{
flex: 1,
backgroundColor: '#000',
// backgroundColor: '#000',
position: 'relative',
}}>
{localStream ? (
<RTCView
objectFit={'cover'}
<View
style={{
backgroundColor: '#050A0E',
width: 100,
height: 100,
}}
streamURL={localStream.toURL()}
/>
position: 'absolute',
top: 50,
right: 0,
zIndex: 99,
}}>
<RTCView
objectFit={'cover'}
style={{
backgroundColor: '#050A0E',
width: 100,
height: 100,
}}
streamURL={localStream.toURL()}
/>
</View>
) : null}
{remoteStream ? (
<RTCView
objectFit={'cover'}
style={{
flex: 1,
}}
style={
isRemoteCameraOn
? {
flex: 1,
}
: {
opacity: 0,
width: 1,
height: 1,
}
}
streamURL={remoteStream.toURL()}
/>
) : null}
{/* <View
style={{
marginVertical: 12,
flexDirection: 'row',
justifyContent: 'space-evenly',
}}>
<IconContainer
backgroundColor={'red'}
onPress={() => {
leave()
}}
Icon={() => {
return <CallEnd height={26} width={26} fill="#FFF" />
}}
/>
<IconContainer
style={{
borderWidth: 1.5,
borderColor: '#2B3034',
}}
backgroundColor={!localMicOn ? '#fff' : 'transparent'}
onPress={() => {
toggleMic()
}}
Icon={() => {
return localMicOn ? (
<MicOn height={24} width={24} fill="#FFF" />
) : (
<MicOff height={28} width={28} fill="#1D2939" />
)
}}
/>
<IconContainer
style={{
borderWidth: 1.5,
borderColor: '#2B3034',
}}
backgroundColor={!localWebcamOn ? '#fff' : 'transparent'}
onPress={() => {
toggleCamera()
}}
Icon={() => {
return localWebcamOn ? (
<VideoOn height={24} width={24} fill="#FFF" />
) : (
<VideoOff height={36} width={36} fill="#1D2939" />
)
}}
/>
<IconContainer
style={{
borderWidth: 1.5,
borderColor: '#2B3034',
}}
backgroundColor={'transparent'}
onPress={() => {
switchCamera()
}}
Icon={() => {
return (
<CameraSwitch height={24} width={24} fill="#FFF" />
)
}}
/>
</View> */}
</View>
)
}

66
src/modules/calls/screens/call/index.tsx

@ -5,42 +5,81 @@ import { @@ -5,42 +5,81 @@ import {
CallMod,
useCallDataStore,
useCallFromStore,
useCallStatus,
useCallsStream,
useLocalStream,
useRemoteStream,
} from '../../hooks'
import { CallBackground, CallBtn } from '../../components'
import { Dimensions, Modal, StatusBar, StyleSheet, View } from 'react-native'
import { callService } from '../../services'
import { Timmer } from '@/shared/components/plugins/timmer.component'
export const CallScreen = () => {
const mod = useCallDataStore(s => s.mod)
const startTime = useCallDataStore(s => s.callStartAt)
const { remoteStream, localStream } = useCallsStream()
const { title, avatarImageUrl } = useCallFromStore()
const connectedStatus = useCallDataStore(s => s.connectedStatus)
const { label } = useCallStatus()
const { toogleMic, localMicOn, isCameraOn, toogleCamera } = useLocalStream()
const { isRemoteCameraOn } = useRemoteStream()
const stopCall = () => {
callService.stop()
}
console.log('isRemoteCameraOn', isRemoteCameraOn)
const templates = {
[CallMod.Speaking]: (
<CallBackground
title={title}
avatarImageUrl={avatarImageUrl}
showAvatar={false}
needOverlay={false}
subtitle={connectedStatus}
showAvatar={isRemoteCameraOn ? false : true}
needOverlay={isRemoteCameraOn ? false : true}
subtitle={label}
subtitleComponent={<Timmer startTime={startTime} />}
fullComponent={
<CallingAtom
localStream={localStream}
localStream={isCameraOn ? localStream : null}
remoteStream={remoteStream}
isRemoteCameraOn={isRemoteCameraOn}
/>
}>
<View style={styles.row}>
<View style={styles.callRow}>
<CallBtn
iconName="speakerhigh"
bgColor="#fff"
isAnimated={false}
onPress={stopCall}
iconColor="#000"
style={styles.callBtn}
/>
<CallBtn
iconName={
isCameraOn ? 'videocamera' : 'videocameraslash'
}
bgColor="#fff"
isAnimated={false}
onPress={toogleCamera}
iconColor="#000"
style={styles.callBtn}
/>
<CallBtn
iconName={localMicOn ? 'microphone' : 'microphoneslash'}
bgColor="#fff"
isAnimated={false}
onPress={toogleMic}
iconColor="#000"
style={styles.callBtn}
/>
<CallBtn
iconName="phone-2"
bgColor="#DE253B"
isAnimated={false}
onPress={stopCall}
style={styles.callBtn}
/>
</View>
</CallBackground>
@ -78,9 +117,6 @@ export const CallScreen = () => { @@ -78,9 +117,6 @@ export const CallScreen = () => {
height: Dimensions.get('screen').height,
}}>
{templates[mod]}
{/* <Txt style={{ color: 'red', fontSize: 50 }}>
{mod} {connectedStatus}
</Txt> */}
</Modal>
<StatusBar hidden />
</>
@ -102,4 +138,14 @@ const styles = StyleSheet.create({ @@ -102,4 +138,14 @@ const styles = StyleSheet.create({
width: '100%',
paddingHorizontal: 30,
},
callRow: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
width: '100%',
paddingHorizontal: 30,
},
callBtn: {
marginHorizontal: 7,
},
})

2
src/modules/calls/services/call.service.ts

@ -7,6 +7,7 @@ import { RouteKey } from '@/shared' @@ -7,6 +7,7 @@ import { RouteKey } from '@/shared'
import { StopCall } from '../core/stop-call'
import { cancelCallReq } from '@/api/calls/requests'
import { RTCSessionDescription } from 'react-native-webrtc'
import { callKeepService } from './callkeep.service'
class CallService extends CallRoot {
public async proccesIncome(data: any) {
@ -47,6 +48,7 @@ class CallService extends CallRoot { @@ -47,6 +48,7 @@ class CallService extends CallRoot {
public async stop() {
new StopCall(useCallDataStore.getState, callsStreamsCtr).stop()
callKeepService.stop()
}
public async finishCall() {

23
src/modules/calls/services/callkeep.service.ts

@ -1,7 +1,11 @@ @@ -1,7 +1,11 @@
import { getIncomeDataReq } from '@/api/calls/requests'
import RNCallKeep from 'react-native-callkeep'
import { CallRoot } from './call-root.service'
import { Platform } from 'react-native'
import { appEvents } from '@/shared'
import { DeviceInfoService } from '@/services/system'
class CallKeepService {
class CallKeepService extends CallRoot {
public register() {
this.init()
this.initListeners()
@ -11,7 +15,8 @@ class CallKeepService { @@ -11,7 +15,8 @@ class CallKeepService {
this.removeListeners()
}
private init() {
private async init() {
RNCallKeep.endAllCalls()
RNCallKeep.setup({
ios: {
appName: 'TaskMe',
@ -55,8 +60,10 @@ class CallKeepService { @@ -55,8 +60,10 @@ class CallKeepService {
private async onAnswer(data: any) {
try {
console.log('ON ANSWER', data)
getIncomeDataReq(data.callUUID)
appEvents.emit('closeConfirmModal', {})
const id = await DeviceInfoService.getDeviceUniqueId()
getIncomeDataReq(data.callUUID, id)
} catch (e) {
console.log('Error on answer', e)
}
@ -71,7 +78,13 @@ class CallKeepService { @@ -71,7 +78,13 @@ class CallKeepService {
}
public async stop() {
RNCallKeep.endCall('')
RNCallKeep.endCall(this.store.callId)
RNCallKeep.endAllCalls()
}
public async handleAcceptedIncomeInOtherDevice(uuid: string) {
RNCallKeep.rejectCall(uuid)
RNCallKeep.endAllCalls()
}
}

8
src/modules/calls/services/calls-events.service.ts

@ -2,9 +2,10 @@ import { RouteKey, socketEvents } from '@/shared' @@ -2,9 +2,10 @@ import { RouteKey, socketEvents } from '@/shared'
import { CallRoot } from './call-root.service'
import { CallMod } from '../hooks'
import { callService } from './call.service'
import { NavigationService } from '@/services/system'
import { DeviceInfoService, NavigationService } from '@/services/system'
import { Alert } from 'react-native'
import { RTCIceCandidate, RTCSessionDescription } from 'react-native-webrtc'
import { callKeepService } from './callkeep.service'
class CallsEventsService extends CallRoot {
constructor() {
@ -40,6 +41,11 @@ class CallsEventsService extends CallRoot { @@ -40,6 +41,11 @@ class CallsEventsService extends CallRoot {
private async proccessNewCall(data) {
console.log('procces new call', data)
const id = await DeviceInfoService.getDeviceUniqueId()
if (data.targetUserDeviceId !== id) {
callKeepService.handleAcceptedIncomeInOtherDevice(data.callId)
return
}
try {
this.storeFrom.put(data.from.title, data.from.avatarImageUrl)

53
src/modules/calls/services/peer-connection.service.ts

@ -9,8 +9,14 @@ import { @@ -9,8 +9,14 @@ import {
useCallDataStore,
} from '../hooks'
import { StopCall } from '../core/stop-call'
import RTCDataChannel from 'react-native-webrtc/lib/typescript/RTCDataChannel'
import { Alert } from 'react-native'
import { appEvents } from '@/shared'
class PeerConnectionService extends CallRoot {
private dataChannel: RTCDataChannel
private remoteDataChannel: RTCDataChannel
public async createIns() {
const peerConnection = new RTCPeerConnection({
iceServers: iceServers,
@ -20,6 +26,8 @@ class PeerConnectionService extends CallRoot { @@ -20,6 +26,8 @@ class PeerConnectionService extends CallRoot {
await this.addListeners(peerConnection)
this.createDataChannel(peerConnection)
return peerConnection
}
@ -49,6 +57,14 @@ class PeerConnectionService extends CallRoot { @@ -49,6 +57,14 @@ class PeerConnectionService extends CallRoot {
peerConnection.addEventListener('iceconnectionstatechange', event => {
this.store.setConnectedStatus(peerConnection.iceConnectionState)
if (
['completed', 'connected'].includes(
peerConnection.iceConnectionState,
)
) {
this.store.setStartAt(new Date().getTime())
}
if (peerConnection.iceConnectionState === 'closed') {
this.store.changeMod(CallMod.Finished)
}
@ -61,6 +77,43 @@ class PeerConnectionService extends CallRoot { @@ -61,6 +77,43 @@ class PeerConnectionService extends CallRoot {
}
})
}
private createDataChannel(peerConnection: RTCPeerConnection) {
peerConnection.addEventListener('datachannel', event => {
const receiveChannel = event.channel
this.remoteDataChannel = receiveChannel
this.remoteDataChannel.addEventListener('message', event => {
this.onMessage(event)
})
})
this.dataChannel = peerConnection.createDataChannel('config_channel')
}
public sendMessage(message: any) {
this.dataChannel.send(JSON.stringify(message))
}
private onMessage(event: any) {
const data = JSON.parse(event.data)
switch (data.type) {
case 'changeMicro': {
break
}
case 'changeVideo': {
appEvents.emit('call-channel/changeVideo', {
value: data.value,
})
break
}
default: {
break
}
}
}
}
export const peerConnectionService = new PeerConnectionService()

1
src/services/system/voip-notification.service.ts

@ -48,6 +48,7 @@ export class VoipNotificationsService { @@ -48,6 +48,7 @@ export class VoipNotificationsService {
deviceUuid,
notificationUserId: this.voipToken,
isVoip: true,
isDev: __DEV__,
})
}, 150)
}

52
src/shared/components/plugins/timmer.component.tsx

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
import React, { FC, useEffect, useState } from 'react'
import { Txt } from '../elements'
import { StyleSheet, View } from 'react-native'
interface IProps {
startTime: number
intervalMs?: number
}
export const Timmer: FC<IProps> = ({ startTime, intervalMs = 1000 }) => {
const [label, setLabel] = useState<string>('00:00')
const formatMilliseconds = milliseconds => {
const totalSeconds = Math.floor(milliseconds / 1000)
const minutes = Math.floor(totalSeconds / 60)
const seconds = totalSeconds % 60
// Форматування часу
const formattedTime = `${minutes.toString().padStart(2, '0')}:${seconds
.toString()
.padStart(2, '0')}`
return formattedTime
}
const calcLabel = () => {
const difference = new Date().getTime() - startTime
setLabel(formatMilliseconds(difference))
}
useEffect(() => {
const timer = setInterval(() => {
calcLabel()
}, intervalMs)
return () => clearInterval(timer)
}, [startTime])
return (
<View style={styles.container}>
<Txt style={styles.label}>{label}</Txt>
</View>
)
}
const styles = StyleSheet.create({
container: {},
label: {
color: '#fff',
fontSize: 20,
},
})

4
src/shared/events/index.ts

@ -154,6 +154,9 @@ export type AppEvents = { @@ -154,6 +154,9 @@ export type AppEvents = {
fileUrl: string
mimeType: FileType
}
'call-channel/changeVideo': {
value: boolean
}
}
export type SocketEvents = {
@ -225,6 +228,7 @@ export type SocketEvents = { @@ -225,6 +228,7 @@ export type SocketEvents = {
callerId: number
rtcMessage: any
callId: string
targetUserDeviceId: string
from: {
type: 'personal'
title: string

2
src/shared/interfaces/call.inteface.ts

@ -2,7 +2,7 @@ import { CallStatus } from '../enums' @@ -2,7 +2,7 @@ import { CallStatus } from '../enums'
import { IUser } from './user.interfaces'
export interface ICall {
id: number
id: string
usersIds: number[]
initiatorUserId: number
finishedAt: string

Loading…
Cancel
Save