Skip to content

Commit 2bda8c6

Browse files
committed
Added new features to the torrent context menu
1 parent 01c7e35 commit 2bda8c6

File tree

5 files changed

+517
-126
lines changed

5 files changed

+517
-126
lines changed

lib/Blocs/bloc_provider_list.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flood_mobile/Blocs/language_bloc/language_bloc.dart';
2+
import 'package:flood_mobile/Blocs/user_interface_bloc/user_interface_bloc.dart';
23
import 'package:flutter_bloc/flutter_bloc.dart';
34
import 'package:flood_mobile/Blocs/api_bloc/api_bloc.dart';
45
import 'package:flood_mobile/Blocs/filter_torrent_bloc/filter_torrent_bloc.dart';
@@ -56,5 +57,8 @@ class BlocProviders {
5657
create: (context) => LanguageBloc(),
5758
lazy: false,
5859
),
60+
BlocProvider<UserInterfaceBloc>(
61+
create: (context) => UserInterfaceBloc(),
62+
),
5963
];
6064
}

lib/Pages/home_screen/home_screen.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:convert';
22
import 'dart:io';
33
import 'package:awesome_notifications/awesome_notifications.dart';
44
import 'package:badges/badges.dart';
5+
import 'package:flood_mobile/Blocs/user_interface_bloc/user_interface_bloc.dart';
56
import 'package:flood_mobile/Notifications/notification_controller.dart';
67
import 'package:flood_mobile/Pages/home_screen/widgets/add_torrent_file.dart';
78
import 'package:flood_mobile/Pages/home_screen/widgets/menu_widget.dart';
@@ -55,6 +56,8 @@ class _HomeScreenState extends State<HomeScreen> {
5556
_processInitialUri();
5657
_listenForUri();
5758
AuthApi.getUsersList(context);
59+
BlocProvider.of<UserInterfaceBloc>(context, listen: false)
60+
.add(GetPreviousSetUserInterfaceEvent());
5861
}
5962

6063
@override

lib/Pages/settings_screen/settings_screen.dart

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'package:flood_mobile/Api/client_api.dart';
22
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';
34
import 'package:flood_mobile/Model/client_settings_model.dart';
5+
import 'package:flood_mobile/Model/user_interface_model.dart';
46
import 'package:flood_mobile/Pages/settings_screen/widgets/authentication_section.dart';
57
import 'package:flood_mobile/Pages/settings_screen/widgets/bandwidth_section.dart';
68
import 'package:flood_mobile/Pages/settings_screen/widgets/connectivity_section.dart';
@@ -11,7 +13,6 @@ import 'package:flood_mobile/Pages/widgets/flood_snackbar.dart';
1113
import 'package:flood_mobile/Pages/widgets/text_size.dart';
1214
import 'package:flood_mobile/Services/transfer_speed_manager.dart';
1315
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart';
14-
import 'package:flood_mobile/Blocs/user_detail_bloc/user_detail_bloc.dart';
1516
import 'package:flood_mobile/l10n/l10n.dart';
1617
import 'package:flutter/material.dart';
1718
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -70,7 +71,6 @@ class _SettingsScreenState extends State<SettingsScreen> {
7071
String downSpeed = '1 kB/s';
7172

7273
// *Authentication
73-
String currentUsername = '';
7474
TextEditingController usernameController = new TextEditingController();
7575
TextEditingController passwordController = new TextEditingController();
7676
TextEditingController pathController = new TextEditingController();
@@ -84,10 +84,16 @@ class _SettingsScreenState extends State<SettingsScreen> {
8484
String client = 'rTorrent';
8585
GlobalKey<FormState> _authenticationformKey = GlobalKey<FormState>();
8686

87+
// *User Interface
88+
Map<String, bool> torrentInfo = {};
89+
Map<String, bool> contextMenuInfo = {};
90+
8791
@override
8892
void didChangeDependencies() {
8993
ClientSettingsModel model =
9094
BlocProvider.of<ClientSettingsBloc>(context).clientSettings;
95+
final UserInterfaceModel userInterfaceModel =
96+
BlocProvider.of<UserInterfaceBloc>(context).state.model;
9197
setState(() {
9298
// *Bandwidth Initialization
9399
globalDownloadRateController = new TextEditingController(
@@ -142,23 +148,95 @@ class _SettingsScreenState extends State<SettingsScreen> {
142148
TransferSpeedManager.valToSpeedMap[model.throttleGlobalUpSpeed] ??
143149
'Unlimited';
144150

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+
};
146173

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+
};
149188
});
150189
super.didChangeDependencies();
151190
}
152191

153192
@override
154193
Widget build(BuildContext context) {
155194
double hp = MediaQuery.of(context).size.height;
195+
final AppLocalizations l10n = context.l10n;
156196
return KeyboardDismissOnTap(
157197
child: Scaffold(
158198
floatingActionButton: FloatingActionButton.extended(
159199
elevation: 0,
160200
backgroundColor: ThemeBloc.theme(widget.themeIndex).primaryColorDark,
161201
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+
162240
ClientSettingsModel clientSettingsModel =
163241
BlocProvider.of<ClientSettingsBloc>(context).clientSettings;
164242
ClientSettingsModel newClientSettingsModel =
@@ -207,8 +285,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
207285

208286
final changeSettingsSnackBar = addFloodSnackBar(
209287
SnackbarType.success,
210-
context.l10n.setting_button_save_snackbar,
211-
context.l10n.button_dismiss);
288+
l10n.setting_button_save_snackbar,
289+
l10n.button_dismiss);
212290

213291
ScaffoldMessenger.of(context).clearSnackBars();
214292
ScaffoldMessenger.of(context).showSnackBar(changeSettingsSnackBar);
@@ -218,7 +296,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
218296
color: Colors.white,
219297
),
220298
label: Text(
221-
context.l10n.button_save,
299+
l10n.button_save,
222300
style: TextStyle(
223301
color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600),
224302
),
@@ -230,7 +308,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
230308
child: Column(
231309
crossAxisAlignment: CrossAxisAlignment.start,
232310
children: [
233-
LText(text: context.l10n.setting_screen_heading),
311+
LText(text: l10n.setting_screen_heading),
234312
SizedBox(height: 30),
235313
// *Bandwidth Section
236314
BandwidthSection(
@@ -346,6 +424,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
346424
UserInterfaceSection(
347425
themeIndex: widget.themeIndex,
348426
hp: hp,
427+
torrentScreenItems: torrentInfo,
428+
contextMenuItems: contextMenuInfo,
349429
),
350430
SizedBox(
351431
height: 200,

lib/Pages/torrent_screen/widgets/focused_menu_items_lis.dart

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)