|
|
|
|
@ -8,9 +8,10 @@ import 'package:fluffychat/config/app_config.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/chat_settings/widgets/language_level_dropdown.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/common/constants/model_keys.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/common/widgets/full_width_dialog.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/models/language_model.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/pages/settings_learning.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/widgets/country_picker_tile.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/widgets/language_tile.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/widgets/p_language_dropdown.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/learning_settings/widgets/p_settings_switch_list_tile.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/spaces/models/space_model.dart';
|
|
|
|
|
import 'package:fluffychat/utils/platform_infos.dart';
|
|
|
|
|
@ -46,88 +47,126 @@ class SettingsLearningView extends StatelessWidget {
|
|
|
|
|
iconColor: Theme.of(context).textTheme.bodyLarge!.color,
|
|
|
|
|
child: MaxWidthBody(
|
|
|
|
|
withScrolling: true,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
LanguageTile(controller),
|
|
|
|
|
CountryPickerTile(controller),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 16.0, bottom: 24.0),
|
|
|
|
|
child: LanguageLevelDropdown(
|
|
|
|
|
initialLevel: controller.cefrLevel,
|
|
|
|
|
onChanged: controller.setCefrLevel,
|
|
|
|
|
child: Form(
|
|
|
|
|
key: controller.formKey,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
const SizedBox(height: 8.0),
|
|
|
|
|
PLanguageDropdown(
|
|
|
|
|
onChange: (lang) =>
|
|
|
|
|
controller.setSelectedLanguage(sourceLanguage: lang),
|
|
|
|
|
initialLanguage: controller.selectedSourceLanguage ??
|
|
|
|
|
LanguageModel.unknown,
|
|
|
|
|
languages: MatrixState
|
|
|
|
|
.pangeaController.pLanguageStore.baseOptions,
|
|
|
|
|
isL2List: false,
|
|
|
|
|
decorationText: L10n.of(context).myBaseLanguage,
|
|
|
|
|
validator: (lang) {
|
|
|
|
|
if (lang == controller.selectedTargetLanguage) {
|
|
|
|
|
return L10n.of(context).noIdenticalLanguages;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const Divider(height: 1),
|
|
|
|
|
ListTile(
|
|
|
|
|
title: Text(L10n.of(context).toggleToolSettingsDescription),
|
|
|
|
|
),
|
|
|
|
|
for (final toolSetting in ToolSetting.values
|
|
|
|
|
.where((tool) => tool.isAvailableSetting))
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
ProfileSettingsSwitchListTile.adaptive(
|
|
|
|
|
defaultValue: controller.getToolSetting(toolSetting),
|
|
|
|
|
title: toolSetting.toolName(context),
|
|
|
|
|
subtitle: toolSetting == ToolSetting.enableTTS &&
|
|
|
|
|
!controller.tts.isLanguageFullySupported
|
|
|
|
|
? null
|
|
|
|
|
: toolSetting.toolDescription(context),
|
|
|
|
|
onChange: (bool value) =>
|
|
|
|
|
controller.updateToolSetting(
|
|
|
|
|
toolSetting,
|
|
|
|
|
value,
|
|
|
|
|
),
|
|
|
|
|
enabled: toolSetting == ToolSetting.enableTTS
|
|
|
|
|
? controller.tts.isLanguageFullySupported
|
|
|
|
|
: true,
|
|
|
|
|
),
|
|
|
|
|
if (toolSetting == ToolSetting.enableTTS &&
|
|
|
|
|
!controller.tts.isLanguageFullySupported)
|
|
|
|
|
ListTile(
|
|
|
|
|
trailing: const Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
|
|
|
|
child: Icon(Icons.info_outlined),
|
|
|
|
|
const SizedBox(height: 24.0),
|
|
|
|
|
PLanguageDropdown(
|
|
|
|
|
onChange: (lang) =>
|
|
|
|
|
controller.setSelectedLanguage(targetLanguage: lang),
|
|
|
|
|
initialLanguage: controller.selectedTargetLanguage,
|
|
|
|
|
languages: MatrixState
|
|
|
|
|
.pangeaController.pLanguageStore.targetOptions,
|
|
|
|
|
isL2List: true,
|
|
|
|
|
decorationText: L10n.of(context).iWantToLearn,
|
|
|
|
|
validator: (lang) {
|
|
|
|
|
if (lang == controller.selectedSourceLanguage) {
|
|
|
|
|
return L10n.of(context).noIdenticalLanguages;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16.0),
|
|
|
|
|
CountryPickerTile(controller),
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(top: 16.0, bottom: 24.0),
|
|
|
|
|
child: LanguageLevelDropdown(
|
|
|
|
|
initialLevel: controller.cefrLevel,
|
|
|
|
|
onChanged: controller.setCefrLevel,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const Divider(height: 1),
|
|
|
|
|
ListTile(
|
|
|
|
|
title:
|
|
|
|
|
Text(L10n.of(context).toggleToolSettingsDescription),
|
|
|
|
|
),
|
|
|
|
|
for (final toolSetting in ToolSetting.values
|
|
|
|
|
.where((tool) => tool.isAvailableSetting))
|
|
|
|
|
Column(
|
|
|
|
|
children: [
|
|
|
|
|
ProfileSettingsSwitchListTile.adaptive(
|
|
|
|
|
defaultValue:
|
|
|
|
|
controller.getToolSetting(toolSetting),
|
|
|
|
|
title: toolSetting.toolName(context),
|
|
|
|
|
subtitle: toolSetting == ToolSetting.enableTTS &&
|
|
|
|
|
!controller.tts.isLanguageFullySupported
|
|
|
|
|
? null
|
|
|
|
|
: toolSetting.toolDescription(context),
|
|
|
|
|
onChange: (bool value) =>
|
|
|
|
|
controller.updateToolSetting(
|
|
|
|
|
toolSetting,
|
|
|
|
|
value,
|
|
|
|
|
),
|
|
|
|
|
subtitle: RichText(
|
|
|
|
|
text: TextSpan(
|
|
|
|
|
text: L10n.of(context).couldNotFindTTS,
|
|
|
|
|
style: DefaultTextStyle.of(context).style,
|
|
|
|
|
children: [
|
|
|
|
|
if (PlatformInfos.isWindows ||
|
|
|
|
|
PlatformInfos.isAndroid)
|
|
|
|
|
TextSpan(
|
|
|
|
|
text: L10n.of(context)
|
|
|
|
|
.ttsInstructionsHyperlink,
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: Colors.blue,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
|
enabled: toolSetting == ToolSetting.enableTTS
|
|
|
|
|
? controller.tts.isLanguageFullySupported
|
|
|
|
|
: true,
|
|
|
|
|
),
|
|
|
|
|
if (toolSetting == ToolSetting.enableTTS &&
|
|
|
|
|
!controller.tts.isLanguageFullySupported)
|
|
|
|
|
ListTile(
|
|
|
|
|
trailing: const Padding(
|
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
|
|
|
|
child: Icon(Icons.info_outlined),
|
|
|
|
|
),
|
|
|
|
|
subtitle: RichText(
|
|
|
|
|
text: TextSpan(
|
|
|
|
|
text: L10n.of(context).couldNotFindTTS,
|
|
|
|
|
style: DefaultTextStyle.of(context).style,
|
|
|
|
|
children: [
|
|
|
|
|
if (PlatformInfos.isWindows ||
|
|
|
|
|
PlatformInfos.isAndroid)
|
|
|
|
|
TextSpan(
|
|
|
|
|
text: L10n.of(context)
|
|
|
|
|
.ttsInstructionsHyperlink,
|
|
|
|
|
style: const TextStyle(
|
|
|
|
|
color: Colors.blue,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
|
),
|
|
|
|
|
recognizer: TapGestureRecognizer()
|
|
|
|
|
..onTap = () {
|
|
|
|
|
launchUrlString(
|
|
|
|
|
PlatformInfos.isWindows
|
|
|
|
|
? AppConfig
|
|
|
|
|
.windowsTTSDownloadInstructions
|
|
|
|
|
: AppConfig
|
|
|
|
|
.androidTTSDownloadInstructions,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
recognizer: TapGestureRecognizer()
|
|
|
|
|
..onTap = () {
|
|
|
|
|
launchUrlString(
|
|
|
|
|
PlatformInfos.isWindows
|
|
|
|
|
? AppConfig
|
|
|
|
|
.windowsTTSDownloadInstructions
|
|
|
|
|
: AppConfig
|
|
|
|
|
.androidTTSDownloadInstructions,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
SwitchListTile.adaptive(
|
|
|
|
|
value: controller.publicProfile,
|
|
|
|
|
onChanged: controller.setPublicProfile,
|
|
|
|
|
title: Text(L10n.of(context).publicProfileTitle),
|
|
|
|
|
subtitle: Text(L10n.of(context).publicProfileDesc),
|
|
|
|
|
activeColor: AppConfig.activeToggleColor,
|
|
|
|
|
),
|
|
|
|
|
SwitchListTile.adaptive(
|
|
|
|
|
value: controller.publicProfile,
|
|
|
|
|
onChanged: controller.setPublicProfile,
|
|
|
|
|
title: Text(L10n.of(context).publicProfileTitle),
|
|
|
|
|
subtitle: Text(L10n.of(context).publicProfileDesc),
|
|
|
|
|
activeColor: AppConfig.activeToggleColor,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
|