From 6946e2ad46403eda406453294570c2271d0aa02f Mon Sep 17 00:00:00 2001 From: zsw Date: Tue, 13 Aug 2024 12:27:15 +0800 Subject: [PATCH] =?UTF-8?q?ios=20pdf=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Runner.xcodeproj/project.pbxproj | 6 +- lib/main.dart | 3 - .../invoices_manage/invoices_detail_page.dart | 24 +--- lib/order/invoices_manage/pdf_screen.dart | 7 +- lib/order/invoices_manage/pinch_page.dart | 125 ------------------ pubspec.lock | 88 ------------ pubspec.yaml | 4 +- 7 files changed, 13 insertions(+), 244 deletions(-) delete mode 100644 lib/order/invoices_manage/pinch_page.dart diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 8441f8a3..52a55458 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -602,7 +602,7 @@ CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEVELOPMENT_TEAM = YF3Q8DVP52; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -806,7 +806,7 @@ CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEVELOPMENT_TEAM = YF3Q8DVP52; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -896,7 +896,7 @@ CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEVELOPMENT_TEAM = YF3Q8DVP52; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/lib/main.dart b/lib/main.dart index 253ad21e..882d4d1e 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -175,7 +175,6 @@ import 'order/invoices_manage/invoices_detail_page.dart'; import 'order/invoices_manage/invoices_history.dart'; import 'order/invoices_manage/invoices_manage_page.dart'; import 'order/invoices_manage/invoices_title_info.dart'; -import 'order/invoices_manage/pinch_page.dart'; void main() async { @@ -427,8 +426,6 @@ Map routers = { GroupPageDetails(arguments:arguments), '/router/photo_view_gallery_screen': (context, {arguments}) => PhotoViewGalleryScreen(), - '/router/pinch_page': (context, {arguments}) => - PinchPage(), '/router/system_details': (context, {arguments}) => SystemDetails(arguments: arguments), '/router/invitation_record': (context, {arguments}) => diff --git a/lib/order/invoices_manage/invoices_detail_page.dart b/lib/order/invoices_manage/invoices_detail_page.dart index d291c48b..68247a8b 100644 --- a/lib/order/invoices_manage/invoices_detail_page.dart +++ b/lib/order/invoices_manage/invoices_detail_page.dart @@ -9,9 +9,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/order/invoices_manage/pdf_screen.dart'; -import 'package:huixiang/order/invoices_manage/pinch_page.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:pdfx/pdfx.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:shimmer/shimmer.dart'; @@ -45,7 +43,6 @@ class _InvoicesDetailPage extends State { String networkError = ""; int networkStatus = 0; final RefreshController refreshController = RefreshController(); - PdfController pdfDoc; @override void initState() { @@ -87,10 +84,6 @@ class _InvoicesDetailPage extends State { }); if (baseData != null && baseData.isSuccess) { invoicesDetailInfo = baseData.data; - final pdfFile = await createFileOfPdfUrl(); - pdfDoc = PdfController( - document: PdfDocument.openFile(pdfFile.path), - ); createFileOfPdfUrl().then((f) { setState(() { remotePDFpath = f.path; @@ -305,21 +298,12 @@ class _InvoicesDetailPage extends State { onTap: () { if ((invoicesDetailInfo?.ossUrl ?? "") .endsWith("pdf")) { - // Navigator.push( - // context, - // MaterialPageRoute( - // builder: (context) => PDFScreen( - // path: remotePDFpath, - // inlet: 0, - // ), - // ), - // ); Navigator.push( context, MaterialPageRoute( - builder: (context) => PinchPage( - path: "https://file.oa.yixinhuixiang.com/2024/08/06/e716b61ed0c4444db4e8e33bf2712432.pdf", - inlet:0 + builder: (context) => PDFScreen( + path: remotePDFpath, + inlet: 0, ), ), ); @@ -489,7 +473,7 @@ class _InvoicesDetailPage extends State { showDialog( context: context, builder: (BuildContext context) { - return PDFScreen(path:remotePDFpath, inlet: 1); + return PDFScreen(path: remotePDFpath, inlet: 1); }, ); } diff --git a/lib/order/invoices_manage/pdf_screen.dart b/lib/order/invoices_manage/pdf_screen.dart index c44eb8c4..fe8b6511 100644 --- a/lib/order/invoices_manage/pdf_screen.dart +++ b/lib/order/invoices_manage/pdf_screen.dart @@ -139,12 +139,15 @@ class _PDFScreenState extends State with WidgetsBindingObserver { onLinkHandler: (String uri) { print('goto uri: $uri'); }, - onPageChanged: (int page, int total) { + onPageChanged: (int page, int total) { if(total >0){ print('page change: $page/$total'); setState(() { - currentPage = page; + currentPage = page +1; pageTotal = total; }); + }else{ + pageTotal = 1; + } }, ), errorMessage.isEmpty diff --git a/lib/order/invoices_manage/pinch_page.dart b/lib/order/invoices_manage/pinch_page.dart deleted file mode 100644 index 99c8e7ba..00000000 --- a/lib/order/invoices_manage/pinch_page.dart +++ /dev/null @@ -1,125 +0,0 @@ -import 'package:dio/dio.dart'; -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; -import 'package:pdfx/pdfx.dart'; - -import '../../retrofit/retrofit_api.dart'; - -class PinchPage extends StatefulWidget { - final String path; - final int inlet; - const PinchPage({Key key,this.path,this.inlet}) : super(key: key); - - @override - State createState() => _PinchPageState(); -} - -enum DocShown { sample, tutorial, hello, password } - -class _PinchPageState extends State { - static const int _initialPage = 1; - PdfControllerPinch _pdfControllerPinch; - ApiService apiService; - - @override - void initState() { - apiService = ApiService( - Dio(), - context: context, - ); - _pdfControllerPinch = PdfControllerPinch( - document: PdfDocument.openData( - apiService.getUrlFile(widget.path ?? "") - ), - initialPage: _initialPage, - ); - super.initState(); - } - - @override - void dispose() { - _pdfControllerPinch.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return widget.inlet == 0 ? Scaffold( - backgroundColor: Colors.white, - body: Column( - children: [ - Container( - alignment: Alignment.topRight, - padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top,right:10), - child: IconButton( - icon: Icon(Icons.close,size: 30,color: Colors.black,), - onPressed: (){ - Navigator.of(context).pop(); - }, - ), - ), - Expanded(child: PdfViewPinch( - builders: PdfViewPinchBuilders( - options: const DefaultBuilderOptions(), - documentLoaderBuilder: (_) => - const Center(child: CircularProgressIndicator()), - pageLoaderBuilder: (_) => - const Center(child: CircularProgressIndicator()), - errorBuilder: (_, error) => Center(child: Text(error.toString())), - ), - controller: _pdfControllerPinch, - )), - Container( - padding:EdgeInsets.only(bottom:45,top:20), - width: MediaQuery.of(context).size.width, - child: Center( - child: PdfPageNumber( - controller: _pdfControllerPinch, - builder: (_, loadingState, page, pagesCount) => Container( - alignment: Alignment.center, - child: Text( - '$page/${pagesCount ?? 0}', - style: const TextStyle(fontSize:16), - ), - ), - ), - ), - ), - ], - ), - ):Column( - children: [ - Expanded(child: Padding( - padding: EdgeInsets.symmetric(vertical:200), - child: PdfViewPinch( - builders: PdfViewPinchBuilders( - options: const DefaultBuilderOptions(), - documentLoaderBuilder: (_) => - const Center(child: CircularProgressIndicator()), - pageLoaderBuilder: (_) => - const Center(child: CircularProgressIndicator()), - errorBuilder: (_, error) => Center(child: Text(error.toString())), - ), - controller: _pdfControllerPinch, - ), - )), - Container( - padding:EdgeInsets.only(bottom:45,top:20), - width: MediaQuery.of(context).size.width, - child: Center( - child: PdfPageNumber( - controller: _pdfControllerPinch, - builder: (_, loadingState, page, pagesCount) => Container( - alignment: Alignment.center, - child: Text( - '$page/${pagesCount ?? 0}', - style: const TextStyle(fontSize:16,color: Colors.white), - ), - ), - ), - ), - ), - ], - ); - } -} \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index f4ceccb5..e4aa165a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -169,54 +169,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.5" - device_info_plus: - dependency: transitive - description: - name: device_info_plus - sha256: c2386729379f04cd39ee0d5d4c48d8c8a0e70f7622dac626cbf5e396392602fd - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.2.4" - device_info_plus_linux: - dependency: transitive - description: - name: device_info_plus_linux - sha256: e4eb5db4704f5534e872148a21cfcd39581022b63df556da6720d88f7c9f91a9 - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.1" - device_info_plus_macos: - dependency: transitive - description: - name: device_info_plus_macos - sha256: "38871fd2ad31871399d8307630c9f4eb5941dd2c643ee221c44d58de95d367a1" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.2.3" - device_info_plus_platform_interface: - dependency: transitive - description: - name: device_info_plus_platform_interface - sha256: b2743934f0efc3e291880d76fb341ea114b7e8417d77ee0f93bd21f5dfd3e8d2 - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.6.1" - device_info_plus_web: - dependency: transitive - description: - name: device_info_plus_web - sha256: "38715ad1ef3bee8915dd7bee08a9ac9ab54472a8df425c887062a3046209f663" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.0" - device_info_plus_windows: - dependency: transitive - description: - name: device_info_plus_windows - sha256: "8fb1403fc94636d6ab48aeebb5f9379f2ca51cde3b337167ec6f39db09234492" - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.1.1" dio: dependency: "direct main" description: @@ -257,14 +209,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.0" - extension: - dependency: transitive - description: - name: extension - sha256: "755224c11fcbfb81d622e38befd05581b52566529a08f2407e424219200ac7cf" - url: "https://pub.flutter-io.cn" - source: hosted - version: "0.2.0" fake_async: dependency: transitive description: @@ -733,14 +677,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "2.0.7" - pdfx: - dependency: "direct main" - description: - name: pdfx - sha256: bdd269f7316630698b514778dd071c602cf1862c6e8c6661a74308970db1dc67 - url: "https://pub.flutter-io.cn" - source: hosted - version: "2.0.1+2" permission_handler: dependency: "direct main" description: @@ -1042,14 +978,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "19.4.56" - synchronized: - dependency: transitive - description: - name: synchronized - sha256: "5fcbd27688af6082f5abd611af56ee575342c30e87541d0245f7ff99faa02c60" - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.1.0" table_calendar: dependency: "direct main" description: @@ -1123,14 +1051,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.2.7" - universal_platform: - dependency: transitive - description: - name: universal_platform - sha256: "64e16458a0ea9b99260ceb5467a214c1f298d647c659af1bff6d3bf82536b1ec" - url: "https://pub.flutter-io.cn" - source: hosted - version: "1.1.0" url_launcher: dependency: "direct main" description: @@ -1163,14 +1083,6 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.1.3" - uuid: - dependency: transitive - description: - name: uuid - sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313" - url: "https://pub.flutter-io.cn" - source: hosted - version: "3.0.7" vector_math: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4d229169..20e98c3c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,9 +18,7 @@ dependencies: tobias: 2.4.1 #pdf展示 - flutter_pdfview: ^1.2.7 - - pdfx: ^2.0.1+2 + flutter_pdfview: ^1.3.2 gradient_widgets: ^0.6.0