agora-appbuilder-core 2.0.2 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/Readme.md +2 -1
  2. package/package.json +1 -1
  3. package/template/_package-lock.json +864 -684
  4. package/template/agora-rn-uikit/.git/index +0 -0
  5. package/template/agora-rn-uikit/.git/logs/HEAD +2 -2
  6. package/template/agora-rn-uikit/.git/logs/refs/heads/ab-dev-auto +1 -1
  7. package/template/agora-rn-uikit/.git/logs/refs/heads/master +1 -1
  8. package/template/agora-rn-uikit/.git/logs/refs/remotes/origin/HEAD +1 -1
  9. package/template/agora-rn-uikit/.git/objects/pack/pack-9181e9e59978901afdcfb1d244e221810fd813e3.idx +0 -0
  10. package/template/agora-rn-uikit/.git/objects/pack/{pack-f379286d0537eb68377220b4929979324b8d5d1c.pack → pack-9181e9e59978901afdcfb1d244e221810fd813e3.pack} +0 -0
  11. package/template/agora-rn-uikit/.git/packed-refs +4 -2
  12. package/template/agora-rn-uikit/.git/refs/heads/ab-dev-auto +1 -1
  13. package/template/agora-rn-uikit/src/Contexts/PropsContext.tsx +21 -0
  14. package/template/agora-rn-uikit/src/Controls/BtnTemplate.tsx +22 -14
  15. package/template/agora-rn-uikit/src/Controls/ImageIcon.tsx +17 -13
  16. package/template/agora-rn-uikit/src/Controls/types.ts +4 -0
  17. package/template/agora-rn-uikit/src/Rtc/Create.tsx +117 -19
  18. package/template/agora-rn-uikit/src/RtcConfigure.tsx +24 -13
  19. package/template/{src/utils/isSafariBrowser.tsx → agora-rn-uikit/src/Utils/isSafariBrowser.ts} +3 -0
  20. package/template/{src → agora-rn-uikit/src}/hooks/useImageDelay.tsx +5 -2
  21. package/template/agora-rn-uikit/src/index.ts +2 -0
  22. package/template/bridge/rtc/webNg/RtcEngine.ts +73 -70
  23. package/template/bridge/rtc/webNg/Types.ts +59 -5
  24. package/template/bridge/rtm/web/Types.ts +13 -0
  25. package/template/bridge/rtm/web/index.ts +78 -1
  26. package/template/global.d.ts +2 -0
  27. package/template/package-lock.json +864 -684
  28. package/template/package.json +2 -3
  29. package/template/react-native-toast-message/src/components/base/styles.js +4 -2
  30. package/template/src/assets/icons.ts +41 -28
  31. package/template/src/components/Chat.tsx +70 -184
  32. package/template/src/components/ChatContext.ts +13 -2
  33. package/template/src/components/Controls.native.tsx +37 -76
  34. package/template/src/components/Controls.tsx +50 -158
  35. package/template/src/components/DeviceConfigure.native.tsx +5 -1
  36. package/template/src/components/DeviceConfigure.tsx +38 -20
  37. package/template/src/components/Navbar.tsx +185 -226
  38. package/template/src/components/ParticipantsView.tsx +176 -184
  39. package/template/src/components/Precall.native.tsx +83 -69
  40. package/template/src/components/Precall.tsx +174 -191
  41. package/template/src/components/RTMConfigure.tsx +264 -78
  42. package/template/src/components/SettingsView.tsx +9 -19
  43. package/template/src/components/livestream/LiveStreamContext.tsx +411 -0
  44. package/template/src/components/livestream/Types.ts +69 -0
  45. package/template/src/components/livestream/index.ts +9 -0
  46. package/template/src/components/livestream/views/LiveStreamControls.tsx +27 -0
  47. package/template/src/components/participants/AllAudienceParticipants.tsx +53 -0
  48. package/template/src/components/participants/AllHostParticipants.tsx +65 -0
  49. package/template/src/components/participants/MeParticipant.tsx +37 -0
  50. package/template/src/components/participants/ParticipantName.tsx +47 -0
  51. package/template/src/components/participants/ParticipantSectionTitle.tsx +29 -0
  52. package/template/src/components/participants/RemoteParticipants.tsx +69 -0
  53. package/template/src/components/participants/ScreenshareParticipants.tsx +28 -0
  54. package/template/src/components/participants/context/ParticipantContext.tsx +97 -0
  55. package/template/src/components/styles.ts +13 -0
  56. package/template/src/pages/Create.tsx +25 -14
  57. package/template/src/pages/VideoCall.tsx +197 -159
  58. package/template/src/subComponents/ChatBubble.tsx +4 -1
  59. package/template/src/subComponents/ChatContainer.tsx +44 -20
  60. package/template/src/subComponents/ChatInput.tsx +4 -12
  61. package/template/src/subComponents/Checkbox.native.tsx +6 -5
  62. package/template/src/subComponents/Checkbox.tsx +1 -0
  63. package/template/src/subComponents/Recording.tsx +23 -9
  64. package/template/src/subComponents/RemoteVideoMute.tsx +2 -3
  65. package/template/src/subComponents/SelectDevice.tsx +70 -35
  66. package/template/src/subComponents/chat/ChatParticipants.tsx +121 -0
  67. package/template/src/subComponents/livestream/ApprovedLiveStreamControlsView.tsx +23 -0
  68. package/template/src/subComponents/livestream/CurrentLiveStreamRequestsView.tsx +70 -0
  69. package/template/src/subComponents/livestream/controls/LocalRaiseHand.tsx +57 -0
  70. package/template/src/subComponents/livestream/controls/RemoteLiveStreamApprovedRequestRecall.tsx +24 -0
  71. package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestApprove.tsx +38 -0
  72. package/template/src/subComponents/livestream/controls/RemoteLiveStreamRequestReject.tsx +37 -0
  73. package/template/src/subComponents/livestream/index.ts +18 -0
  74. package/template/src/subComponents/screenshare/ScreenshareButton.tsx +80 -0
  75. package/template/src/subComponents/screenshare/ScreenshareConfigure.native.tsx +24 -0
  76. package/template/src/subComponents/screenshare/ScreenshareConfigure.tsx +200 -0
  77. package/template/src/subComponents/screenshare/ScreenshareContext.tsx +21 -0
  78. package/template/src/utils/index.tsx +48 -0
  79. package/template/agora-rn-uikit/.git/objects/pack/pack-f379286d0537eb68377220b4929979324b8d5d1c.idx +0 -0
@@ -12,8 +12,12 @@
12
12
  import React, {useState, useContext, useEffect} from 'react';
13
13
  import {View, StyleSheet, Text, Platform} from 'react-native';
14
14
 
15
- import {RtcConfigure} from '../../agora-rn-uikit';
16
- import {PropsProvider} from '../../agora-rn-uikit';
15
+ import {
16
+ RtcConfigure,
17
+ PropsProvider,
18
+ ClientRole,
19
+ ChannelProfile,
20
+ } from '../../agora-rn-uikit';
17
21
  import Navbar from '../components/Navbar';
18
22
  import Precall from '../components/Precall';
19
23
  import ParticipantsView from '../components/ParticipantsView';
@@ -27,7 +31,6 @@ import Chat from '../components/Chat';
27
31
  import RtmConfigure from '../components/RTMConfigure';
28
32
  import DeviceConfigure from '../components/DeviceConfigure';
29
33
  import {gql, useQuery} from '@apollo/client';
30
- // import Watermark from '../subComponents/Watermark';
31
34
  import StorageContext from '../components/StorageContext';
32
35
  import Logo from '../subComponents/Logo';
33
36
  import hasBrandLogo from '../utils/hasBrandLogo';
@@ -40,12 +43,14 @@ import {videoView} from '../../theme.json';
40
43
  import Layout from '../subComponents/LayoutEnum';
41
44
  import Toast from '../../react-native-toast-message';
42
45
  import {NetworkQualityProvider} from '../components/NetworkQualityContext';
46
+ import {LiveStreamContextProvider} from '../components/livestream';
47
+ import ScreenshareConfigure from '../subComponents/screenshare/ScreenshareConfigure';
43
48
 
44
49
  const useChatNotification = (
45
50
  messageStore: string | any[],
46
51
  privateMessageStore: string | any[],
47
52
  chatDisplayed: boolean,
48
- isPrivateChatDisplayed: boolean
53
+ isPrivateChatDisplayed: boolean,
49
54
  ) => {
50
55
  // store the last checked state from the messagestore, to identify unread messages
51
56
  const [lastCheckedPublicState, setLastCheckedPublicState] = useState(0);
@@ -54,7 +59,7 @@ const useChatNotification = (
54
59
  if (chatDisplayed && !isPrivateChatDisplayed) {
55
60
  setLastCheckedPublicState(messageStore.length);
56
61
  }
57
- }, [messageStore,isPrivateChatDisplayed]);
62
+ }, [messageStore, isPrivateChatDisplayed]);
58
63
 
59
64
  const setPrivateMessageLastSeen = ({userId, lastSeenCount}) => {
60
65
  setLastCheckedPrivateState((prevState) => {
@@ -70,7 +75,12 @@ const useChatNotification = (
70
75
  ];
71
76
  };
72
77
 
73
- const NotificationControl = ({children, chatDisplayed, setSidePanel, isPrivateChatDisplayed}) => {
78
+ const NotificationControl = ({
79
+ children,
80
+ chatDisplayed,
81
+ setSidePanel,
82
+ isPrivateChatDisplayed,
83
+ }) => {
74
84
  const {messageStore, privateMessageStore, userList, localUid, events} =
75
85
  useContext(ChatContext);
76
86
  const [
@@ -79,7 +89,12 @@ const NotificationControl = ({children, chatDisplayed, setSidePanel, isPrivateCh
79
89
  lastCheckedPrivateState,
80
90
  setLastCheckedPrivateState,
81
91
  setPrivateMessageLastSeen,
82
- ] = useChatNotification(messageStore, privateMessageStore, chatDisplayed, isPrivateChatDisplayed);
92
+ ] = useChatNotification(
93
+ messageStore,
94
+ privateMessageStore,
95
+ chatDisplayed,
96
+ isPrivateChatDisplayed,
97
+ );
83
98
 
84
99
  const pendingPublicNotification =
85
100
  messageStore.length - lastCheckedPublicState;
@@ -246,7 +261,7 @@ const VideoCall: React.FC = () => {
246
261
  const [chatDisplayed, setChatDisplayed] = useState(false);
247
262
  const [queryComplete, setQueryComplete] = useState(false);
248
263
  const [sidePanel, setSidePanel] = useState<SidePanelType>(SidePanelType.None);
249
- const [isPrivateChatDisplayed, setPrivateChatDisplayed] = useState(false)
264
+ const [isPrivateChatDisplayed, setPrivateChatDisplayed] = useState(false);
250
265
  const {phrase} = useParams();
251
266
  const [errorMessage, setErrorMessage] = useState(null);
252
267
  const [isHost, setIsHost] = React.useState(false);
@@ -264,6 +279,7 @@ const VideoCall: React.FC = () => {
264
279
  encryption: $config.ENCRYPTION_ENABLED
265
280
  ? {key: null, mode: RnEncryptionEnum.AES128XTS, screenKey: null}
266
281
  : false,
282
+ role: ClientRole.Broadcaster,
267
283
  });
268
284
 
269
285
  const {data, loading, error} = useQuery(
@@ -281,6 +297,7 @@ const VideoCall: React.FC = () => {
281
297
  // console.log('error data', data);
282
298
  if (!errorMessage) {
283
299
  setErrorMessage(error);
300
+ queryComplete ? {} : setQueryComplete(true);
284
301
  }
285
302
  return;
286
303
  }
@@ -305,9 +322,13 @@ const VideoCall: React.FC = () => {
305
322
  : false,
306
323
  screenShareUid: data.joinChannel.screenShare.uid,
307
324
  screenShareToken: data.joinChannel.screenShare.rtc,
325
+ role: data.joinChannel.isHost
326
+ ? ClientRole.Broadcaster
327
+ : ClientRole.Audience,
308
328
  });
309
329
  setIsHost(data.joinChannel.isHost);
310
330
  setTitle(data.joinChannel.title);
331
+
311
332
  console.log('query done: ', data, queryComplete);
312
333
  // 1. Store the display name from API
313
334
  if (data.getUser) {
@@ -333,168 +354,184 @@ const VideoCall: React.FC = () => {
333
354
  }
334
355
  }, [username]);
335
356
 
336
- // throw new Error("My first Sentry error!");
337
357
  return (
338
358
  <>
339
- {queryComplete || !callActive ? (
340
- <>
341
- <PropsProvider
342
- value={{
343
- rtcProps: {
344
- ...rtcProps,
345
- callActive,
346
- },
347
- callbacks,
348
- styleProps,
349
- }}>
350
- <RtcConfigure>
351
- <DeviceConfigure>
352
- <RtmConfigure
353
- setRecordingActive={setRecordingActive}
354
- name={username}
355
- callActive={callActive}>
356
- {callActive ? (
357
- <View style={style.full}>
358
- <NotificationControl
359
- setSidePanel={setSidePanel}
360
- chatDisplayed={sidePanel === SidePanelType.Chat}
361
- isPrivateChatDisplayed={isPrivateChatDisplayed}
362
- >
363
- {({
364
- pendingPublicNotification,
365
- pendingPrivateNotification,
366
- setLastCheckedPublicState,
367
- lastCheckedPublicState,
368
- lastCheckedPrivateState,
369
- setLastCheckedPrivateState,
370
- privateMessageCountMap,
371
- setPrivateMessageLastSeen,
372
- }) => (
373
- <>
374
- <Navbar
375
- sidePanel={sidePanel}
359
+ {queryComplete ? (
360
+ queryComplete || !callActive ? (
361
+ <>
362
+ <PropsProvider
363
+ value={{
364
+ rtcProps: {
365
+ ...rtcProps,
366
+ callActive,
367
+ },
368
+ callbacks,
369
+ styleProps,
370
+ mode: $config.EVENT_MODE
371
+ ? ChannelProfile.LiveBroadcasting
372
+ : ChannelProfile.Communication,
373
+ }}>
374
+ <RtcConfigure>
375
+ <DeviceConfigure userRole={rtcProps.role}>
376
+ <RtmConfigure
377
+ setRecordingActive={setRecordingActive}
378
+ name={username}
379
+ callActive={callActive}>
380
+ <ScreenshareConfigure
381
+ setLayout={setLayout}
382
+ recordingActive={recordingActive}>
383
+ <LiveStreamContextProvider
384
+ setRtcProps={setRtcProps}
385
+ isHost={isHost}>
386
+ {callActive ? (
387
+ <View style={style.full}>
388
+ <NotificationControl
376
389
  setSidePanel={setSidePanel}
377
- layout={layout}
378
- setLayout={setLayout}
379
- recordingActive={recordingActive}
380
- setRecordingActive={setRecordingActive}
381
- isHost={isHost}
382
- title={title}
383
- pendingMessageLength={
384
- pendingPublicNotification +
385
- pendingPrivateNotification
386
- }
387
- setLastCheckedPublicState={
388
- setLastCheckedPublicState
389
- }
390
- />
391
- <NetworkQualityProvider>
392
- <View
393
- style={[
394
- style.videoView,
395
- {backgroundColor: '#ffffff00'},
396
- ]}>
397
- {layout === Layout.Pinned ? (
398
- <PinnedVideo />
399
- ) : (
400
- <GridVideo setLayout={setLayout} />
401
- )}
402
- {sidePanel === SidePanelType.Participants ? (
403
- <ParticipantsView
404
- isHost={isHost}
405
- // setParticipantsView={setParticipantsView}
390
+ chatDisplayed={sidePanel === SidePanelType.Chat}
391
+ isPrivateChatDisplayed={isPrivateChatDisplayed}>
392
+ {({
393
+ pendingPublicNotification,
394
+ pendingPrivateNotification,
395
+ setLastCheckedPublicState,
396
+ lastCheckedPublicState,
397
+ lastCheckedPrivateState,
398
+ setLastCheckedPrivateState,
399
+ privateMessageCountMap,
400
+ setPrivateMessageLastSeen,
401
+ }) => (
402
+ <>
403
+ <Navbar
404
+ sidePanel={sidePanel}
406
405
  setSidePanel={setSidePanel}
406
+ layout={layout}
407
+ setLayout={setLayout}
408
+ recordingActive={recordingActive}
409
+ setRecordingActive={setRecordingActive}
410
+ isHost={isHost}
411
+ title={title}
412
+ pendingMessageLength={
413
+ pendingPublicNotification +
414
+ pendingPrivateNotification
415
+ }
416
+ setLastCheckedPublicState={
417
+ setLastCheckedPublicState
418
+ }
407
419
  />
408
- ) : (
409
- <></>
410
- )}
411
- {sidePanel === SidePanelType.Chat ? (
412
- $config.CHAT ? (
413
- <Chat
414
- setPrivateChatDisplayed={setPrivateChatDisplayed}
415
- privateMessageCountMap={
416
- privateMessageCountMap
417
- }
418
- pendingPublicNotification={
419
- pendingPublicNotification
420
- }
421
- pendingPrivateNotification={
420
+ <NetworkQualityProvider>
421
+ <View
422
+ style={[
423
+ style.videoView,
424
+ {backgroundColor: '#ffffff00'},
425
+ ]}>
426
+ {layout === Layout.Pinned ? (
427
+ <PinnedVideo />
428
+ ) : (
429
+ <GridVideo setLayout={setLayout} />
430
+ )}
431
+ {sidePanel ===
432
+ SidePanelType.Participants ? (
433
+ <ParticipantsView
434
+ isHost={isHost}
435
+ // setParticipantsView={setParticipantsView}
436
+ setSidePanel={setSidePanel}
437
+ />
438
+ ) : (
439
+ <></>
440
+ )}
441
+ {sidePanel === SidePanelType.Chat ? (
442
+ $config.CHAT ? (
443
+ <Chat
444
+ setPrivateChatDisplayed={
445
+ setPrivateChatDisplayed
446
+ }
447
+ privateMessageCountMap={
448
+ privateMessageCountMap
449
+ }
450
+ pendingPublicNotification={
451
+ pendingPublicNotification
452
+ }
453
+ pendingPrivateNotification={
454
+ pendingPrivateNotification
455
+ }
456
+ setPrivateMessageLastSeen={
457
+ setPrivateMessageLastSeen
458
+ }
459
+ lastCheckedPrivateState={
460
+ lastCheckedPrivateState
461
+ }
462
+ />
463
+ ) : (
464
+ <></>
465
+ )
466
+ ) : (
467
+ <></>
468
+ )}
469
+ {sidePanel === SidePanelType.Settings ? (
470
+ <SettingsView
471
+ isHost={isHost}
472
+ // setParticipantsView={setParticipantsView}
473
+ setSidePanel={setSidePanel}
474
+ />
475
+ ) : (
476
+ <></>
477
+ )}
478
+ </View>
479
+ </NetworkQualityProvider>
480
+ {Platform.OS !== 'web' &&
481
+ sidePanel === SidePanelType.Chat ? (
482
+ <></>
483
+ ) : (
484
+ <Controls
485
+ setLayout={setLayout}
486
+ recordingActive={recordingActive}
487
+ setRecordingActive={setRecordingActive}
488
+ // chatDisplayed={chatDisplayed}
489
+ // setChatDisplayed={setChatDisplayed}
490
+ isHost={isHost}
491
+ // participantsView={participantsView}
492
+ // setParticipantsView={setParticipantsView}
493
+ sidePanel={sidePanel}
494
+ setSidePanel={setSidePanel}
495
+ pendingMessageLength={
496
+ pendingPublicNotification +
422
497
  pendingPrivateNotification
423
498
  }
424
- setPrivateMessageLastSeen={
425
- setPrivateMessageLastSeen
426
- }
427
- lastCheckedPrivateState={
428
- lastCheckedPrivateState
499
+ setLastCheckedPublicState={
500
+ setLastCheckedPublicState
429
501
  }
430
502
  />
431
- ) : (
432
- <></>
433
- )
434
- ) : (
435
- <></>
436
- )}
437
- {sidePanel === SidePanelType.Settings ? (
438
- <SettingsView
439
- isHost={isHost}
440
- // setParticipantsView={setParticipantsView}
441
- setSidePanel={setSidePanel}
442
- />
443
- ) : (
444
- <></>
445
- )}
446
- </View>
447
- </NetworkQualityProvider>
448
- {Platform.OS !== 'web' &&
449
- sidePanel === SidePanelType.Chat ? (
450
- <></>
451
- ) : (
452
- <Controls
453
- setLayout={setLayout}
454
- recordingActive={recordingActive}
455
- setRecordingActive={setRecordingActive}
456
- // chatDisplayed={chatDisplayed}
457
- // setChatDisplayed={setChatDisplayed}
458
- isHost={isHost}
459
- // participantsView={participantsView}
460
- // setParticipantsView={setParticipantsView}
461
- sidePanel={sidePanel}
462
- setSidePanel={setSidePanel}
463
- pendingMessageLength={
464
- pendingPublicNotification +
465
- pendingPrivateNotification
466
- }
467
- setLastCheckedPublicState={
468
- setLastCheckedPublicState
469
- }
470
- />
471
- )}
472
- </>
503
+ )}
504
+ </>
505
+ )}
506
+ </NotificationControl>
507
+ </View>
508
+ ) : $config.PRECALL ? (
509
+ <Precall
510
+ error={errorMessage}
511
+ username={username}
512
+ setUsername={setUsername}
513
+ setCallActive={setCallActive}
514
+ queryComplete={queryComplete}
515
+ title={title}
516
+ />
517
+ ) : (
518
+ <></>
473
519
  )}
474
- </NotificationControl>
475
- </View>
476
- ) : $config.PRECALL ? (
477
- <Precall
478
- error={errorMessage}
479
- username={username}
480
- setUsername={setUsername}
481
- setCallActive={setCallActive}
482
- queryComplete={queryComplete}
483
- title={title}
484
- />
485
- ) : (
486
- <></>
487
- )}
488
- </RtmConfigure>
489
- </DeviceConfigure>
490
- </RtcConfigure>
491
- </PropsProvider>
492
- </>
520
+ </LiveStreamContextProvider>
521
+ </ScreenshareConfigure>
522
+ </RtmConfigure>
523
+ </DeviceConfigure>
524
+ </RtcConfigure>
525
+ </PropsProvider>
526
+ </>
527
+ ) : (
528
+ <View style={style.loader}>
529
+ <View style={style.loaderLogo}>{hasBrandLogo && <Logo />}</View>
530
+ <Text style={style.loaderText}>Starting Call. Just a second.</Text>
531
+ </View>
532
+ )
493
533
  ) : (
494
- <View style={style.loader}>
495
- <View style={style.loaderLogo}>{hasBrandLogo && <Logo />}</View>
496
- <Text style={style.loaderText}>Starting Call. Just a second.</Text>
497
- </View>
534
+ <></>
498
535
  )}
499
536
  </>
500
537
  );
@@ -519,6 +556,7 @@ const styleProps = {
519
556
  muteRemoteVideo: styles.remoteButton,
520
557
  remoteSwap: styles.remoteButton,
521
558
  minCloseBtnStyles: styles.minCloseBtn,
559
+ liveStreamHostControlBtns: styles.liveStreamHostControlBtns,
522
560
  },
523
561
  BtnStyles: styles.remoteButton,
524
562
  };
@@ -19,7 +19,10 @@ const ChatBubble = (props: channelMessage) => {
19
19
  const {userList} = useContext(ChatContext);
20
20
  const {primaryColor} = useContext(ColorContext);
21
21
  let {isLocal, msg, ts, uid} = props;
22
- let time = new Date(ts).getHours() + ':' + new Date(ts).getMinutes();
22
+ let time =
23
+ new Date(parseInt(ts)).getHours() +
24
+ ':' +
25
+ new Date(parseInt(ts)).getMinutes();
23
26
  const handleUrl = (url: string) => {
24
27
  if (Platform.OS === 'web') {
25
28
  window.open(url, '_blank');
@@ -13,12 +13,10 @@ import React, {useContext, useRef} from 'react';
13
13
  import {
14
14
  View,
15
15
  ScrollView,
16
- Text,
17
- TouchableOpacity,
18
16
  StyleSheet,
19
- Image,
20
17
  Platform,
21
- useWindowDimensions
18
+ Text,
19
+ useWindowDimensions,
22
20
  } from 'react-native';
23
21
  import {RFValue} from 'react-native-responsive-fontsize';
24
22
  import ChatBubble from './ChatBubble';
@@ -32,14 +30,17 @@ import TextWithTooltip from './TextWithTooltip';
32
30
  * and maps it to a ChatBubble
33
31
  */
34
32
  const ChatContainer = (props: any) => {
33
+ const {userList} = useContext(ChatContext);
35
34
  const {height, width} = useWindowDimensions();
36
- const {selectedUser, privateActive, setPrivateActive, selectedUsername} =
35
+ const {selectedUserID, privateActive, setPrivateActive, selectedUsername} =
37
36
  props;
38
37
  const {messageStore, localUid, privateMessageStore} = useContext(ChatContext);
38
+
39
39
  const scrollViewRef = useRef<ScrollView>(null);
40
+
40
41
  return (
41
42
  <View style={style.containerView}>
42
- {privateActive ? (
43
+ {privateActive && (
43
44
  <View style={style.row}>
44
45
  <View style={style.backButton}>
45
46
  <BtnTemplate
@@ -48,12 +49,19 @@ const ChatContainer = (props: any) => {
48
49
  name={'backBtn'}
49
50
  />
50
51
  </View>
51
- <View style={{flex:1}}>
52
- <TextWithTooltip style={[style.name, {flexShrink: 1,fontSize: RFValue(16, height > width ? height : width)}]} value={selectedUsername} />
52
+ <View style={{flex: 1}}>
53
+ <TextWithTooltip
54
+ style={[
55
+ style.name,
56
+ {
57
+ flexShrink: 1,
58
+ fontSize: RFValue(16, height > width ? height : width),
59
+ },
60
+ ]}
61
+ value={selectedUsername}
62
+ />
53
63
  </View>
54
64
  </View>
55
- ) : (
56
- <></>
57
65
  )}
58
66
  <ScrollView
59
67
  ref={scrollViewRef}
@@ -72,8 +80,8 @@ const ChatContainer = (props: any) => {
72
80
  />
73
81
  );
74
82
  })
75
- ) : privateMessageStore[selectedUser.uid] ? (
76
- privateMessageStore[selectedUser.uid].map((message: any) => {
83
+ ) : privateMessageStore[selectedUserID] ? (
84
+ privateMessageStore[selectedUserID].map((message: any) => {
77
85
  return (
78
86
  <ChatBubble
79
87
  isLocal={localUid === message.uid}
@@ -87,6 +95,11 @@ const ChatContainer = (props: any) => {
87
95
  ) : (
88
96
  <></>
89
97
  )}
98
+ {userList[selectedUserID]?.offline && (
99
+ <View style={style.infoTextView}>
100
+ <Text style={style.infoText}>User is offline</Text>
101
+ </View>
102
+ )}
90
103
  </ScrollView>
91
104
  </View>
92
105
  );
@@ -97,16 +110,16 @@ const style = StyleSheet.create({
97
110
  row: {
98
111
  flexDirection: 'row',
99
112
  marginTop: 2,
100
- alignItems: 'center',
113
+ alignItems: 'baseline',
101
114
  paddingVertical: 10,
102
115
  ...Platform.select({
103
- android:{
104
- height: 40
116
+ android: {
117
+ height: 40,
118
+ },
119
+ ios: {
120
+ height: 40,
105
121
  },
106
- ios:{
107
- height: 40
108
- }
109
- })
122
+ }),
110
123
  },
111
124
  backButton: {
112
125
  marginHorizontal: 10,
@@ -117,11 +130,22 @@ const style = StyleSheet.create({
117
130
  fontWeight: Platform.OS === 'web' ? '500' : '700',
118
131
  color: $config.PRIMARY_FONT_COLOR,
119
132
  textAlign: 'left',
120
- marginRight: 10
133
+ marginRight: 10,
121
134
  },
122
135
  backIcon: {
123
136
  width: 20,
124
137
  height: 20,
125
138
  },
139
+ infoTextView: {
140
+ marginVertical: 2,
141
+ flexDirection: 'row',
142
+ },
143
+ infoText: {
144
+ color: $config.PRIMARY_FONT_COLOR + '60',
145
+ fontWeight: '500',
146
+ fontSize: 14,
147
+ flex: 1,
148
+ textAlign: 'center',
149
+ },
126
150
  });
127
151
  export default ChatContainer;
@@ -31,15 +31,11 @@ const ChatInput = (props: any) => {
31
31
  const {primaryColor} = useContext(ColorContext);
32
32
  const [message, onChangeMessage] = useState('');
33
33
  // const [height, setHeight] = useState(0);
34
- const {privateActive, selectedUser} = props;
34
+ const {privateActive, selectedUserID} = props;
35
35
  const {sendMessage, sendMessageToUid} = useContext(ChatContext);
36
36
 
37
37
  return (
38
- <View
39
- style={[
40
- style.inputView,
41
- {borderColor: primaryColor, height: 40}
42
- ]}>
38
+ <View style={[style.inputView, {borderColor: primaryColor, height: 40}]}>
43
39
  <TextInput
44
40
  value={message}
45
41
  // onContentSizeChange={(event) => {
@@ -64,13 +60,10 @@ const ChatInput = (props: any) => {
64
60
  if (!privateActive) {
65
61
  sendMessage(message);
66
62
  onChangeMessage('');
67
- // setHeight(40);
68
63
  } else {
69
- sendMessageToUid(message, selectedUser.uid);
64
+ sendMessageToUid(message, selectedUserID);
70
65
  onChangeMessage('');
71
- // setHeight(40);
72
66
  }
73
- // UIManager.focus(inputRef.current);
74
67
  }}
75
68
  placeholder="Type your message.."
76
69
  placeholderTextColor={$config.PRIMARY_FONT_COLOR}
@@ -84,7 +77,7 @@ const ChatInput = (props: any) => {
84
77
  onChangeMessage('');
85
78
  // setHeight(40);
86
79
  } else {
87
- sendMessageToUid(message, selectedUser.uid);
80
+ sendMessageToUid(message, selectedUserID);
88
81
  onChangeMessage('');
89
82
  // setHeight(40);
90
83
  }
@@ -116,7 +109,6 @@ const style = StyleSheet.create({
116
109
  },
117
110
  chatInputButton: {
118
111
  width: 30,
119
- // width: '10%',
120
112
  marginRight: 0,
121
113
  height: 30,
122
114
  borderRadius: 30,
@@ -22,13 +22,14 @@ const Checkbox = (props: any) => {
22
22
  <CheckBox
23
23
  value={urlCheckbox}
24
24
  onValueChange={setUrlCheckbox}
25
+ disabled={props?.disabled}
25
26
  tintColors={{
26
- true: $config.PRIMARY_COLOR,
27
- false: $config.PRIMARY_FONT_COLOR + 80,
27
+ true: props?.disabled ? 'grey' : $config.PRIMARY_COLOR,
28
+ false: props?.disabled ? 'grey' : $config.PRIMARY_FONT_COLOR + 80,
28
29
  }}
29
- tintColor={$config.PRIMARY_FONT_COLOR + 80}
30
- onCheckColor={$config.PRIMARY_COLOR}
31
- onTintColor={$config.PRIMARY_COLOR}
30
+ tintColor={props?.disabled ? 'grey' : $config.PRIMARY_FONT_COLOR + 80}
31
+ onCheckColor={props?.disabled ? 'grey' : $config.PRIMARY_COLOR}
32
+ onTintColor={props?.disabled ? 'grey' : $config.PRIMARY_COLOR}
32
33
  />
33
34
  );
34
35
  };