Skip to content

Commit

Permalink
fix: show expanded Toc
Browse files Browse the repository at this point in the history
* when searching for a refernce in the TOC screen, the filtered TOCs could be open to show sub-headers.
  • Loading branch information
Sivan22 committed Jan 11, 2025
1 parent d2a44ca commit 01a7032
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions lib/screens/reading/text/toc_navigator_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,26 @@ class _TocViewerState extends State<TocViewer>
return Padding(
padding: EdgeInsets.fromLTRB(
0, 0, 10 * allEntries[index].level.toDouble(), 0),
child: ListTile(
title: Text(allEntries[index].fullText),
onTap: () {
widget.scrollController.scrollTo(
index: allEntries[index].index,
duration: const Duration(milliseconds: 250),
curve: Curves.ease,
);
if (Platform.isAndroid) {
widget.closeLeftPaneCallback();
}
},
),
child: allEntries[index].children.isEmpty
? ListTile(
title: Text(allEntries[index].fullText),
onTap: () {
widget.scrollController.scrollTo(
index: allEntries[index].index,
duration: const Duration(milliseconds: 250),
curve: Curves.ease,
);
if (Platform.isAndroid) {
widget.closeLeftPaneCallback();
}
},
)
: _buildTocItem(allEntries[index], showFullText: true),
);
});
}

Widget _buildTocItem(TocEntry entry) {
Widget _buildTocItem(TocEntry entry, {bool showFullText = false}) {
void navigateToEntry() {
widget.scrollController.scrollTo(
index: entry.index,
Expand Down Expand Up @@ -95,7 +97,7 @@ class _TocViewerState extends State<TocViewer>
initiallyExpanded: entry.level == 1,
title: GestureDetector(
onTap: navigateToEntry,
child: Text(entry.text),
child: Text(showFullText ? entry.fullText : entry.text),
),
leading: const Icon(Icons.chevron_right_rounded),
trailing: const SizedBox.shrink(),
Expand Down

0 comments on commit 01a7032

Please sign in to comment.