You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fluffychat/lib/pangea/toolbar/widgets/missing_voice_button.dart

51 lines
1.3 KiB
Dart

import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:android_intent_plus/android_intent.dart';
import 'package:fluffychat/l10n/l10n.dart';
import 'package:fluffychat/widgets/future_loading_dialog.dart';
import 'package:fluffychat/widgets/matrix.dart';
class MissingVoiceButton extends StatelessWidget {
const MissingVoiceButton({super.key});
Future<void> launchTTSSettings(BuildContext context) async {
if (!kIsWeb && Platform.isAndroid) {
const intent = AndroidIntent(
action: 'com.android.settings.TTS_SETTINGS',
package: 'com.talktolearn.chat',
);
await showFutureLoadingDialog(
context: context,
future: intent.launch,
);
}
}
@override
Widget build(BuildContext context) {
if (kIsWeb || !Platform.isAndroid) {
return const SizedBox();
}
return TextButton(
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all<Color>(
Theme.of(context).colorScheme.primary.withAlpha(25),
),
),
onPressed: () async {
MatrixState.pAnyState.closeOverlay();
await launchTTSSettings(context);
},
child: Center(
child: Text(L10n.of(context).openVoiceSettings),
),
);
}
}