123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- import 'package:ConversionFlutterDemo/models/convert_contain_options_bean.dart';
- import 'package:ConversionFlutterDemo/states/convert_options_provider.dart';
- import 'package:flutter/material.dart';
- import 'package:provider/provider.dart';
- /// convert_excel_options_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 ConvertExcelOptionsWidget extends StatefulWidget {
- const ConvertExcelOptionsWidget({Key? key}) : super(key: key);
- @override
- State<ConvertExcelOptionsWidget> createState() =>
- _ConvertExcelOptionsWidgetState();
- }
- class _ConvertExcelOptionsWidgetState extends State<ConvertExcelOptionsWidget> {
- @override
- Widget build(BuildContext context) {
- bool containImages = context.select<ConvertOptionsProvider, bool>(
- (value) => value.excelOptions.containImages);
- bool containAnnotations = context.select<ConvertOptionsProvider, bool>(
- (value) => value.excelOptions.containAnnotations);
- return SingleChildScrollView(child: Padding(
- padding: EdgeInsets.all(8),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- const Text('ContainImages'),
- Switch(
- value: containImages,
- onChanged: (value) {
- context
- .read<ConvertOptionsProvider>()
- .changeExcelOptions(containImages: value);
- })
- ],
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- const Text('ContainAnnotations'),
- Switch(
- value: containAnnotations,
- onChanged: (value) {
- context
- .read<ConvertOptionsProvider>()
- .changeExcelOptions(containAnnotations: value);
- })
- ],
- ),
- excelWorkSheetOptions((value) {
- context
- .read<ConvertOptionsProvider>()
- .changeExcelOptions(workSheetOptions: value);
- }),
- excelContentOptions((value) {
- context
- .read<ConvertOptionsProvider>()
- .changeExcelOptions(contentOptions: value);
- })
- ],
- )),);
- }
- Widget excelWorkSheetOptions(ValueChanged<ExcelWorkSheetOptions> onChanged) {
- ExcelWorkSheetOptions workSheetOptions =
- context.select<ConvertOptionsProvider, ExcelWorkSheetOptions>(
- (value) => value.excelOptions.workSheetOptions);
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('WorkSheetOptions:'),
- _excelWorkSheetOptionsItem(
- workSheetOptions, ExcelWorkSheetOptions.ForEachTable, onChanged),
- _excelWorkSheetOptionsItem(
- workSheetOptions, ExcelWorkSheetOptions.ForEachPage, onChanged),
- _excelWorkSheetOptionsItem(
- workSheetOptions, ExcelWorkSheetOptions.ForTheDocument, onChanged),
- ],
- );
- }
- Widget _excelWorkSheetOptionsItem(
- ExcelWorkSheetOptions currentWorkSheetOptions,
- ExcelWorkSheetOptions options,
- ValueChanged<ExcelWorkSheetOptions> onChanged) {
- return CheckboxListTile(
- controlAffinity: ListTileControlAffinity.leading,
- title: Text(options.name),
- value: currentWorkSheetOptions == options,
- onChanged: (value) {
- onChanged(options);
- });
- }
- Widget excelContentOptions(ValueChanged<ContentOptions> onChanged) {
- ContentOptions contentOptions =
- context.select<ConvertOptionsProvider, ContentOptions>(
- (value) => value.excelOptions.contentOptions);
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text('ContentOptions:'),
- _excelContentOptionsItem(
- contentOptions, ContentOptions.OnlyText, onChanged),
- _excelContentOptionsItem(
- contentOptions, ContentOptions.OnlyTable, onChanged),
- _excelContentOptionsItem(
- contentOptions, ContentOptions.AllContent, onChanged),
- ],
- );
- }
- Widget _excelContentOptionsItem(ContentOptions currentOptions,
- ContentOptions options, ValueChanged<ContentOptions> onChanged) {
- return CheckboxListTile(
- controlAffinity: ListTileControlAffinity.leading,
- title: Text(options.name),
- value: currentOptions == options,
- onChanged: (value) {
- onChanged(options);
- });
- }
- }
|