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.
62 lines
1.7 KiB
Dart
62 lines
1.7 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:android_intent_plus/android_intent.dart';
|
|
import 'package:fluffychat/config/app_config.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
|
|
|
class MissingVoiceButton extends StatelessWidget {
|
|
final String targetLangCode;
|
|
|
|
const MissingVoiceButton({
|
|
required this.targetLangCode,
|
|
super.key,
|
|
});
|
|
|
|
void launchTTSSettings(BuildContext context) {
|
|
if (Platform.isAndroid) {
|
|
const intent = AndroidIntent(
|
|
action: 'com.android.settings.TTS_SETTINGS',
|
|
package: 'com.talktolearn.chat',
|
|
);
|
|
|
|
showFutureLoadingDialog(
|
|
context: context,
|
|
future: intent.launch,
|
|
);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color:
|
|
Theme.of(context).colorScheme.onPrimaryContainer.withOpacity(0.1),
|
|
borderRadius: const BorderRadius.all(
|
|
Radius.circular(AppConfig.borderRadius),
|
|
),
|
|
),
|
|
padding: const EdgeInsets.all(8),
|
|
margin: const EdgeInsets.only(top: 8),
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
L10n.of(context)!.voiceNotAvailable,
|
|
textAlign: TextAlign.center,
|
|
),
|
|
TextButton(
|
|
onPressed: () => launchTTSSettings,
|
|
style: const ButtonStyle(
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
),
|
|
child: Text(L10n.of(context)!.openVoiceSettings),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|