Skip to content

Commit 873cda7

Browse files
authored
Merge pull request #252 from amitamrutiya2210/new-user-interface
New customizable user interface options.
2 parents 5287c7a + 3fbfaab commit 873cda7

36 files changed

+429
-209
lines changed

.github/workflows/dart.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Flutter CI
22

33
on:
44
push:
5-
branches: [ master , develop ]
5+
branches: [master, develop]
66
pull_request:
7-
branches: [ master , develop ]
7+
branches: [master, develop]
88

99
jobs:
1010
build:
@@ -14,10 +14,10 @@ jobs:
1414
- uses: actions/checkout@v2
1515
- uses: actions/setup-java@v1
1616
with:
17-
java-version: '12.x'
17+
java-version: "12.x"
1818
- uses: subosito/flutter-action@v1
1919
with:
20-
flutter-version: '3.10.5'
20+
flutter-version: "3.13.1"
2121
- run: flutter pub get
2222
- run: flutter gen-l10n --arb-dir=lib/l10n/arb
2323
- run: flutter analyze

lib/Blocs/user_interface_bloc/user_interface_bloc.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class UserInterfaceBloc extends Bloc<UserInterfaceEvent, UserInterfaceState> {
1919
Emitter<UserInterfaceState> emit,
2020
) {
2121
UserInterfaceModel model = UserInterfaceModel(
22+
showProgressBar: event.model.showProgressBar,
2223
showDateAdded: event.model.showDateAdded,
2324
showDateCreated: event.model.showDateCreated,
2425
showRatio: event.model.showRatio,
@@ -43,6 +44,7 @@ class UserInterfaceBloc extends Bloc<UserInterfaceEvent, UserInterfaceState> {
4344
showInitialSeeding: event.model.showInitialSeeding,
4445
showSequentialDownload: event.model.showSequentialDownload,
4546
showDownloadTorrent: event.model.showDownloadTorrent,
47+
tagPreferenceButtonValue: event.model.tagPreferenceButtonValue,
4648
);
4749

4850
saveUserInterfaceModel(model);

lib/Blocs/user_interface_bloc/user_interface_state.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class UserInterfaceState extends Equatable {
99

1010
factory UserInterfaceState.initial() => UserInterfaceState(
1111
model: UserInterfaceModel(
12+
showProgressBar: true,
1213
showDateAdded: true,
1314
showDateCreated: true,
1415
showRatio: false,
@@ -33,6 +34,7 @@ class UserInterfaceState extends Equatable {
3334
showInitialSeeding: false,
3435
showSequentialDownload: false,
3536
showDownloadTorrent: false,
37+
tagPreferenceButtonValue: TagPreferenceButtonValue.multiSelection,
3638
),
3739
);
3840

lib/Model/user_interface_model.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'package:equatable/equatable.dart';
22

3+
enum TagPreferenceButtonValue { singleSelection, multiSelection }
4+
35
class UserInterfaceModel extends Equatable {
6+
final bool showProgressBar;
47
final bool showDateAdded;
58
final bool showDateCreated;
69
final bool showRatio;
@@ -25,8 +28,10 @@ class UserInterfaceModel extends Equatable {
2528
final bool showInitialSeeding;
2629
final bool showSequentialDownload;
2730
final bool showDownloadTorrent;
31+
final TagPreferenceButtonValue tagPreferenceButtonValue;
2832

2933
const UserInterfaceModel({
34+
required this.showProgressBar,
3035
required this.showDateAdded,
3136
required this.showDateCreated,
3237
required this.showRatio,
@@ -51,10 +56,12 @@ class UserInterfaceModel extends Equatable {
5156
required this.showInitialSeeding,
5257
required this.showSequentialDownload,
5358
required this.showDownloadTorrent,
59+
required this.tagPreferenceButtonValue,
5460
});
5561

5662
factory UserInterfaceModel.fromJson(Map<String, dynamic> json) {
5763
return UserInterfaceModel(
64+
showProgressBar: json['showProgressBar'] as bool,
5865
showDateAdded: json['showDateAdded'] as bool,
5966
showDateCreated: json['showDateCreated'] as bool,
6067
showRatio: json['showRatio'] as bool,
@@ -79,11 +86,16 @@ class UserInterfaceModel extends Equatable {
7986
showInitialSeeding: json['showInitialSeeding'] as bool,
8087
showSequentialDownload: json['showSequentialDownload'] as bool,
8188
showDownloadTorrent: json['showDownloadTorrent'] as bool,
89+
tagPreferenceButtonValue:
90+
json['tagPreferenceButtonValue'] == 'singleSelection'
91+
? TagPreferenceButtonValue.singleSelection
92+
: TagPreferenceButtonValue.multiSelection,
8293
);
8394
}
8495

8596
Map<String, dynamic> toJson() {
8697
return {
98+
'showProgressBar': showProgressBar,
8799
'showDateAdded': showDateAdded,
88100
'showDateCreated': showDateCreated,
89101
'showRatio': showRatio,
@@ -108,11 +120,16 @@ class UserInterfaceModel extends Equatable {
108120
'showInitialSeeding': showInitialSeeding,
109121
'showSequentialDownload': showSequentialDownload,
110122
'showDownloadTorrent': showDownloadTorrent,
123+
'tagPreferenceButtonValue':
124+
tagPreferenceButtonValue == TagPreferenceButtonValue.singleSelection
125+
? 'singleSelection'
126+
: 'multiSelection',
111127
};
112128
}
113129

114130
@override
115131
List<Object?> get props => [
132+
showProgressBar,
116133
showDateAdded,
117134
showDateCreated,
118135
showRatio,
@@ -136,6 +153,7 @@ class UserInterfaceModel extends Equatable {
136153
showPriority,
137154
showInitialSeeding,
138155
showSequentialDownload,
139-
showDownloadTorrent
156+
showDownloadTorrent,
157+
tagPreferenceButtonValue,
140158
];
141159
}

lib/Pages/home_screen/widgets/rss_feed_home_page.dart

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,20 +1011,23 @@ class _RSSFeedHomePageState extends State<RSSFeedHomePage>
10111011
Padding(
10121012
padding:
10131013
const EdgeInsets
1014-
.only(
1014+
.only(
10151015
top: 20),
10161016
child: Column(
10171017
crossAxisAlignment:
10181018
CrossAxisAlignment
10191019
.start,
10201020
children: [
10211021
Padding(
1022-
padding: const EdgeInsets
1022+
padding:
1023+
const EdgeInsets
10231024
.only(
1024-
right: 20,
1025-
left: 20,
1026-
bottom:
1027-
5),
1025+
right:
1026+
20,
1027+
left:
1028+
20,
1029+
bottom:
1030+
5),
10281031
child: Text(
10291032
l10n.selected_magnet_link,
10301033
style: TextStyle(
@@ -1043,7 +1046,7 @@ class _RSSFeedHomePageState extends State<RSSFeedHomePage>
10431046
),
10441047
Padding(
10451048
padding: const EdgeInsets
1046-
.only(
1049+
.only(
10471050
left:
10481051
20.0,
10491052
right:
@@ -1384,7 +1387,7 @@ class _RSSFeedHomePageState extends State<RSSFeedHomePage>
13841387
? Padding(
13851388
padding:
13861389
const EdgeInsets
1387-
.only(
1390+
.only(
13881391
top: 8.0),
13891392
child: Container(
13901393
height: 1,

lib/Pages/settings_screen/settings_screen.dart

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
8888
// *User Interface
8989
Map<String, bool> torrentInfo = {};
9090
Map<String, bool> contextMenuInfo = {};
91+
TagPreferenceButtonValue tagPreferenceButtonValue =
92+
TagPreferenceButtonValue.multiSelection;
9193

9294
@override
9395
void didChangeDependencies() {
@@ -152,6 +154,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
152154
// *User Interface Initialization
153155
final AppLocalizations l10n = context.l10n;
154156
torrentInfo = {
157+
l10n.show_progress_bar_option: userInterfaceModel.showProgressBar,
155158
l10n.torrent_description_date_added: userInterfaceModel.showDateAdded,
156159
l10n.torrent_description_date_created:
157160
userInterfaceModel.showDateCreated,
@@ -186,6 +189,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
186189
userInterfaceModel.showSequentialDownload,
187190
l10n.torrents_download_torrent: userInterfaceModel.showDownloadTorrent,
188191
};
192+
193+
tagPreferenceButtonValue = userInterfaceModel.tagPreferenceButtonValue;
189194
});
190195
super.didChangeDependencies();
191196
}
@@ -200,43 +205,53 @@ class _SettingsScreenState extends State<SettingsScreen> {
200205
elevation: 0,
201206
backgroundColor: ThemeBloc.theme(widget.themeIndex).primaryColorDark,
202207
onPressed: () {
203-
BlocProvider.of<UserInterfaceBloc>(context, listen: false)
204-
.add(UpdateUserInterfaceEvent(
208+
BlocProvider.of<UserInterfaceBloc>(context, listen: false).add(
209+
UpdateUserInterfaceEvent(
205210
model: UserInterfaceModel(
206-
showDateAdded: torrentInfo[l10n.torrent_description_date_added]!,
207-
showDateCreated:
208-
torrentInfo[l10n.torrent_description_date_created]!,
209-
showRatio: torrentInfo[l10n.torrent_description_ratio]!,
210-
showLocation: torrentInfo[l10n.torrent_description_location]!,
211-
showTags: torrentInfo[l10n.torrents_add_tags]!,
212-
showTrackers: torrentInfo[l10n.torrent_description_trackers]!,
213-
showTrackersMessage:
214-
torrentInfo[l10n.torrent_description_trackers_message]!,
215-
showDownloadSpeed:
216-
torrentInfo[l10n.torrent_description_download_speed]!,
217-
showUploadSpeed:
218-
torrentInfo[l10n.torrent_description_upload_speed]!,
219-
showPeers: torrentInfo[l10n.torrent_description_peers]!,
220-
showSeeds: torrentInfo[l10n.torrent_description_seeds]!,
221-
showSize: torrentInfo[l10n.torrent_description_size]!,
222-
showType: torrentInfo[l10n.torrent_description_type]!,
223-
showHash: torrentInfo[l10n.torrent_description_hash]!,
224-
showDelete: contextMenuInfo[l10n.multi_torrents_actions_delete]!,
225-
showSetTags: contextMenuInfo[l10n.torrents_set_tags_heading]!,
226-
showCheckHash: contextMenuInfo[l10n.torrent_check_hash]!,
227-
showReannounce: contextMenuInfo[l10n.torrents_reannounce]!,
228-
showSetTrackers:
229-
contextMenuInfo[l10n.torrents_set_trackers_heading]!,
230-
showGenerateMagnetLink:
231-
contextMenuInfo[l10n.torrents_genrate_magnet_link]!,
232-
showPriority: contextMenuInfo[l10n.set_priority_heading]!,
233-
showInitialSeeding:
234-
contextMenuInfo[l10n.torrents_initial_seeding]!,
235-
showSequentialDownload:
236-
contextMenuInfo[l10n.torrents_sequential_download]!,
237-
showDownloadTorrent:
238-
contextMenuInfo[l10n.torrents_download_torrent]!,
239-
)));
211+
showProgressBar:
212+
torrentInfo[l10n.show_progress_bar_option]!,
213+
showDateAdded:
214+
torrentInfo[l10n.torrent_description_date_added]!,
215+
showDateCreated:
216+
torrentInfo[l10n.torrent_description_date_created]!,
217+
showRatio: torrentInfo[l10n.torrent_description_ratio]!,
218+
showLocation:
219+
torrentInfo[l10n.torrent_description_location]!,
220+
showTags: torrentInfo[l10n.torrents_add_tags]!,
221+
showTrackers:
222+
torrentInfo[l10n.torrent_description_trackers]!,
223+
showTrackersMessage: torrentInfo[
224+
l10n.torrent_description_trackers_message]!,
225+
showDownloadSpeed: torrentInfo[
226+
l10n.torrent_description_download_speed]!,
227+
showUploadSpeed:
228+
torrentInfo[l10n.torrent_description_upload_speed]!,
229+
showPeers: torrentInfo[l10n.torrent_description_peers]!,
230+
showSeeds: torrentInfo[l10n.torrent_description_seeds]!,
231+
showSize: torrentInfo[l10n.torrent_description_size]!,
232+
showType: torrentInfo[l10n.torrent_description_type]!,
233+
showHash: torrentInfo[l10n.torrent_description_hash]!,
234+
showDelete: contextMenuInfo[
235+
l10n.multi_torrents_actions_delete]!,
236+
showSetTags:
237+
contextMenuInfo[l10n.torrents_set_tags_heading]!,
238+
showCheckHash:
239+
contextMenuInfo[l10n.torrent_check_hash]!,
240+
showReannounce:
241+
contextMenuInfo[l10n.torrents_reannounce]!,
242+
showSetTrackers: contextMenuInfo[
243+
l10n.torrents_set_trackers_heading]!,
244+
showGenerateMagnetLink:
245+
contextMenuInfo[l10n.torrents_genrate_magnet_link]!,
246+
showPriority:
247+
contextMenuInfo[l10n.set_priority_heading]!,
248+
showInitialSeeding:
249+
contextMenuInfo[l10n.torrents_initial_seeding]!,
250+
showSequentialDownload:
251+
contextMenuInfo[l10n.torrents_sequential_download]!,
252+
showDownloadTorrent:
253+
contextMenuInfo[l10n.torrents_download_torrent]!,
254+
tagPreferenceButtonValue: tagPreferenceButtonValue)));
240255

241256
ClientSettingsModel clientSettingsModel =
242257
BlocProvider.of<ClientSettingsBloc>(context).clientSettings;
@@ -428,6 +443,12 @@ class _SettingsScreenState extends State<SettingsScreen> {
428443
hp: hp,
429444
torrentScreenItems: torrentInfo,
430445
contextMenuItems: contextMenuInfo,
446+
selectedRadioButton: tagPreferenceButtonValue,
447+
tagSelectionOnChange: (value) {
448+
setState(() {
449+
tagPreferenceButtonValue = value!;
450+
});
451+
},
431452
),
432453
// *Power Management Section
433454
PowerManagementSection(

lib/Pages/settings_screen/widgets/user_interface_section.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:flood_mobile/Blocs/language_bloc/language_bloc.dart';
55
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart';
66
import 'package:flood_mobile/Blocs/user_interface_bloc/user_interface_bloc.dart';
77
import 'package:flood_mobile/Constants/languages.dart';
8+
import 'package:flood_mobile/Model/user_interface_model.dart';
89
import 'package:flood_mobile/Pages/widgets/flood_snackbar.dart';
910
import 'package:flood_mobile/Pages/widgets/text_size.dart';
1011
import 'package:flood_mobile/l10n/l10n.dart';
@@ -15,13 +16,17 @@ class UserInterfaceSection extends StatefulWidget {
1516
final double hp;
1617
Map<String, bool> torrentScreenItems;
1718
Map<String, bool> contextMenuItems;
19+
final TagPreferenceButtonValue selectedRadioButton;
20+
final void Function(TagPreferenceButtonValue? value) tagSelectionOnChange;
1821

1922
UserInterfaceSection({
2023
Key? key,
2124
required this.themeIndex,
2225
required this.hp,
2326
required this.torrentScreenItems,
2427
required this.contextMenuItems,
28+
required this.selectedRadioButton,
29+
required this.tagSelectionOnChange,
2530
}) : super(key: key);
2631

2732
@override
@@ -259,6 +264,33 @@ class _UserInterfaceSectionState extends State<UserInterfaceSection> {
259264
itemCount: widget.contextMenuItems.length,
260265
),
261266
),
267+
SizedBox(height: widget.hp * 0.02),
268+
SText(
269+
text: l10n.tag_selection_heading,
270+
themeIndex: widget.themeIndex,
271+
),
272+
Row(
273+
children: [
274+
Expanded(
275+
child: RadioListTile(
276+
contentPadding: EdgeInsets.zero,
277+
title: Text(l10n.single_selection_radio_button),
278+
value: TagPreferenceButtonValue.singleSelection,
279+
groupValue: widget.selectedRadioButton,
280+
onChanged: widget.tagSelectionOnChange,
281+
),
282+
),
283+
Expanded(
284+
child: RadioListTile(
285+
contentPadding: EdgeInsets.zero,
286+
title: Text(l10n.multi_selection_radio_button),
287+
value: TagPreferenceButtonValue.multiSelection,
288+
groupValue: widget.selectedRadioButton,
289+
onChanged: widget.tagSelectionOnChange,
290+
),
291+
),
292+
],
293+
)
262294
],
263295
)
264296
],

0 commit comments

Comments
 (0)