cpdf_action_widget.dart 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. ///
  2. /// Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
  3. ///
  4. /// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  5. /// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  6. /// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  7. /// This notice may not be removed from this file.
  8. import 'package:flutter/material.dart';
  9. class CPDFActions {
  10. static CPDFActionWidget thumbnail({CPDFActionOnPressedCallback? onPressed}) {
  11. return CPDFActionWidget(
  12. image: 'assets/images/ic_thumbnail.png',
  13. package: 'compdfkit_flutter',
  14. onPressed: onPressed,
  15. );
  16. }
  17. static CPDFActionWidget search({CPDFActionOnPressedCallback? onPressed}) {
  18. return CPDFActionWidget(
  19. image: 'assets/images/ic_search.png',
  20. package: 'compdfkit_flutter',
  21. onPressed: onPressed,
  22. );
  23. }
  24. static CPDFActionWidget bota({CPDFActionOnPressedCallback? onPressed}) {
  25. return CPDFActionWidget(
  26. image: 'assets/images/ic_book.png',
  27. package: 'compdfkit_flutter',
  28. onPressed: onPressed,
  29. );
  30. }
  31. static CPDFActionWidget more({CPDFActionOnPressedCallback? onPressed}) {
  32. return CPDFActionWidget(
  33. image: 'assets/images/ic_more.png',
  34. package: 'compdfkit_flutter',
  35. onPressed: onPressed,
  36. );
  37. }
  38. }
  39. typedef CPDFActionOnPressedCallback = Function(BuildContext context);
  40. class CPDFActionWidget extends StatelessWidget {
  41. final String image;
  42. final String package;
  43. final CPDFActionOnPressedCallback? onPressed;
  44. const CPDFActionWidget(
  45. {Key? key,
  46. required this.image,
  47. this.package = 'compdfkit_flutter',
  48. this.onPressed})
  49. : super(key: key);
  50. @override
  51. Widget build(BuildContext context) {
  52. return IconButton(
  53. splashRadius: 24,
  54. onPressed: () {
  55. if (onPressed != null) {
  56. onPressed!(context);
  57. }
  58. },
  59. icon: Image.asset(
  60. image,
  61. package: package,
  62. width: 24,
  63. height: 24,
  64. color: Theme.of(context).colorScheme.onBackground,
  65. ));
  66. }
  67. }