@@ -8,9 +8,10 @@ import 'package:fluffychat/config/app_config.dart';
8
8
import 'package:fluffychat/pangea/chat_settings/widgets/language_level_dropdown.dart' ;
9
9
import 'package:fluffychat/pangea/common/constants/model_keys.dart' ;
10
10
import 'package:fluffychat/pangea/common/widgets/full_width_dialog.dart' ;
11
+ import 'package:fluffychat/pangea/learning_settings/models/language_model.dart' ;
11
12
import 'package:fluffychat/pangea/learning_settings/pages/settings_learning.dart' ;
12
13
import 'package:fluffychat/pangea/learning_settings/widgets/country_picker_tile.dart' ;
13
- import 'package:fluffychat/pangea/learning_settings/widgets/language_tile .dart' ;
14
+ import 'package:fluffychat/pangea/learning_settings/widgets/p_language_dropdown .dart' ;
14
15
import 'package:fluffychat/pangea/learning_settings/widgets/p_settings_switch_list_tile.dart' ;
15
16
import 'package:fluffychat/pangea/spaces/models/space_model.dart' ;
16
17
import 'package:fluffychat/utils/platform_infos.dart' ;
@@ -46,88 +47,126 @@ class SettingsLearningView extends StatelessWidget {
46
47
iconColor: Theme .of (context).textTheme.bodyLarge! .color,
47
48
child: MaxWidthBody (
48
49
withScrolling: true ,
49
- child: Column (
50
- children: [
51
- LanguageTile (controller),
52
- CountryPickerTile (controller),
53
- Padding (
54
- padding: const EdgeInsets .only (top: 16.0 , bottom: 24.0 ),
55
- child: LanguageLevelDropdown (
56
- initialLevel: controller.cefrLevel,
57
- onChanged: controller.setCefrLevel,
50
+ child: Form (
51
+ key: controller.formKey,
52
+ child: Column (
53
+ children: [
54
+ const SizedBox (height: 8.0 ),
55
+ PLanguageDropdown (
56
+ onChange: (lang) =>
57
+ controller.setSelectedLanguage (sourceLanguage: lang),
58
+ initialLanguage: controller.selectedSourceLanguage ??
59
+ LanguageModel .unknown,
60
+ languages: MatrixState
61
+ .pangeaController.pLanguageStore.baseOptions,
62
+ isL2List: false ,
63
+ decorationText: L10n .of (context).myBaseLanguage,
64
+ validator: (lang) {
65
+ if (lang == controller.selectedTargetLanguage) {
66
+ return L10n .of (context).noIdenticalLanguages;
67
+ }
68
+ return null ;
69
+ },
58
70
),
59
- ),
60
- const Divider (height: 1 ),
61
- ListTile (
62
- title: Text (L10n .of (context).toggleToolSettingsDescription),
63
- ),
64
- for (final toolSetting in ToolSetting .values
65
- .where ((tool) => tool.isAvailableSetting))
66
- Column (
67
- children: [
68
- ProfileSettingsSwitchListTile .adaptive (
69
- defaultValue: controller.getToolSetting (toolSetting),
70
- title: toolSetting.toolName (context),
71
- subtitle: toolSetting == ToolSetting .enableTTS &&
72
- ! controller.tts.isLanguageFullySupported
73
- ? null
74
- : toolSetting.toolDescription (context),
75
- onChange: (bool value) =>
76
- controller.updateToolSetting (
77
- toolSetting,
78
- value,
79
- ),
80
- enabled: toolSetting == ToolSetting .enableTTS
81
- ? controller.tts.isLanguageFullySupported
82
- : true ,
83
- ),
84
- if (toolSetting == ToolSetting .enableTTS &&
85
- ! controller.tts.isLanguageFullySupported)
86
- ListTile (
87
- trailing: const Padding (
88
- padding: EdgeInsets .symmetric (horizontal: 16.0 ),
89
- child: Icon (Icons .info_outlined),
71
+ const SizedBox (height: 24.0 ),
72
+ PLanguageDropdown (
73
+ onChange: (lang) =>
74
+ controller.setSelectedLanguage (targetLanguage: lang),
75
+ initialLanguage: controller.selectedTargetLanguage,
76
+ languages: MatrixState
77
+ .pangeaController.pLanguageStore.targetOptions,
78
+ isL2List: true ,
79
+ decorationText: L10n .of (context).iWantToLearn,
80
+ validator: (lang) {
81
+ if (lang == controller.selectedSourceLanguage) {
82
+ return L10n .of (context).noIdenticalLanguages;
83
+ }
84
+ return null ;
85
+ },
86
+ ),
87
+ const SizedBox (height: 16.0 ),
88
+ CountryPickerTile (controller),
89
+ Padding (
90
+ padding: const EdgeInsets .only (top: 16.0 , bottom: 24.0 ),
91
+ child: LanguageLevelDropdown (
92
+ initialLevel: controller.cefrLevel,
93
+ onChanged: controller.setCefrLevel,
94
+ ),
95
+ ),
96
+ const Divider (height: 1 ),
97
+ ListTile (
98
+ title:
99
+ Text (L10n .of (context).toggleToolSettingsDescription),
100
+ ),
101
+ for (final toolSetting in ToolSetting .values
102
+ .where ((tool) => tool.isAvailableSetting))
103
+ Column (
104
+ children: [
105
+ ProfileSettingsSwitchListTile .adaptive (
106
+ defaultValue:
107
+ controller.getToolSetting (toolSetting),
108
+ title: toolSetting.toolName (context),
109
+ subtitle: toolSetting == ToolSetting .enableTTS &&
110
+ ! controller.tts.isLanguageFullySupported
111
+ ? null
112
+ : toolSetting.toolDescription (context),
113
+ onChange: (bool value) =>
114
+ controller.updateToolSetting (
115
+ toolSetting,
116
+ value,
90
117
),
91
- subtitle: RichText (
92
- text: TextSpan (
93
- text: L10n .of (context).couldNotFindTTS,
94
- style: DefaultTextStyle .of (context).style,
95
- children: [
96
- if (PlatformInfos .isWindows ||
97
- PlatformInfos .isAndroid)
98
- TextSpan (
99
- text: L10n .of (context)
100
- .ttsInstructionsHyperlink,
101
- style: const TextStyle (
102
- color: Colors .blue,
103
- fontWeight: FontWeight .bold,
104
- decoration: TextDecoration .underline,
118
+ enabled: toolSetting == ToolSetting .enableTTS
119
+ ? controller.tts.isLanguageFullySupported
120
+ : true ,
121
+ ),
122
+ if (toolSetting == ToolSetting .enableTTS &&
123
+ ! controller.tts.isLanguageFullySupported)
124
+ ListTile (
125
+ trailing: const Padding (
126
+ padding: EdgeInsets .symmetric (horizontal: 16.0 ),
127
+ child: Icon (Icons .info_outlined),
128
+ ),
129
+ subtitle: RichText (
130
+ text: TextSpan (
131
+ text: L10n .of (context).couldNotFindTTS,
132
+ style: DefaultTextStyle .of (context).style,
133
+ children: [
134
+ if (PlatformInfos .isWindows ||
135
+ PlatformInfos .isAndroid)
136
+ TextSpan (
137
+ text: L10n .of (context)
138
+ .ttsInstructionsHyperlink,
139
+ style: const TextStyle (
140
+ color: Colors .blue,
141
+ fontWeight: FontWeight .bold,
142
+ decoration: TextDecoration .underline,
143
+ ),
144
+ recognizer: TapGestureRecognizer ()
145
+ ..onTap = () {
146
+ launchUrlString (
147
+ PlatformInfos .isWindows
148
+ ? AppConfig
149
+ .windowsTTSDownloadInstructions
150
+ : AppConfig
151
+ .androidTTSDownloadInstructions,
152
+ );
153
+ },
105
154
),
106
- recognizer: TapGestureRecognizer ()
107
- ..onTap = () {
108
- launchUrlString (
109
- PlatformInfos .isWindows
110
- ? AppConfig
111
- .windowsTTSDownloadInstructions
112
- : AppConfig
113
- .androidTTSDownloadInstructions,
114
- );
115
- },
116
- ),
117
- ],
155
+ ],
156
+ ),
118
157
),
119
158
),
120
- ),
121
- ],
159
+ ],
160
+ ),
161
+ SwitchListTile .adaptive (
162
+ value: controller.publicProfile,
163
+ onChanged: controller.setPublicProfile,
164
+ title: Text (L10n .of (context).publicProfileTitle),
165
+ subtitle: Text (L10n .of (context).publicProfileDesc),
166
+ activeColor: AppConfig .activeToggleColor,
122
167
),
123
- SwitchListTile .adaptive (
124
- value: controller.publicProfile,
125
- onChanged: controller.setPublicProfile,
126
- title: Text (L10n .of (context).publicProfileTitle),
127
- subtitle: Text (L10n .of (context).publicProfileDesc),
128
- activeColor: AppConfig .activeToggleColor,
129
- ),
130
- ],
168
+ ],
169
+ ),
131
170
),
132
171
),
133
172
),
0 commit comments