123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- ///
- /// 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.
- import 'package:compdfkit_flutter/common/util/Strings.dart';
- import 'package:compdfkit_flutter/common/util/cpdf_date_util.dart';
- import 'package:compdfkit_flutter/core/document/cpdf_document.dart';
- import 'package:compdfkit_flutter/core/document/cpdf_info.dart';
- import 'package:compdfkit_flutter/core/document/cpdf_permissions_info.dart';
- import 'package:compdfkit_flutter/widgets/common/views/cpdf_scaffold.dart';
- import 'package:compdfkit_flutter/widgets/common/views/cpdf_tool_bar.dart';
- import 'package:flutter/material.dart';
- class CPDFDocumentInfoPage extends StatefulWidget {
- final bool isDark;
- final CPDFDocument document;
- const CPDFDocumentInfoPage(
- {Key? key, this.isDark = false, required this.document})
- : super(key: key);
- @override
- State<CPDFDocumentInfoPage> createState() => _CPDFDocumentInfoPageState();
- }
- class _CPDFDocumentInfoPageState extends State<CPDFDocumentInfoPage> {
- @override
- Widget build(BuildContext context) {
- return CPDFScaffold(
- isDark: widget.isDark,
- appBar: CPDFToolbar.normal(
- context: context,
- titleText: Strings.DocumentInfo,
- leadingOnPressed: () {
- Navigator.pop(context);
- },
- ),
- body:ListView(children: [_documentInfo(), _permissionInfo()],),
- );
- }
- Widget _documentInfo() {
- return FutureBuilder(
- future: widget.document.getInfo(),
- builder: (context, snapshot) {
- if (snapshot.connectionState == ConnectionState.done &&
- snapshot.hasData) {
- CPDFInfo info = snapshot.data!;
- return Column(
- children: [
- const CPDFDocumentInfoTitle(title: Strings.Abstract),
- CPDFDocumentInfoItem(
- title: Strings.FileName, content: info.fileName),
- CPDFDocumentInfoItem(
- title: Strings.FileSize, content: info.fileSizeStr()),
- CPDFDocumentInfoItem(title: Strings.Title, content: info.title),
- CPDFDocumentInfoItem(
- title: Strings.Author, content: info.author),
- CPDFDocumentInfoItem(
- title: Strings.Subject, content: info.subject),
- CPDFDocumentInfoItem(
- title: Strings.Keywords, content: info.keywords),
- const CPDFDocumentInfoTitle(title: Strings.CreateInformation),
- CPDFDocumentInfoItem(
- title: Strings.Version,
- content: info.majorVersion.toString()),
- CPDFDocumentInfoItem(
- title: Strings.Pages, content: info.pageCount.toString()),
- CPDFDocumentInfoItem(
- title: Strings.Creator, content: info.creator),
- CPDFDocumentInfoItem(
- title: Strings.CreationDate,
- content: CPDFDateUtil.format(info.creationDate)),
- CPDFDocumentInfoItem(
- title: Strings.ModificationDate,
- content: CPDFDateUtil.format(info.modificationDate)),
- ],
- );
- } else {
- return const Padding(padding: EdgeInsets.zero);
- }
- });
- }
- Widget _permissionInfo() {
- return FutureBuilder(
- future: widget.document.getPermissionsInfo(),
- builder: (context, snapshot) {
- if (snapshot.connectionState == ConnectionState.done &&
- snapshot.hasData) {
- CPDFPermissionsInfo info = snapshot.data!;
- return Column(
- children: [
- const CPDFDocumentInfoTitle(title: Strings.CreateInformation),
- CPDFDocumentInfoItem(
- title: Strings.Printing,
- content: _allowStr(info.allowsPrinting)),
- CPDFDocumentInfoItem(
- title: Strings.ContentCopying, content: _allowStr(info.allowsCopying)),
- CPDFDocumentInfoItem(
- title: Strings.DocumentChange, content: _allowStr(info.allowsDocumentChanges)),
- CPDFDocumentInfoItem(
- title: Strings.DocumentAssembly,
- content: _allowStr(info.allowsDocumentAssembly)),
- CPDFDocumentInfoItem(
- title: Strings.Commenting,
- content: _allowStr(info.allowsCommenting)),
- CPDFDocumentInfoItem(
- title: Strings.FillingOfFormField,
- content: _allowStr(info.allowsFormFieldEntry)),
- ],
- );
- } else {
- return const Padding(padding: EdgeInsets.zero);
- }
- });
- }
- String _allowStr(bool allow) {
- return allow ? Strings.Allowed : Strings.NotAllowed;
- }
- }
- class CPDFDocumentInfoTitle extends StatelessWidget {
- final String title;
- const CPDFDocumentInfoTitle({Key? key, required this.title})
- : super(key: key);
- @override
- Widget build(BuildContext context) {
- return Container(
- alignment: Alignment.centerLeft,
- height: 28,
- padding: const EdgeInsets.symmetric(horizontal: 16),
- color: Theme.of(context).colorScheme.secondaryContainer,
- child: Text(
- title,
- style: Theme.of(context).textTheme.labelMedium,
- ),
- );
- }
- }
- class CPDFDocumentInfoItem extends StatelessWidget {
- final String title;
- final String content;
- const CPDFDocumentInfoItem(
- {Key? key, required this.title, required this.content})
- : super(key: key);
- @override
- Widget build(BuildContext context) {
- return Container(
- color: Theme.of(context).colorScheme.background,
- padding: const EdgeInsets.only(left: 16),
- child: Column(
- children: [
- SizedBox(
- height: 56,
- child: Row(
- mainAxisSize: MainAxisSize.max,
- children: [
- Text('$title:',
- style: Theme.of(context).textTheme.labelLarge),
- Expanded(
- child: Container(
- alignment: Alignment.centerRight,
- padding: const EdgeInsets.only(left: 10, right: 16),
- child: Text(
- content,
- style: Theme.of(context).textTheme.bodyMedium?.copyWith(
- color:
- Theme.of(context).colorScheme.primaryContainer),
- ),
- ))
- ],
- )),
- const Divider(height: 0.5)
- ],
- ));
- }
- }
|