1
1
import 'package:flood_mobile/Api/client_api.dart' ;
2
2
import 'package:flood_mobile/Blocs/client_settings_bloc/client_settings_bloc.dart' ;
3
+ import 'package:flood_mobile/Blocs/user_interface_bloc/user_interface_bloc.dart' ;
3
4
import 'package:flood_mobile/Model/client_settings_model.dart' ;
5
+ import 'package:flood_mobile/Model/user_interface_model.dart' ;
4
6
import 'package:flood_mobile/Pages/settings_screen/widgets/authentication_section.dart' ;
5
7
import 'package:flood_mobile/Pages/settings_screen/widgets/bandwidth_section.dart' ;
6
8
import 'package:flood_mobile/Pages/settings_screen/widgets/connectivity_section.dart' ;
@@ -11,7 +13,6 @@ import 'package:flood_mobile/Pages/widgets/flood_snackbar.dart';
11
13
import 'package:flood_mobile/Pages/widgets/text_size.dart' ;
12
14
import 'package:flood_mobile/Services/transfer_speed_manager.dart' ;
13
15
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart' ;
14
- import 'package:flood_mobile/Blocs/user_detail_bloc/user_detail_bloc.dart' ;
15
16
import 'package:flood_mobile/l10n/l10n.dart' ;
16
17
import 'package:flutter/material.dart' ;
17
18
import 'package:flutter_bloc/flutter_bloc.dart' ;
@@ -70,7 +71,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
70
71
String downSpeed = '1 kB/s' ;
71
72
72
73
// *Authentication
73
- String currentUsername = '' ;
74
74
TextEditingController usernameController = new TextEditingController ();
75
75
TextEditingController passwordController = new TextEditingController ();
76
76
TextEditingController pathController = new TextEditingController ();
@@ -84,10 +84,16 @@ class _SettingsScreenState extends State<SettingsScreen> {
84
84
String client = 'rTorrent' ;
85
85
GlobalKey <FormState > _authenticationformKey = GlobalKey <FormState >();
86
86
87
+ // *User Interface
88
+ Map <String , bool > torrentInfo = {};
89
+ Map <String , bool > contextMenuInfo = {};
90
+
87
91
@override
88
92
void didChangeDependencies () {
89
93
ClientSettingsModel model =
90
94
BlocProvider .of <ClientSettingsBloc >(context).clientSettings;
95
+ final UserInterfaceModel userInterfaceModel =
96
+ BlocProvider .of <UserInterfaceBloc >(context).state.model;
91
97
setState (() {
92
98
// *Bandwidth Initialization
93
99
globalDownloadRateController = new TextEditingController (
@@ -142,23 +148,95 @@ class _SettingsScreenState extends State<SettingsScreen> {
142
148
TransferSpeedManager .valToSpeedMap[model.throttleGlobalUpSpeed] ??
143
149
'Unlimited' ;
144
150
145
- // Authentication Initialization
151
+ // *User Interface Initialization
152
+ final AppLocalizations l10n = context.l10n;
153
+ torrentInfo = {
154
+ l10n.torrent_description_date_added: userInterfaceModel.showDateAdded,
155
+ l10n.torrent_description_date_created:
156
+ userInterfaceModel.showDateCreated,
157
+ l10n.torrent_description_ratio: userInterfaceModel.showRatio,
158
+ l10n.torrent_description_location: userInterfaceModel.showLocation,
159
+ l10n.torrents_add_tags: userInterfaceModel.showTags,
160
+ l10n.torrent_description_trackers: userInterfaceModel.showTrackers,
161
+ l10n.torrent_description_trackers_message:
162
+ userInterfaceModel.showTrackersMessage,
163
+ l10n.torrent_description_download_speed:
164
+ userInterfaceModel.showDownloadSpeed,
165
+ l10n.torrent_description_upload_speed:
166
+ userInterfaceModel.showUploadSpeed,
167
+ l10n.torrent_description_peers: userInterfaceModel.showPeers,
168
+ l10n.torrent_description_seeds: userInterfaceModel.showSeeds,
169
+ l10n.torrent_description_size: userInterfaceModel.showSize,
170
+ l10n.torrent_description_type: userInterfaceModel.showType,
171
+ l10n.torrent_description_hash: userInterfaceModel.showHash,
172
+ };
146
173
147
- currentUsername =
148
- BlocProvider .of <UserDetailBloc >(context, listen: false ).username;
174
+ contextMenuInfo = {
175
+ l10n.multi_torrents_actions_delete: userInterfaceModel.showDelete,
176
+ l10n.torrents_set_tags_heading: userInterfaceModel.showSetTags,
177
+ l10n.torrent_check_hash: userInterfaceModel.showCheckHash,
178
+ l10n.torrents_reannounce: userInterfaceModel.showReannounce,
179
+ l10n.torrents_set_trackers_heading: userInterfaceModel.showSetTrackers,
180
+ l10n.torrents_genrate_magnet_link:
181
+ userInterfaceModel.showGenerateMagnetLink,
182
+ l10n.set_priority_heading: userInterfaceModel.showPriority,
183
+ l10n.torrents_initial_seeding: userInterfaceModel.showInitialSeeding,
184
+ l10n.torrents_sequential_download:
185
+ userInterfaceModel.showSequentialDownload,
186
+ l10n.torrents_download_torrent: userInterfaceModel.showDownloadTorrent,
187
+ };
149
188
});
150
189
super .didChangeDependencies ();
151
190
}
152
191
153
192
@override
154
193
Widget build (BuildContext context) {
155
194
double hp = MediaQuery .of (context).size.height;
195
+ final AppLocalizations l10n = context.l10n;
156
196
return KeyboardDismissOnTap (
157
197
child: Scaffold (
158
198
floatingActionButton: FloatingActionButton .extended (
159
199
elevation: 0 ,
160
200
backgroundColor: ThemeBloc .theme (widget.themeIndex).primaryColorDark,
161
201
onPressed: () {
202
+ BlocProvider .of <UserInterfaceBloc >(context, listen: false )
203
+ .add (UpdateUserInterfaceEvent (
204
+ model: UserInterfaceModel (
205
+ showDateAdded: torrentInfo[l10n.torrent_description_date_added]! ,
206
+ showDateCreated:
207
+ torrentInfo[l10n.torrent_description_date_created]! ,
208
+ showRatio: torrentInfo[l10n.torrent_description_ratio]! ,
209
+ showLocation: torrentInfo[l10n.torrent_description_location]! ,
210
+ showTags: torrentInfo[l10n.torrents_add_tags]! ,
211
+ showTrackers: torrentInfo[l10n.torrent_description_trackers]! ,
212
+ showTrackersMessage:
213
+ torrentInfo[l10n.torrent_description_trackers_message]! ,
214
+ showDownloadSpeed:
215
+ torrentInfo[l10n.torrent_description_download_speed]! ,
216
+ showUploadSpeed:
217
+ torrentInfo[l10n.torrent_description_upload_speed]! ,
218
+ showPeers: torrentInfo[l10n.torrent_description_peers]! ,
219
+ showSeeds: torrentInfo[l10n.torrent_description_seeds]! ,
220
+ showSize: torrentInfo[l10n.torrent_description_size]! ,
221
+ showType: torrentInfo[l10n.torrent_description_type]! ,
222
+ showHash: torrentInfo[l10n.torrent_description_hash]! ,
223
+ showDelete: contextMenuInfo[l10n.multi_torrents_actions_delete]! ,
224
+ showSetTags: contextMenuInfo[l10n.torrents_set_tags_heading]! ,
225
+ showCheckHash: contextMenuInfo[l10n.torrent_check_hash]! ,
226
+ showReannounce: contextMenuInfo[l10n.torrents_reannounce]! ,
227
+ showSetTrackers:
228
+ contextMenuInfo[l10n.torrents_set_trackers_heading]! ,
229
+ showGenerateMagnetLink:
230
+ contextMenuInfo[l10n.torrents_genrate_magnet_link]! ,
231
+ showPriority: contextMenuInfo[l10n.set_priority_heading]! ,
232
+ showInitialSeeding:
233
+ contextMenuInfo[l10n.torrents_initial_seeding]! ,
234
+ showSequentialDownload:
235
+ contextMenuInfo[l10n.torrents_sequential_download]! ,
236
+ showDownloadTorrent:
237
+ contextMenuInfo[l10n.torrents_download_torrent]! ,
238
+ )));
239
+
162
240
ClientSettingsModel clientSettingsModel =
163
241
BlocProvider .of <ClientSettingsBloc >(context).clientSettings;
164
242
ClientSettingsModel newClientSettingsModel =
@@ -207,8 +285,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
207
285
208
286
final changeSettingsSnackBar = addFloodSnackBar (
209
287
SnackbarType .success,
210
- context. l10n.setting_button_save_snackbar,
211
- context. l10n.button_dismiss);
288
+ l10n.setting_button_save_snackbar,
289
+ l10n.button_dismiss);
212
290
213
291
ScaffoldMessenger .of (context).clearSnackBars ();
214
292
ScaffoldMessenger .of (context).showSnackBar (changeSettingsSnackBar);
@@ -218,7 +296,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
218
296
color: Colors .white,
219
297
),
220
298
label: Text (
221
- context. l10n.button_save,
299
+ l10n.button_save,
222
300
style: TextStyle (
223
301
color: Colors .white, fontSize: 16 , fontWeight: FontWeight .w600),
224
302
),
@@ -230,7 +308,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
230
308
child: Column (
231
309
crossAxisAlignment: CrossAxisAlignment .start,
232
310
children: [
233
- LText (text: context. l10n.setting_screen_heading),
311
+ LText (text: l10n.setting_screen_heading),
234
312
SizedBox (height: 30 ),
235
313
// *Bandwidth Section
236
314
BandwidthSection (
@@ -346,6 +424,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
346
424
UserInterfaceSection (
347
425
themeIndex: widget.themeIndex,
348
426
hp: hp,
427
+ torrentScreenItems: torrentInfo,
428
+ contextMenuItems: contextMenuInfo,
349
429
),
350
430
SizedBox (
351
431
height: 200 ,
0 commit comments