1
1
import 'dart:collection' ;
2
2
import 'dart:convert' ;
3
3
import 'dart:io' ;
4
- import 'package:awesome_notifications/awesome_notifications.dart' ;
5
4
import 'package:battery_plus/battery_plus.dart' ;
6
- import 'package:duration/duration.dart' ;
7
5
import 'package:flutter/cupertino.dart' ;
8
6
import 'package:flutter/services.dart' ;
9
7
import 'package:flutter_bloc/flutter_bloc.dart' ;
@@ -14,7 +12,6 @@ import 'package:flood_mobile/Api/torrent_api.dart';
14
12
import 'package:flood_mobile/Blocs/filter_torrent_bloc/filter_torrent_bloc.dart' ;
15
13
import 'package:flood_mobile/Blocs/home_screen_bloc/home_screen_bloc.dart' ;
16
14
import 'package:flood_mobile/Blocs/power_management_bloc/power_management_bloc.dart' ;
17
- import 'package:flood_mobile/Constants/notification_keys.dart' ;
18
15
import 'package:flood_mobile/Model/download_rate_model.dart' ;
19
16
import 'package:flood_mobile/Model/torrent_model.dart' ;
20
17
import 'package:flood_mobile/Services/file_size_helper.dart' ;
@@ -162,88 +159,6 @@ class EventHandlerApi {
162
159
}
163
160
}
164
161
165
- static Future <void > showNotification (int id, BuildContext context) async {
166
- late bool displayNotification;
167
- late bool isPaused;
168
- isPaused = true ;
169
- HomeScreenState homeModel =
170
- BlocProvider .of <HomeScreenBloc >(context, listen: false ).state;
171
-
172
- // Skip finished torrents
173
- if (homeModel.torrentList[id].status.contains ('complete' )) {
174
- displayNotification = false ;
175
- } else {
176
- displayNotification = true ;
177
- }
178
-
179
- // Torrent not being downloaded
180
- if (homeModel.torrentList[id].status.contains ('downloading' )) {
181
- // Change to the 'RESUME' action
182
- isPaused = false ;
183
- }
184
-
185
- // Torrent Paused
186
- else {
187
- isPaused = true ;
188
- }
189
-
190
- // Create notification for unfinished downloads
191
- if (displayNotification) {
192
- AwesomeNotifications ().createNotification (
193
- content: NotificationContent (
194
- id: id,
195
- actionType: ActionType .Default ,
196
- channelKey: NotificationConstants .DOWNLOADS_CHANNEL_KEY ,
197
- category: NotificationCategory .Progress ,
198
- notificationLayout: NotificationLayout .ProgressBar ,
199
- title: homeModel.torrentList[id].name,
200
- body: isPaused
201
- ? "Stopped ETA: ∞"
202
- : "Downloading ETA: " +
203
- prettyDuration (
204
- Duration (
205
- seconds: homeModel.torrentList[id].eta.toInt (),
206
- ),
207
- abbreviated: true ,
208
- ),
209
- progress: homeModel.torrentList[id].percentComplete.round (),
210
- summary: isPaused ? 'Paused' : 'Downloading' ,
211
- locked: true ,
212
- autoDismissible: false ,
213
- showWhen: false ,
214
- ),
215
- actionButtons: [
216
- NotificationActionButton (
217
- key: isPaused
218
- ? NotificationConstants .RESUME_ACTION_KEY
219
- : NotificationConstants .PAUSE_ACTION_KEY ,
220
- label: isPaused ? 'Resume' : 'Pause' ,
221
- actionType: ActionType .KeepOnTop ,
222
- enabled: true ,
223
- autoDismissible: false ,
224
- ),
225
- ],
226
- );
227
- }
228
- }
229
-
230
- static Future <void > showEventNotification (
231
- int id, BuildContext context) async {
232
- AwesomeNotifications ().createNotification (
233
- content: NotificationContent (
234
- id: id,
235
- autoDismissible: false ,
236
- channelKey: NotificationConstants .PUSH_NOTIFICATION_CHANNEL_KEY ,
237
- category: NotificationCategory .Event ,
238
- notificationLayout: NotificationLayout .Default ,
239
- title: BlocProvider .of <HomeScreenBloc >(context, listen: false )
240
- .state
241
- .torrentList[id]
242
- .name,
243
- body: "Download Finished" ,
244
- ));
245
- }
246
-
247
162
static Future <void > filterDataRephrasor (
248
163
List <TorrentModel > torrentList, context) async {
249
164
FilterTorrentBloc filterBloc =
0 commit comments