Browse Source

ios pdf更改

wr_2024_invoice
zsw 5 months ago
parent
commit
6946e2ad46
  1. 6
      ios/Runner.xcodeproj/project.pbxproj
  2. 3
      lib/main.dart
  3. 24
      lib/order/invoices_manage/invoices_detail_page.dart
  4. 7
      lib/order/invoices_manage/pdf_screen.dart
  5. 125
      lib/order/invoices_manage/pinch_page.dart
  6. 88
      pubspec.lock
  7. 4
      pubspec.yaml

6
ios/Runner.xcodeproj/project.pbxproj

@ -602,7 +602,7 @@
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 6; CURRENT_PROJECT_VERSION = 7;
DEVELOPMENT_TEAM = YF3Q8DVP52; DEVELOPMENT_TEAM = YF3Q8DVP52;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -806,7 +806,7 @@
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 6; CURRENT_PROJECT_VERSION = 7;
DEVELOPMENT_TEAM = YF3Q8DVP52; DEVELOPMENT_TEAM = YF3Q8DVP52;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (
@ -896,7 +896,7 @@
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO; CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 6; CURRENT_PROJECT_VERSION = 7;
DEVELOPMENT_TEAM = YF3Q8DVP52; DEVELOPMENT_TEAM = YF3Q8DVP52;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = ( FRAMEWORK_SEARCH_PATHS = (

3
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_history.dart';
import 'order/invoices_manage/invoices_manage_page.dart'; import 'order/invoices_manage/invoices_manage_page.dart';
import 'order/invoices_manage/invoices_title_info.dart'; import 'order/invoices_manage/invoices_title_info.dart';
import 'order/invoices_manage/pinch_page.dart';
void main() async { void main() async {
@ -427,8 +426,6 @@ Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
GroupPageDetails(arguments:arguments), GroupPageDetails(arguments:arguments),
'/router/photo_view_gallery_screen': (context, {arguments}) => '/router/photo_view_gallery_screen': (context, {arguments}) =>
PhotoViewGalleryScreen(), PhotoViewGalleryScreen(),
'/router/pinch_page': (context, {arguments}) =>
PinchPage(),
'/router/system_details': (context, {arguments}) => '/router/system_details': (context, {arguments}) =>
SystemDetails(arguments: arguments), SystemDetails(arguments: arguments),
'/router/invitation_record': (context, {arguments}) => '/router/invitation_record': (context, {arguments}) =>

24
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_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.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/pdf_screen.dart';
import 'package:huixiang/order/invoices_manage/pinch_page.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:pdfx/pdfx.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:shimmer/shimmer.dart'; import 'package:shimmer/shimmer.dart';
@ -45,7 +43,6 @@ class _InvoicesDetailPage extends State<InvoicesDetailPage> {
String networkError = ""; String networkError = "";
int networkStatus = 0; int networkStatus = 0;
final RefreshController refreshController = RefreshController(); final RefreshController refreshController = RefreshController();
PdfController pdfDoc;
@override @override
void initState() { void initState() {
@ -87,10 +84,6 @@ class _InvoicesDetailPage extends State<InvoicesDetailPage> {
}); });
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
invoicesDetailInfo = baseData.data; invoicesDetailInfo = baseData.data;
final pdfFile = await createFileOfPdfUrl();
pdfDoc = PdfController(
document: PdfDocument.openFile(pdfFile.path),
);
createFileOfPdfUrl().then((f) { createFileOfPdfUrl().then((f) {
setState(() { setState(() {
remotePDFpath = f.path; remotePDFpath = f.path;
@ -305,21 +298,12 @@ class _InvoicesDetailPage extends State<InvoicesDetailPage> {
onTap: () { onTap: () {
if ((invoicesDetailInfo?.ossUrl ?? "") if ((invoicesDetailInfo?.ossUrl ?? "")
.endsWith("pdf")) { .endsWith("pdf")) {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => PDFScreen(
// path: remotePDFpath,
// inlet: 0,
// ),
// ),
// );
Navigator.push( Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(
builder: (context) => PinchPage( builder: (context) => PDFScreen(
path: "https://file.oa.yixinhuixiang.com/2024/08/06/e716b61ed0c4444db4e8e33bf2712432.pdf", path: remotePDFpath,
inlet:0 inlet: 0,
), ),
), ),
); );
@ -489,7 +473,7 @@ class _InvoicesDetailPage extends State<InvoicesDetailPage> {
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
return PDFScreen(path:remotePDFpath, inlet: 1); return PDFScreen(path: remotePDFpath, inlet: 1);
}, },
); );
} }

7
lib/order/invoices_manage/pdf_screen.dart

@ -139,12 +139,15 @@ class _PDFScreenState extends State<PDFScreen> with WidgetsBindingObserver {
onLinkHandler: (String uri) { onLinkHandler: (String uri) {
print('goto uri: $uri'); print('goto uri: $uri');
}, },
onPageChanged: (int page, int total) { onPageChanged: (int page, int total) { if(total >0){
print('page change: $page/$total'); print('page change: $page/$total');
setState(() { setState(() {
currentPage = page; currentPage = page +1;
pageTotal = total; pageTotal = total;
}); });
}else{
pageTotal = 1;
}
}, },
), ),
errorMessage.isEmpty errorMessage.isEmpty

125
lib/order/invoices_manage/pinch_page.dart

@ -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<PinchPage> createState() => _PinchPageState();
}
enum DocShown { sample, tutorial, hello, password }
class _PinchPageState extends State<PinchPage> {
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<DefaultBuilderOptions>(
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<DefaultBuilderOptions>(
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),
),
),
),
),
),
],
);
}
}

88
pubspec.lock

@ -169,54 +169,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.0.5" 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: dio:
dependency: "direct main" dependency: "direct main"
description: description:
@ -257,14 +209,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.0" 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: fake_async:
dependency: transitive dependency: transitive
description: description:
@ -733,14 +677,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.7" 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: permission_handler:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1042,14 +978,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "19.4.56" 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: table_calendar:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1123,14 +1051,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.7" 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: url_launcher:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1163,14 +1083,6 @@ packages:
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.1.3" 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: vector_math:
dependency: transitive dependency: transitive
description: description:

4
pubspec.yaml

@ -18,9 +18,7 @@ dependencies:
tobias: 2.4.1 tobias: 2.4.1
#pdf展示 #pdf展示
flutter_pdfview: ^1.2.7 flutter_pdfview: ^1.3.2
pdfx: ^2.0.1+2
gradient_widgets: ^0.6.0 gradient_widgets: ^0.6.0

Loading…
Cancel
Save