Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 34 additions & 21 deletions lib/src/widgets/screen_select_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,16 @@ class ThumbnailWidgetState extends State<ThumbnailWidget> {

// ignore: must_be_immutable
class ScreenSelectDialog extends Dialog {
ScreenSelectDialog({Key? key}) : super(key: key) {
Future.delayed(const Duration(milliseconds: 100), () async {
await _getSources();
ScreenSelectDialog({
Key? key,
this.titleText = 'Choose what to share',
this.screenTabText = 'Entire Screen',
this.windowTabText = 'Window',
this.cancelText = 'Cancel',
this.shareText = 'Share',
}) : super(key: key) {
Future.delayed(const Duration(milliseconds: 100), () {
_getSources();
});
_subscriptions.add(rtc.desktopCapturer.onAdded.stream.listen((source) {
_sources[source.id] = source;
Expand All @@ -113,6 +120,13 @@ class ScreenSelectDialog extends Dialog {
_stateSetter?.call(() {});
}));
}

final String titleText;
final String screenTabText;
final String windowTabText;
final String cancelText;
final String shareText;

final Map<String, rtc.DesktopCapturerSource> _sources = {};
rtc.SourceType _sourceType = rtc.SourceType.Screen;
rtc.DesktopCapturerSource? _selectedSource;
Expand Down Expand Up @@ -176,11 +190,11 @@ class ScreenSelectDialog extends Dialog {
padding: const EdgeInsets.all(10),
child: Stack(
children: <Widget>[
const Align(
Align(
alignment: Alignment.topLeft,
child: Text(
'Choose what to share',
style: TextStyle(fontSize: 16, color: Colors.black87),
titleText,
style: const TextStyle(fontSize: 16, color: Colors.black87),
),
),
Align(
Expand Down Expand Up @@ -208,21 +222,20 @@ class ScreenSelectDialog extends Dialog {
Container(
constraints: const BoxConstraints.expand(height: 24),
child: TabBar(
onTap: (value) async {
await Future.delayed(const Duration(milliseconds: 300));
_sourceType = value == 0 ? rtc.SourceType.Screen : rtc.SourceType.Window;
await _getSources();
},
tabs: const [
onTap: (value) => Future.delayed(const Duration(milliseconds: 300), () {
_sourceType = value == 0 ? rtc.SourceType.Screen : rtc.SourceType.Window;
_getSources();
}),
tabs: [
Tab(
child: Text(
'Entire Screen',
style: TextStyle(color: Colors.black54),
screenTabText,
style: const TextStyle(color: Colors.black54),
)),
Tab(
child: Text(
'Window',
style: TextStyle(color: Colors.black54),
windowTabText,
style: const TextStyle(color: Colors.black54),
)),
]),
),
Expand Down Expand Up @@ -281,18 +294,18 @@ class ScreenSelectDialog extends Dialog {
child: OverflowBar(
children: <Widget>[
MaterialButton(
child: const Text(
'Cancel',
style: TextStyle(color: Colors.black54),
child: Text(
cancelText,
style: const TextStyle(color: Colors.black54),
),
onPressed: () async {
await _cancel(context);
},
),
MaterialButton(
color: Theme.of(context).primaryColor,
child: const Text(
'Share',
child: Text(
shareText,
),
onPressed: () async {
await _ok(context);
Expand Down
Loading