@@ -23,6 +23,8 @@ import '../app/user_auth_controller.dart';
2323import '../di/injector.dart' ;
2424import '../widgets/closed_captions_widget.dart' ;
2525
26+ const _useCustomDesktopScreenShareOption = false ;
27+
2628class CallScreen extends StatefulWidget {
2729 const CallScreen ({
2830 super .key,
@@ -264,6 +266,10 @@ class _CallScreenState extends State<CallScreen> {
264266 enabledScreenShareBackgroundColor:
265267 AppColorPalette .primary,
266268 disabledScreenShareIcon: Icons .screen_share,
269+ desktopScreenSelectorBuilder:
270+ _useCustomDesktopScreenShareOption
271+ ? _customDesktopScreenShareSelector
272+ : null ,
267273 ),
268274 ToggleMicrophoneOption (
269275 call: call,
@@ -330,3 +336,30 @@ class ChatBottomSheet extends StatelessWidget {
330336 );
331337 }
332338}
339+
340+ // This is an example of a bottom sheet that only allows the selection of a screen.
341+ // After tapping a screen the bottom sheet is directly closed and the screen is shared.
342+ Future <DesktopCapturerSource ?> _customDesktopScreenShareSelector (
343+ BuildContext context) {
344+ final ScreenSelectorStateNotifier stateNotifier =
345+ ScreenSelectorStateNotifier (sourceTypes: [SourceType .Screen ]);
346+
347+ return showModalBottomSheet <DesktopCapturerSource ?>(
348+ context: context,
349+ builder: (BuildContext context) {
350+ return ValueListenableBuilder (
351+ valueListenable: stateNotifier,
352+ builder:
353+ (BuildContext context, ScreenSelectorState value, Widget ? child) =>
354+ Padding (
355+ padding: const EdgeInsets .symmetric (horizontal: 16.0 ),
356+ child: ThumbnailGrid (
357+ sources: value.sources.values.toList (),
358+ selectedSource: value.selectedSource,
359+ onSelectSource: (source) => Navigator .pop (context, source),
360+ ),
361+ ),
362+ );
363+ },
364+ );
365+ }
0 commit comments