1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- ///
- /// 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';
- final displayModes = [
- CPDFRadioGroupData(
- 0, 'assets/images/ic_vertical_scrolling.png', Strings.VerticalScrolling),
- CPDFRadioGroupData(1, 'assets/images/ic_horizontal_scrolling.png',
- Strings.HorizontalScrolling)
- ];
- class CPDFDisplayModeWidget extends StatefulWidget {
- final CPDFViewCtrl ctrl;
- const CPDFDisplayModeWidget({Key? key, required this.ctrl}) : super(key: key);
- @override
- State<CPDFDisplayModeWidget> createState() => _CPDFDisplayModeWidgetState();
- }
- class _CPDFDisplayModeWidgetState extends State<CPDFDisplayModeWidget> {
- bool _isVerticalMode = true;
- @override
- void initState() {
- super.initState();
- _initDisplaySettings();
- }
- void _initDisplaySettings() async {
- CPDFViewCtrl ctrl = widget.ctrl;
- bool verticalMode = await ctrl.isVerticalMode();
- setState(() {
- _isVerticalMode = verticalMode;
- });
- }
- @override
- Widget build(BuildContext context) {
- return Column(
- children: [
- _title(context, Strings.DisplayMode),
- CPDFRadioListGroup(
- iconColor: Theme.of(context).brightness == Brightness.dark
- ? Colors.white
- : null,
- checkId: _isVerticalMode ? 0 : 1,
- list: displayModes,
- onChecked: (checkId) {
- setState(() {
- _isVerticalMode = checkId == 0;
- widget.ctrl.setVerticalMode(_isVerticalMode);
- });
- },
- )
- ],
- );
- }
- 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,
- ),
- );
- }
- }
|