/// /// 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/core/cpdf_view_ctrl.dart'; import 'package:flutter/material.dart'; import '../../../common/util/Strings.dart'; import '../../common/radio/cpdf_radio_group_data.dart'; import '../../common/radio/cpdf_radio_list_group.dart'; import '../../common/switch/cpdf_switch_list_tile.dart'; class CPDFPageSettingWidget extends StatefulWidget { final CPDFViewCtrl ctrl; const CPDFPageSettingWidget({Key? key, required this.ctrl}) : super(key: key); @override State createState() => _CPDFPageSettingWidgetState(); } class _CPDFPageSettingWidgetState extends State { bool _isContinuousScroll = false; bool _cropMode = false; @override void initState() { super.initState(); _initDisplaySettings(); } void _initDisplaySettings() async { CPDFViewCtrl ctrl = widget.ctrl; bool isContinuous = await ctrl.isContinueMode(); bool isCrop = await ctrl.isCropMode(); setState(() { _isContinuousScroll = isContinuous; _cropMode = isCrop; }); } @override Widget build(BuildContext context) { return Column( children: [ _title(context, ''), CPDFSwitchListTile( iconColor: Theme.of(context).brightness == Brightness.dark ? Colors.white : null, leadingPackage: 'compdfkit_flutter', leadingImageIcon: 'assets/images/ic_continuous_scroll.png', titleText: Strings.ContinuousScroll, checked: _isContinuousScroll, onChecked: (check) { setState(() { _isContinuousScroll = check; widget.ctrl.setContinueMode(_isContinuousScroll); }); }, ), CPDFSwitchListTile( iconColor: Theme.of(context).brightness == Brightness.dark ? Colors.white : null, leadingPackage: 'compdfkit_flutter', leadingImageIcon: 'assets/images/ic_crop_mode.png', titleText: Strings.Crop, checked: _cropMode, onChecked: (check) { setState(() { _cropMode = check; widget.ctrl.setCropMode(_cropMode); }); }, ) ], ); } Widget _title(BuildContext context, String title) { 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, ), ); } }