1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- import 'package:ConversionFlutterDemo/models/convert_bean.dart';
- import 'package:ConversionFlutterDemo/states/convert_provider.dart';
- import 'package:flutter/material.dart';
- import 'package:open_file/open_file.dart';
- import 'package:provider/provider.dart';
- /// convert_list_widget.dart
- /// Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
- ///
- /// THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
- /// AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
- /// UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
- /// This notice may not be removed from this file.
- class ConvertListWidget extends StatefulWidget {
- const ConvertListWidget({Key? key}) : super(key: key);
- @override
- State<ConvertListWidget> createState() => _ConvertListWidgetState();
- }
- class _ConvertListWidgetState extends State<ConvertListWidget> {
- @override
- Widget build(BuildContext context) {
- var count =
- context.select<ConvertProvider, int>((value) => value.items.length);
- return ListView.builder(
- itemCount: count,
- primary: true,
- shrinkWrap: true,
- physics: new ClampingScrollPhysics(),
- itemBuilder: (BuildContext context, int index) {
- //设置子条目
- return Builder(builder: (context) {
- ConvertBean bean = context.select<ConvertProvider, ConvertBean>(
- (value) => value.items[index]);
- context.select<ConvertProvider, int>(
- (value) => value.items[index].progress);
- int status = context.select<ConvertProvider, int>(
- (value) => value.items[index].status);
- return Column(
- children: [
- ListTile(
- isThreeLine: true,
- title: Text(
- bean.fileName,
- style: const TextStyle(fontSize: 18),
- ),
- subtitle: Text(
- "PDF convert ${bean.convertType.toUpperCase()} ${bean.outputPath != null ? "\n${bean.outputPath}" : ''}",
- style: const TextStyle(fontSize: 12),
- ),
- trailing: Text(bean.getStatusName()),
- // item 直观感受是整体大小
- contentPadding:
- const EdgeInsets.symmetric(horizontal: 12, vertical: 2),
- onTap: () async {
- print('ontap list status:${status}, path:${bean.outputPath}');
- if (status == convertSuccess) {
- OpenFile.open(bean.outputPath);
- }
- },
- ),
- ],
- );
- });
- },
- );
- }
- }
|