pdf_page_widget.dart 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import 'package:flutter/material.dart';
  2. import 'package:kmpdfkit_demo/widgets/compdfkit/compdfkit_widget.dart';
  3. import 'package:kmpdfkit_demo/widgets/events.dart';
  4. import 'package:kmpdfkit_demo/widgets/page_routes.dart';
  5. import '../function/annot_tool_list_widget.dart';
  6. /// pdf_page_widget.dart
  7. ///
  8. /// Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
  9. ///
  10. /// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
  11. /// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
  12. /// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
  13. /// This notice may not be removed from this file.
  14. class PDFPageWidget extends StatefulWidget {
  15. final String? documentPath;
  16. final dynamic configuration;
  17. const PDFPageWidget({
  18. Key? key,
  19. this.documentPath,
  20. this.configuration,
  21. }) : super(key: key);
  22. @override
  23. State<PDFPageWidget> createState() => _PDFPageWidgetState();
  24. }
  25. class _PDFPageWidgetState extends State<PDFPageWidget> {
  26. bool _fullScreen = false;
  27. bool isInit = false;
  28. @override
  29. Widget build(BuildContext context) {
  30. return Scaffold(
  31. body: Stack(
  32. children: [
  33. SafeArea(
  34. child: ComPDFKitWidget(
  35. documentPath: widget.documentPath,
  36. configuration: widget.configuration,
  37. onComPDFKitWidgetCreate: () {
  38. setState(() {
  39. isInit = true;
  40. });
  41. setReaderViewCallbackListener(onTapMainDocArea: () {
  42. setState(() {
  43. _fullScreen = !_fullScreen;
  44. });
  45. });
  46. },
  47. )),
  48. Builder(builder: (context) {
  49. return Positioned(
  50. top: 0,
  51. left: 0,
  52. right: 0,
  53. child: AnimatedOpacity(
  54. opacity: _fullScreen ? 0.0 : 1.0,
  55. duration: const Duration(milliseconds: 200),
  56. child: AppBar(
  57. actions: [
  58. IconButton(
  59. onPressed: () {
  60. Navigator.pushNamed(context, PageRoutes.settings);
  61. },
  62. icon: const Icon(Icons.more_vert))
  63. ],
  64. )));
  65. }),
  66. Positioned(
  67. bottom: 0,
  68. left: 0,
  69. right: 0,
  70. child: AnimatedOpacity(
  71. opacity: _fullScreen ? 0.0 : 1.0,
  72. duration: const Duration(milliseconds: 200),
  73. child: isInit
  74. ? const PDFBottomAnnotFunWidget()
  75. : Container(
  76. color: const Color(0xFFEFF4FD),
  77. width: double.infinity,
  78. height: 60))),
  79. ],
  80. ),
  81. );
  82. }
  83. }