Skip to content

Commit 71473dc

Browse files
compose_box: Add video call button in compose box
1 parent 3333cdd commit 71473dc

File tree

3 files changed

+157
-46
lines changed

3 files changed

+157
-46
lines changed

lib/widgets/compose_box.dart

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,63 @@ Future<void> _uploadFiles({
10311031
}
10321032
}
10331033

1034+
class _AttachVideoChatUrlButton extends StatelessWidget {
1035+
const _AttachVideoChatUrlButton({
1036+
required this.controller,
1037+
required this.enabled,
1038+
});
1039+
1040+
final ComposeBoxController controller;
1041+
final bool enabled;
1042+
1043+
static const int jitsi = 1;
1044+
static const int zoom = 2; //TODO: Add other supported video chat providers
1045+
1046+
String _generateJitsiUrl(String serverUrl, String visibleText) {
1047+
final id = List.generate(15, (_) => Random.secure().nextInt(10)).join();
1048+
return inlineLink(visibleText, '$serverUrl/$id#config.startWithVideoMuted=false');
1049+
}
1050+
1051+
String? _getMeetingUrl(ZulipLocalizations zulipLocalization, int? provider, String? jitsiServerUrl) {
1052+
final visibleText = zulipLocalization.composeBoxUploadedVideoCallUrl;
1053+
1054+
switch (provider) {
1055+
case 0: return null; //TODO: Implement feedback no video chat provider is setup
1056+
case jitsi: return jitsiServerUrl == null ? null :_generateJitsiUrl(jitsiServerUrl, visibleText);
1057+
case zoom: return inlineLink(visibleText,
1058+
'https://zoom.us/start/meeting');
1059+
default: return null;
1060+
}
1061+
}
1062+
1063+
void _handlePress(BuildContext context) {
1064+
final store = PerAccountStoreWidget.of(context);
1065+
final zulipLocalizations = ZulipLocalizations.of(context);
1066+
1067+
final placeholder = _getMeetingUrl(zulipLocalizations,
1068+
store.realmVideoChatProvider, store.jitsiServerUrl);
1069+
if (placeholder == null) return;
1070+
1071+
final contentController = controller.content;
1072+
final insertionRange = contentController.insertionIndex();
1073+
contentController.value = contentController.value.replaced(insertionRange, '$placeholder\n\n');
1074+
controller.contentFocusNode.requestFocus();
1075+
}
1076+
1077+
@override
1078+
Widget build(BuildContext context) {
1079+
final designVariables = DesignVariables.of(context);
1080+
final zulipLocalizations = ZulipLocalizations.of(context);
1081+
1082+
return SizedBox(
1083+
width: _composeButtonSize,
1084+
child: IconButton(
1085+
icon: Icon(ZulipIcons.video, color: designVariables.foreground.withFadedAlpha(0.5)),
1086+
tooltip: zulipLocalizations.composeBoxAttachFromVideoCallTooltip,
1087+
onPressed: enabled ? () => _handlePress(context) : null));
1088+
}
1089+
}
1090+
10341091
abstract class _AttachUploadsButton extends StatelessWidget {
10351092
const _AttachUploadsButton({required this.controller, required this.enabled});
10361093

@@ -1469,6 +1526,7 @@ abstract class _ComposeBoxBody extends StatelessWidget {
14691526
_AttachFileButton(controller: controller, enabled: composeButtonsEnabled),
14701527
_AttachMediaButton(controller: controller, enabled: composeButtonsEnabled),
14711528
_AttachFromCameraButton(controller: controller, enabled: composeButtonsEnabled),
1529+
_AttachVideoChatUrlButton(controller: controller, enabled: composeButtonsEnabled),
14721530
];
14731531

14741532
final topicInput = buildTopicInput();

pubspec.lock

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ packages:
1313
dependency: transitive
1414
description:
1515
name: _flutterfire_internals
16-
sha256: "948f7d74f41dd6f2d563ea9f4c21d7ea764f8e047d2b24138974c19c24d37eb6"
16+
sha256: f871a7d1b686bea1f13722aa51ab31554d05c81f47054d6de48cc8c45153508b
1717
url: "https://pub.dev"
1818
source: hosted
19-
version: "1.3.61"
19+
version: "1.3.63"
2020
analyzer:
2121
dependency: transitive
2222
description:
@@ -262,10 +262,10 @@ packages:
262262
dependency: "direct main"
263263
description:
264264
name: device_info_plus
265-
sha256: a7e611f8475a124caca8dac394c76c48218a244daa498c3584f97934267d1d4e
265+
sha256: "49413c8ca514dea7633e8def233b25efdf83ec8522955cc2c0e3ad802927e7c6"
266266
url: "https://pub.dev"
267267
source: hosted
268-
version: "12.0.0"
268+
version: "12.1.0"
269269
device_info_plus_platform_interface:
270270
dependency: transitive
271271
description:
@@ -278,18 +278,18 @@ packages:
278278
dependency: "direct main"
279279
description:
280280
name: drift
281-
sha256: "6aaea757f53bb035e8a3baedf3d1d53a79d6549a6c13d84f7546509da9372c7c"
281+
sha256: "540cf382a3bfa99b76e51514db5b0ebcd81ce3679b7c1c9cb9478ff3735e47a1"
282282
url: "https://pub.dev"
283283
source: hosted
284-
version: "2.28.1"
284+
version: "2.28.2"
285285
drift_dev:
286286
dependency: "direct dev"
287287
description:
288288
name: drift_dev
289-
sha256: d6646ee608b9f359b023ac329321bc9c63b098217291de079b8b2334a48abf39
289+
sha256: "4db0eeedc7e8bed117a9f22d867ab7a3a294300fed5c269aac90d0b3545967ca"
290290
url: "https://pub.dev"
291291
source: hosted
292-
version: "2.28.2"
292+
version: "2.28.3"
293293
fake_async:
294294
dependency: "direct dev"
295295
description:
@@ -358,50 +358,50 @@ packages:
358358
dependency: "direct main"
359359
description:
360360
name: firebase_core
361-
sha256: "967dae9a65f69377beb9f4ab292ea63ce5befa1ce24682cab1b69ca4b7a46927"
361+
sha256: "132e1c311bc41e7d387b575df0aacdf24efbf4930365eb61042be5bde3978f03"
362362
url: "https://pub.dev"
363363
source: hosted
364-
version: "4.1.0"
364+
version: "4.2.0"
365365
firebase_core_platform_interface:
366366
dependency: transitive
367367
description:
368368
name: firebase_core_platform_interface
369-
sha256: "5dbc900677dcbe5873d22ad7fbd64b047750124f1f9b7ebe2a33b9ddccc838eb"
369+
sha256: cccb4f572325dc14904c02fcc7db6323ad62ba02536833dddb5c02cac7341c64
370370
url: "https://pub.dev"
371371
source: hosted
372-
version: "6.0.0"
372+
version: "6.0.2"
373373
firebase_core_web:
374374
dependency: transitive
375375
description:
376376
name: firebase_core_web
377-
sha256: f7ee08febc1c4451588ce58ffcf28edaee857e9a196fee88b85deb889990094a
377+
sha256: ecde2def458292404a4fcd3731ee4992fd631a0ec359d2d67c33baa8da5ec8ae
378378
url: "https://pub.dev"
379379
source: hosted
380-
version: "3.1.0"
380+
version: "3.2.0"
381381
firebase_messaging:
382382
dependency: "direct main"
383383
description:
384384
name: firebase_messaging
385-
sha256: aad5dcdea5698499b70d74d5a53b1f6a9972f85f97225e4b7ac006dd8d4f9bac
385+
sha256: "5021279acd1cb5ccaceaa388e616e82cc4a2e4d862f02637df0e8ab766e6900a"
386386
url: "https://pub.dev"
387387
source: hosted
388-
version: "16.0.1"
388+
version: "16.0.3"
389389
firebase_messaging_platform_interface:
390390
dependency: transitive
391391
description:
392392
name: firebase_messaging_platform_interface
393-
sha256: "825bc11767bf50a43dccf49b3026f847ec31d0f176139bfc48d662cc128b5014"
393+
sha256: f3a16c51f02055ace2a7c16ccb341c1f1b36b67c13270a48bcef68c1d970bbe8
394394
url: "https://pub.dev"
395395
source: hosted
396-
version: "4.7.1"
396+
version: "4.7.3"
397397
firebase_messaging_web:
398398
dependency: transitive
399399
description:
400400
name: firebase_messaging_web
401-
sha256: db8dbdd79921245c4de02407e33cae2d1868683be18a5ba948d2af5311e3ef5d
401+
sha256: "3eb9a1382caeb95b370f21e36d4a460496af777c9c2ef5df9b90d4803982c069"
402402
url: "https://pub.dev"
403403
source: hosted
404-
version: "4.0.1"
404+
version: "4.0.3"
405405
fixnum:
406406
dependency: transitive
407407
description:
@@ -454,10 +454,10 @@ packages:
454454
dependency: transitive
455455
description:
456456
name: flutter_plugin_android_lifecycle
457-
sha256: b0694b7fb1689b0e6cc193b3f1fcac6423c4f93c74fb20b806c6b6f196db0c31
457+
sha256: "306f0596590e077338312f38837f595c04f28d6cdeeac392d3d74df2f0003687"
458458
url: "https://pub.dev"
459459
source: hosted
460-
version: "2.0.30"
460+
version: "2.0.32"
461461
flutter_test:
462462
dependency: "direct dev"
463463
description: flutter
@@ -541,10 +541,10 @@ packages:
541541
dependency: transitive
542542
description:
543543
name: image_picker_android
544-
sha256: a45bef33deb24839a51fb85a4d9e504ead2b1ad1c4779d02d09bf6a8857cdd52
544+
sha256: "58a85e6f09fe9c4484d53d18a0bd6271b72c53fce1d05e6f745ae36d8c18efca"
545545
url: "https://pub.dev"
546546
source: hosted
547-
version: "0.8.13+2"
547+
version: "0.8.13+5"
548548
image_picker_for_web:
549549
dependency: transitive
550550
description:
@@ -786,10 +786,10 @@ packages:
786786
dependency: transitive
787787
description:
788788
name: path_provider_android
789-
sha256: "993381400e94d18469750e5b9dcb8206f15bc09f9da86b9e44a9b0092a0066db"
789+
sha256: e122c5ea805bb6773bb12ce667611265980940145be920cd09a4b0ec0285cb16
790790
url: "https://pub.dev"
791791
source: hosted
792-
version: "2.2.18"
792+
version: "2.2.20"
793793
path_provider_foundation:
794794
dependency: transitive
795795
description:
@@ -834,10 +834,10 @@ packages:
834834
dependency: "direct dev"
835835
description:
836836
name: pigeon
837-
sha256: "2073deca15d22f1a0f5862cc6edc9e8660b3be7fd94f03b49101db71a5316b0f"
837+
sha256: "0045b172d1da43c40cb3f58e80e04b50a65cba20b8b70dc880af04181f7758da"
838838
url: "https://pub.dev"
839839
source: hosted
840-
version: "26.0.1"
840+
version: "26.0.2"
841841
platform:
842842
dependency: transitive
843843
description:
@@ -858,10 +858,10 @@ packages:
858858
dependency: transitive
859859
description:
860860
name: pool
861-
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
861+
sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d"
862862
url: "https://pub.dev"
863863
source: hosted
864-
version: "1.5.1"
864+
version: "1.5.2"
865865
powers:
866866
dependency: transitive
867867
description:
@@ -1007,18 +1007,18 @@ packages:
10071007
dependency: "direct main"
10081008
description:
10091009
name: sqlite3
1010-
sha256: f393d92c71bdcc118d6203d07c991b9be0f84b1a6f89dd4f7eed348131329924
1010+
sha256: f18fd9a72d7a1ad2920db61368f2a69368f1cc9b56b8233e9d83b47b0a8435aa
10111011
url: "https://pub.dev"
10121012
source: hosted
1013-
version: "2.9.0"
1013+
version: "2.9.3"
10141014
sqlite3_flutter_libs:
10151015
dependency: "direct main"
10161016
description:
10171017
name: sqlite3_flutter_libs
1018-
sha256: "2b03273e71867a8a4d030861fc21706200debe5c5858a4b9e58f4a1c129586a4"
1018+
sha256: "69c80d812ef2500202ebd22002cbfc1b6565e9ff56b2f971e757fac5d42294df"
10191019
url: "https://pub.dev"
10201020
source: hosted
1021-
version: "0.5.39"
1021+
version: "0.5.40"
10221022
sqlparser:
10231023
dependency: transitive
10241024
description:
@@ -1119,10 +1119,10 @@ packages:
11191119
dependency: "direct main"
11201120
description:
11211121
name: unorm_dart
1122-
sha256: "8e3870a1caa60bde8352f9597dd3535d8068613269444f8e35ea8925ec84c1f5"
1122+
sha256: "0c69186b03ca6addab0774bcc0f4f17b88d4ce78d9d4d8f0619e30a99ead58e7"
11231123
url: "https://pub.dev"
11241124
source: hosted
1125-
version: "0.3.1+1"
1125+
version: "0.3.2"
11261126
url_launcher:
11271127
dependency: "direct main"
11281128
description:
@@ -1135,10 +1135,10 @@ packages:
11351135
dependency: "direct main"
11361136
description:
11371137
name: url_launcher_android
1138-
sha256: "07cffecb7d68cbc6437cd803d5f11a86fe06736735c3dfe46ff73bcb0f958eed"
1138+
sha256: "5c8b6c2d89a78f5a1cca70a73d9d5f86c701b36b42f9c9dac7bad592113c28e9"
11391139
url: "https://pub.dev"
11401140
source: hosted
1141-
version: "6.3.21"
1141+
version: "6.3.24"
11421142
url_launcher_ios:
11431143
dependency: transitive
11441144
description:
@@ -1215,10 +1215,10 @@ packages:
12151215
dependency: transitive
12161216
description:
12171217
name: video_player_android
1218-
sha256: "59e5a457ddcc1688f39e9aef0efb62aa845cf0cbbac47e44ac9730dc079a2385"
1218+
sha256: eb68847234ade419a9bfe45bf2eabc9197f9773c4e0dad9f07297a69b35a4e9c
12191219
url: "https://pub.dev"
12201220
source: hosted
1221-
version: "2.8.13"
1221+
version: "2.8.16"
12221222
video_player_avfoundation:
12231223
dependency: transitive
12241224
description:
@@ -1231,10 +1231,10 @@ packages:
12311231
dependency: "direct dev"
12321232
description:
12331233
name: video_player_platform_interface
1234-
sha256: cf2a1d29a284db648fd66cbd18aacc157f9862d77d2cc790f6f9678a46c1db5a
1234+
sha256: "9e372520573311055cb353b9a0da1c9d72b094b7ba01b8ecc66f28473553793b"
12351235
url: "https://pub.dev"
12361236
source: hosted
1237-
version: "6.4.0"
1237+
version: "6.5.0"
12381238
video_player_web:
12391239
dependency: transitive
12401240
description:
@@ -1271,10 +1271,10 @@ packages:
12711271
dependency: transitive
12721272
description:
12731273
name: watcher
1274-
sha256: "5bf046f41320ac97a469d506261797f35254fa61c641741ef32dacda98b7d39c"
1274+
sha256: "592ab6e2892f67760543fb712ff0177f4ec76c031f02f5b4ff8d3fc5eb9fb61a"
12751275
url: "https://pub.dev"
12761276
source: hosted
1277-
version: "1.1.3"
1277+
version: "1.1.4"
12781278
web:
12791279
dependency: transitive
12801280
description:
@@ -1319,10 +1319,10 @@ packages:
13191319
dependency: transitive
13201320
description:
13211321
name: win32
1322-
sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
1322+
sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e
13231323
url: "https://pub.dev"
13241324
source: hosted
1325-
version: "5.14.0"
1325+
version: "5.15.0"
13261326
win32_registry:
13271327
dependency: transitive
13281328
description:

0 commit comments

Comments
 (0)