Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .changes/screen-select-dialog-i18n
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patch type="added" "Allow customizing screen share dialog labels for localization"
55 changes: 33 additions & 22 deletions lib/src/widgets/screen_select_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,15 @@ 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) {
Timer(const Duration(milliseconds: 100), _getSources);
_subscriptions.add(rtc.desktopCapturer.onAdded.stream.listen((source) {
_sources[source.id] = source;
_stateSetter?.call(() {});
Expand All @@ -113,6 +118,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 +188,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 +220,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) => Timer(const Duration(milliseconds: 300), () {
_sourceType = value == 0 ? rtc.SourceType.Screen : rtc.SourceType.Window;
unawaited(_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 +292,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