@@ -222,117 +222,74 @@ class Pspdfkit {
222
222
static Future <Directory > getTemporaryDirectory () =>
223
223
PspdfkitFlutterPlatform .instance.getTemporaryDirectory ();
224
224
225
- /// onPause callback for FlutterPdfActivity
226
- static void Function ()? flutterPdfActivityOnPause;
225
+ /// onPause callback for FlutterPdfActivity. Only available on Android.
226
+ static set flutterPdfActivityOnPause (
227
+ VoidCallback ? flutterPdfActivityOnPause) {
228
+ PspdfkitFlutterPlatform .instance.flutterPdfActivityOnPause =
229
+ flutterPdfActivityOnPause;
230
+ }
227
231
228
- /// Added callback for FlutterPdfFragment
229
- static void Function ()? flutterPdfFragmentAdded;
232
+ /// called when a PdfFragment is added. Only available on Android.
233
+ static set flutterPdfFragmentAdded (VoidCallback ? flutterPdfFragmentAdded) {
234
+ PspdfkitFlutterPlatform .instance.flutterPdfFragmentAdded =
235
+ flutterPdfFragmentAdded;
236
+ }
230
237
231
- /// ViewControllerWillDismiss callback for PDFViewController
232
- static void Function ()? pdfViewControllerWillDismiss;
238
+ /// Called when a document is loaded.
239
+ static set pspdfkitDocumentLoaded (
240
+ PspdfkitDocumentLoadedCallback ? pspdfkitDocumentLoaded) {
241
+ PspdfkitFlutterPlatform .instance.flutterPdfDocumentLoaded =
242
+ pspdfkitDocumentLoaded;
243
+ }
233
244
234
- /// ViewControllerDidDismiss callback for PDFViewController
235
- static void Function ()? pdfViewControllerDidDismiss;
245
+ /// ViewControllerWillDismiss callback for PDFViewController. Only available on iOS.
246
+ static set pdfViewControllerWillDismiss (
247
+ VoidCallback ? pdfViewControllerWillDismiss) {
248
+ PspdfkitFlutterPlatform .instance.pdfViewControllerWillDismiss =
249
+ pdfViewControllerWillDismiss;
250
+ }
251
+
252
+ /// ViewControllerDidDismiss callback for PDFViewController. Only available on iOS.
253
+ static set pdfViewControllerDidDismiss (VoidCallback ? callback) {
254
+ PspdfkitFlutterPlatform .instance.pdfViewControllerDidDismiss = callback;
255
+ }
236
256
237
257
/// Called when instant synchronization starts.
238
- static void Function (String ? documentId)? instantSyncStarted;
258
+ static set instantSyncStarted (InstantSyncStartedCallback ? callback) {
259
+ PspdfkitFlutterPlatform .instance.instantSyncStarted = callback;
260
+ }
239
261
240
262
/// Called when instant synchronization ends.
241
- static void Function (String ? documentId)? instantSyncFinished;
263
+ static set instantSyncFinished (InstantSyncFinishedCallback ? callback) {
264
+ PspdfkitFlutterPlatform .instance.instantSyncFinished = callback;
265
+ }
242
266
243
267
/// Called when instant synchronization fails.
244
- static void Function (String ? documentId, String ? error)? instantSyncFailed;
268
+ static set instantSyncFailed (InstantSyncFailedCallback ? callback) {
269
+ PspdfkitFlutterPlatform .instance.instantSyncFailed = callback;
270
+ }
245
271
246
272
/// Called when instant authentication is done.
247
- static void Function (String documentId, String ? validJWT)?
248
- instantAuthenticationFinished;
273
+ static set instantAuthenticationFinished (
274
+ InstantAuthenticationFinishedCallback ? callback) {
275
+ PspdfkitFlutterPlatform .instance.instantAuthenticationFinished = callback;
276
+ }
249
277
250
278
/// Called when instant authentication fails.
251
- static void Function (String ? documentId, String ? error)?
252
- instantAuthenticationFailed;
253
-
254
- /// Only available on iOS.
255
- /// Called when instant document download is done.
256
- static void Function (String ? documentId)? instantDownloadFinished;
257
-
258
- /// Only available on iOS.
259
- /// Called when instant document download fails.
260
- static void Function (String ? documentId, String ? error)?
261
- instantDownloadFailed;
262
-
263
- /// Called with the document has been loaded
264
- static void Function (String ? documentId)? pspdfkitDocumentLoaded;
265
-
266
- static Future <void > _platformCallHandler (MethodCall call) {
267
- try {
268
- switch (call.method) {
269
- case 'flutterPdfActivityOnPause' :
270
- flutterPdfActivityOnPause? .call ();
271
- break ;
272
- case 'flutterPdfFragmentAdded' :
273
- flutterPdfFragmentAdded? .call ();
274
- break ;
275
- case 'pdfViewControllerWillDismiss' :
276
- pdfViewControllerWillDismiss? .call ();
277
- break ;
278
- case 'pdfViewControllerDidDismiss' :
279
- pdfViewControllerDidDismiss? .call ();
280
- break ;
281
- case 'pspdfkitInstantSyncStarted' :
282
- instantSyncStarted? .call (call.arguments as String );
283
- break ;
284
- case 'pspdfkitInstantSyncFinished' :
285
- instantSyncFinished? .call (call.arguments as String );
286
- break ;
287
- case 'pspdfkitInstantSyncFailed' :
288
- {
289
- final Map <dynamic , dynamic > map =
290
- call.arguments as Map <dynamic , dynamic >;
291
- instantSyncFailed? .call (
292
- map['documentId' ] as String , map['error' ] as String );
293
- break ;
294
- }
295
- case 'pspdfkitInstantAuthenticationFinished' :
296
- {
297
- final Map <dynamic , dynamic > map =
298
- call.arguments as Map <dynamic , dynamic >;
299
- instantAuthenticationFinished? .call (
300
- map['documentId' ] as String , map['jwt' ] as String );
301
- break ;
302
- }
303
- case 'pspdfkitInstantAuthenticationFailed' :
304
- {
305
- final Map <dynamic , dynamic > arguments =
306
- call.arguments as Map <dynamic , dynamic >;
307
- instantAuthenticationFailed? .call (arguments['documentId' ] as String ,
308
- arguments['error' ] as String );
309
- break ;
310
- }
311
- case 'pspdfkitInstantDownloadFinished' :
312
- instantDownloadFinished? .call (call.arguments as String );
313
- break ;
314
- case 'pspdfkitInstantDownloadFailed' :
315
- {
316
- final Map <dynamic , dynamic > arguments =
317
- call.arguments as Map <dynamic , dynamic >;
318
- instantDownloadFailed? .call (arguments['documentId' ] as String ,
319
- arguments['error' ] as String );
320
- break ;
321
- }
322
- case 'pspdfkitDocumentLoaded' :
323
- pspdfkitDocumentLoaded? .call (call.arguments as String );
324
- break ;
325
- default :
326
- if (kDebugMode) {
327
- print ('Unknown method ${call .method } ' );
328
- }
329
- }
330
- } catch (e) {
331
- if (kDebugMode) {
332
- print (e);
333
- }
334
- }
335
- return Future .value ();
279
+ static set instantAuthenticationFailed (
280
+ InstantAuthenticationFailedCallback ? callback) {
281
+ PspdfkitFlutterPlatform .instance.instantAuthenticationFailed = callback;
282
+ }
283
+
284
+ /// Called when instant document download is done.Only available on iOS.
285
+ static set instantDownloadFinished (
286
+ InstantDownloadFinishedCallback ? callback) {
287
+ PspdfkitFlutterPlatform .instance.instantDownloadFinished = callback;
288
+ }
289
+
290
+ /// Called when instant document download fails. Only available on iOS.
291
+ static set instantDownloadFailed (InstantDownloadFailedCallback ? callback) {
292
+ PspdfkitFlutterPlatform .instance.instantDownloadFailed = callback;
336
293
}
337
294
}
338
295
0 commit comments