|
@@ -2,10 +2,10 @@ import 'package:compdfkit_flutter/common/util/Strings.dart';
|
|
|
import 'package:compdfkit_flutter/core/cpdf_view_ctrl.dart';
|
|
|
import 'package:compdfkit_flutter/theme/colors.dart';
|
|
|
import 'package:compdfkit_flutter/theme/themes.dart';
|
|
|
+import 'package:compdfkit_flutter/widgets/viewer/pdfbota/pdfoutline/cpdf_outline_page.dart';
|
|
|
import 'package:compdfkit_flutter/widgets/viewer/pdfbota/pdfthumbnail/cpdf_thumbnail_page.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
-import '../../../core/document/cpdf_document.dart';
|
|
|
import '../../common/views/cpdf_tool_bar.dart';
|
|
|
|
|
|
/// Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
|
|
@@ -34,7 +34,31 @@ class CPDFBotaPage extends StatefulWidget {
|
|
|
State<CPDFBotaPage> createState() => _CPDFBotaPageState();
|
|
|
}
|
|
|
|
|
|
-class _CPDFBotaPageState extends State<CPDFBotaPage> {
|
|
|
+class _CPDFBotaPageState extends State<CPDFBotaPage>
|
|
|
+ with SingleTickerProviderStateMixin {
|
|
|
+ late TabController _tabController;
|
|
|
+
|
|
|
+ final ValueNotifier<String> _title = ValueNotifier('');
|
|
|
+
|
|
|
+ @override
|
|
|
+ void initState() {
|
|
|
+ super.initState();
|
|
|
+ _title.value = titles()[0];
|
|
|
+ _tabController = TabController(length: widget.types.length, vsync: this);
|
|
|
+ _tabController.addListener(() {
|
|
|
+ if (!_tabController.indexIsChanging) {
|
|
|
+ _title.value = titles()[_tabController.index];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @override
|
|
|
+ void dispose() {
|
|
|
+ _title.dispose();
|
|
|
+ _tabController.dispose();
|
|
|
+ super.dispose();
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Theme(
|
|
@@ -43,25 +67,34 @@ class _CPDFBotaPageState extends State<CPDFBotaPage> {
|
|
|
: comPDFKitLightTheme.copyWith(
|
|
|
colorScheme: comPDFKitLightTheme.colorScheme
|
|
|
.copyWith(primary: CPDFColors.backgroundLight)),
|
|
|
- child: DefaultTabController(
|
|
|
- length: widget.types.length,
|
|
|
- child: Scaffold(
|
|
|
- appBar: CPDFToolbar(
|
|
|
- bottom:
|
|
|
- widget.types.length > 1 ? TabBar(tabs: _tabItems()) : null,
|
|
|
- leadingIcon: IconButton(
|
|
|
- onPressed: () {
|
|
|
- Navigator.pop(context);
|
|
|
- },
|
|
|
- icon: Icon(Icons.arrow_back,
|
|
|
- color: Theme.of(context).colorScheme.onBackground)),
|
|
|
- titleText: Strings.Thumbnails,
|
|
|
- ),
|
|
|
- body: TabBarView(children: _pages()),
|
|
|
- )));
|
|
|
+ child: Scaffold(
|
|
|
+ appBar: CPDFToolbar(
|
|
|
+ bottom: widget.types.length > 1
|
|
|
+ ? TabBar(controller: _tabController, tabs: _tabItems())
|
|
|
+ : null,
|
|
|
+ leadingIcon: IconButton(
|
|
|
+ onPressed: () {
|
|
|
+ Navigator.pop(context);
|
|
|
+ },
|
|
|
+ icon: Icon(Icons.arrow_back,
|
|
|
+ color: Theme.of(context).colorScheme.onBackground)),
|
|
|
+ title: ValueListenableBuilder(
|
|
|
+ builder: (BuildContext context, String title, Widget? child) {
|
|
|
+ return Text(title,
|
|
|
+ style: const TextStyle(
|
|
|
+ fontFamily: 'sans-serif-medium', fontSize: 22));
|
|
|
+ },
|
|
|
+ valueListenable: _title,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ body: TabBarView(
|
|
|
+ controller: _tabController,
|
|
|
+ children: _pages(),
|
|
|
+ ),
|
|
|
+ ));
|
|
|
}
|
|
|
|
|
|
- List<Widget> _tabItems() {
|
|
|
+ List<String> titles() {
|
|
|
List<String> titles = widget.types.map((e) {
|
|
|
switch (e) {
|
|
|
case CPDFBotaType.annotations:
|
|
@@ -74,7 +107,11 @@ class _CPDFBotaPageState extends State<CPDFBotaPage> {
|
|
|
return Strings.Thumbnails;
|
|
|
}
|
|
|
}).toList();
|
|
|
- return titles.map((e) => Tab(text: e)).toList();
|
|
|
+ return titles;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Widget> _tabItems() {
|
|
|
+ return titles().map((e) => Tab(text: e)).toList();
|
|
|
}
|
|
|
|
|
|
List<Widget> _pages() {
|
|
@@ -89,8 +126,8 @@ class _CPDFBotaPageState extends State<CPDFBotaPage> {
|
|
|
// return Strings.Annotations;
|
|
|
// case CPDFBotaType.bookmarks:
|
|
|
// return Strings.Bookmarks;
|
|
|
- // case CPDFBotaType.outline:
|
|
|
- // return Strings.Outlines;
|
|
|
+ case CPDFBotaType.outline:
|
|
|
+ return CPDFOutlinePage(document: widget.ctrl.document);
|
|
|
default:
|
|
|
return Text(e.name);
|
|
|
}
|