@@ -17,6 +17,7 @@ import 'package:fluffychat/pangea/learning_settings/widgets/country_picker_tile.
17
17
import 'package:fluffychat/pangea/learning_settings/widgets/p_language_dropdown.dart' ;
18
18
import 'package:fluffychat/pangea/learning_settings/widgets/p_settings_switch_list_tile.dart' ;
19
19
import 'package:fluffychat/pangea/spaces/models/space_model.dart' ;
20
+ import 'package:fluffychat/widgets/layouts/max_width_body.dart' ;
20
21
import 'package:fluffychat/widgets/matrix.dart' ;
21
22
22
23
class SettingsLearningView extends StatelessWidget {
@@ -105,158 +106,156 @@ class SettingsLearningView extends StatelessWidget {
105
106
builder: (context, _) {
106
107
final dialogContent = Scaffold (
107
108
appBar: AppBar (
109
+ automaticallyImplyLeading: false ,
108
110
centerTitle: true ,
109
111
title: Text (
110
112
L10n .of (context).learningSettings,
111
113
),
112
- leading: IconButton (
113
- icon: const Icon (Icons .close),
114
- onPressed: controller.onSettingsClose,
115
- ),
114
+ leading: controller.widget.isDialog
115
+ ? IconButton (
116
+ icon: const Icon (Icons .close),
117
+ onPressed: controller.onSettingsClose,
118
+ )
119
+ : null ,
116
120
),
117
- body: ListTileTheme (
118
- iconColor: Theme .of (context).textTheme.bodyLarge! .color,
119
- child: Form (
120
- key: controller.formKey,
121
- child: Padding (
122
- padding: const EdgeInsets .symmetric (
123
- vertical: 16.0 ,
124
- horizontal: 8.0 ,
125
- ),
121
+ body: Form (
122
+ key: controller.formKey,
123
+ child: ListTileTheme (
124
+ iconColor: Theme .of (context).textTheme.bodyLarge! .color,
125
+ child: MaxWidthBody (
126
126
child: Column (
127
127
children: [
128
- Expanded (
129
- child: SingleChildScrollView (
130
- child: Padding (
131
- padding: const EdgeInsets .all (16.0 ),
132
- child: Column (
133
- spacing: 16.0 ,
134
- children: [
135
- PLanguageDropdown (
136
- onChange: (lang) =>
137
- controller.setSelectedLanguage (
138
- sourceLanguage: lang,
139
- ),
140
- initialLanguage:
141
- controller.selectedSourceLanguage ??
142
- LanguageModel .unknown,
143
- languages: MatrixState .pangeaController
144
- .pLanguageStore.baseOptions,
145
- isL2List: false ,
146
- decorationText: L10n .of (context).myBaseLanguage,
147
- hasError: controller.languageMatchError != null ,
148
- backgroundColor: Theme .of (context)
149
- .colorScheme
150
- .surfaceContainerHigh,
128
+ SingleChildScrollView (
129
+ child: Padding (
130
+ padding: const EdgeInsets .all (16.0 ),
131
+ child: Column (
132
+ spacing: 16.0 ,
133
+ children: [
134
+ PLanguageDropdown (
135
+ onChange: (lang) =>
136
+ controller.setSelectedLanguage (
137
+ sourceLanguage: lang,
151
138
),
152
- PLanguageDropdown (
153
- onChange: (lang) =>
154
- controller.setSelectedLanguage (
155
- targetLanguage: lang,
156
- ),
157
- initialLanguage:
158
- controller.selectedTargetLanguage,
159
- languages: MatrixState .pangeaController
160
- .pLanguageStore.targetOptions,
161
- isL2List: true ,
162
- decorationText: L10n .of (context).iWantToLearn,
163
- error: controller.languageMatchError,
164
- backgroundColor: Theme .of (context)
165
- .colorScheme
166
- .surfaceContainerHigh,
139
+ initialLanguage:
140
+ controller.selectedSourceLanguage ??
141
+ LanguageModel .unknown,
142
+ languages: MatrixState
143
+ .pangeaController.pLanguageStore.baseOptions,
144
+ isL2List: false ,
145
+ decorationText: L10n .of (context).myBaseLanguage,
146
+ hasError: controller.languageMatchError != null ,
147
+ backgroundColor: Theme .of (context)
148
+ .colorScheme
149
+ .surfaceContainerHigh,
150
+ ),
151
+ PLanguageDropdown (
152
+ onChange: (lang) =>
153
+ controller.setSelectedLanguage (
154
+ targetLanguage: lang,
167
155
),
168
- CountryPickerDropdown (controller),
169
- LanguageLevelDropdown (
170
- initialLevel: controller.cefrLevel,
171
- onChanged: controller.setCefrLevel,
156
+ initialLanguage:
157
+ controller.selectedTargetLanguage,
158
+ languages: MatrixState .pangeaController
159
+ .pLanguageStore.targetOptions,
160
+ isL2List: true ,
161
+ decorationText: L10n .of (context).iWantToLearn,
162
+ error: controller.languageMatchError,
163
+ backgroundColor: Theme .of (context)
164
+ .colorScheme
165
+ .surfaceContainerHigh,
166
+ ),
167
+ CountryPickerDropdown (controller),
168
+ LanguageLevelDropdown (
169
+ initialLevel: controller.cefrLevel,
170
+ onChanged: controller.setCefrLevel,
171
+ ),
172
+ Container (
173
+ decoration: BoxDecoration (
174
+ border: Border .all (
175
+ color: Colors .white54,
176
+ ),
177
+ borderRadius: BorderRadius .circular (8.0 ),
172
178
),
173
- Container (
174
- decoration: BoxDecoration (
175
- border: Border .all (
176
- color: Colors .white54,
179
+ padding: const EdgeInsets .all (8.0 ),
180
+ child: Column (
181
+ children: [
182
+ ProfileSettingsSwitchListTile .adaptive (
183
+ defaultValue: controller.getToolSetting (
184
+ ToolSetting .autoIGC,
185
+ ),
186
+ title:
187
+ ToolSetting .autoIGC.toolName (context),
188
+ subtitle: ToolSetting .autoIGC
189
+ .toolDescription (context),
190
+ onChange: (bool value) =>
191
+ controller.updateToolSetting (
192
+ ToolSetting .autoIGC,
193
+ value,
194
+ ),
195
+ enabled: true ,
177
196
),
178
- borderRadius: BorderRadius .circular (8.0 ),
179
- ),
180
- padding: const EdgeInsets .all (8.0 ),
181
- child: Column (
182
- children: [
183
- ProfileSettingsSwitchListTile .adaptive (
184
- defaultValue: controller
185
- .getToolSetting (ToolSetting .autoIGC),
186
- title:
187
- ToolSetting .autoIGC.toolName (context),
188
- subtitle: ToolSetting .autoIGC
189
- .toolDescription (context),
190
- onChange: (bool value) =>
191
- controller.updateToolSetting (
192
- ToolSetting .autoIGC,
193
- value,
194
- ),
195
- enabled: true ,
197
+ ProfileSettingsSwitchListTile .adaptive (
198
+ defaultValue: controller.getToolSetting (
199
+ ToolSetting .enableAutocorrect,
196
200
),
197
- ProfileSettingsSwitchListTile .adaptive (
198
- defaultValue: controller.getToolSetting (
201
+ title: ToolSetting .enableAutocorrect
202
+ .toolName (context),
203
+ subtitle: ToolSetting .enableAutocorrect
204
+ .toolDescription (context),
205
+ onChange: (bool value) {
206
+ controller.updateToolSetting (
199
207
ToolSetting .enableAutocorrect,
200
- ),
201
- title: ToolSetting .enableAutocorrect
202
- .toolName (context),
203
- subtitle: ToolSetting .enableAutocorrect
204
- .toolDescription (context),
205
- onChange: (bool value) {
206
- controller.updateToolSetting (
207
- ToolSetting .enableAutocorrect,
208
- value,
208
+ value,
209
+ );
210
+ if (value) {
211
+ _showKeyboardSettingsDialog (
212
+ context,
209
213
);
210
- if (value) {
211
- _showKeyboardSettingsDialog (context);
212
- }
213
- },
214
- enabled: true ,
215
- ),
216
- ],
217
- ),
214
+ }
215
+ },
216
+ enabled: true ,
217
+ ),
218
+ ],
218
219
),
219
- for (final toolSetting
220
- in ToolSetting .values.where (
221
- (tool) =>
222
- tool.isAvailableSetting &&
223
- tool != ToolSetting .autoIGC &&
224
- tool != ToolSetting .enableAutocorrect,
225
- ))
226
- Column (
227
- children: [
228
- ProfileSettingsSwitchListTile .adaptive (
229
- defaultValue: controller
230
- .getToolSetting (toolSetting),
231
- title: toolSetting.toolName (context),
232
- subtitle: toolSetting ==
233
- ToolSetting .enableTTS &&
234
- ! controller.isTTSSupported
235
- ? null
236
- : toolSetting
237
- .toolDescription (context),
238
- onChange: (bool value) =>
239
- controller.updateToolSetting (
240
- toolSetting,
241
- value,
242
- ),
220
+ ),
221
+ for (final toolSetting in ToolSetting .values.where (
222
+ (tool) =>
223
+ tool.isAvailableSetting &&
224
+ tool != ToolSetting .autoIGC &&
225
+ tool != ToolSetting .enableAutocorrect,
226
+ ))
227
+ Column (
228
+ children: [
229
+ ProfileSettingsSwitchListTile .adaptive (
230
+ defaultValue:
231
+ controller.getToolSetting (toolSetting),
232
+ title: toolSetting.toolName (context),
233
+ subtitle: toolSetting ==
234
+ ToolSetting .enableTTS &&
235
+ ! controller.isTTSSupported
236
+ ? null
237
+ : toolSetting.toolDescription (context),
238
+ onChange: (bool value) =>
239
+ controller.updateToolSetting (
240
+ toolSetting,
241
+ value,
243
242
),
244
- ],
245
- ),
246
- SwitchListTile .adaptive (
247
- value: controller.publicProfile,
248
- onChanged: controller.setPublicProfile,
249
- title: Text (
250
- L10n .of (context).publicProfileTitle,
251
- ),
252
- subtitle: Text (
253
- L10n .of (context).publicProfileDesc,
254
- ),
255
- activeColor: AppConfig .activeToggleColor,
256
- contentPadding: EdgeInsets .zero,
243
+ ),
244
+ ],
257
245
),
258
- ],
259
- ),
246
+ SwitchListTile .adaptive (
247
+ value: controller.publicProfile,
248
+ onChanged: controller.setPublicProfile,
249
+ title: Text (
250
+ L10n .of (context).publicProfileTitle,
251
+ ),
252
+ subtitle: Text (
253
+ L10n .of (context).publicProfileDesc,
254
+ ),
255
+ activeColor: AppConfig .activeToggleColor,
256
+ contentPadding: EdgeInsets .zero,
257
+ ),
258
+ ],
260
259
),
261
260
),
262
261
),
@@ -277,6 +276,8 @@ class SettingsLearningView extends StatelessWidget {
277
276
),
278
277
);
279
278
279
+ if (! controller.widget.isDialog) return dialogContent;
280
+
280
281
return FullWidthDialog (
281
282
dialogContent: dialogContent,
282
283
maxWidth: 600 ,
0 commit comments