mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-03-11 17:25:32 +00:00
Fix "Show extensions" Button
The "Show extensions" Button was not working properly when categories were hidden.
An Exception would throw:
```
_AssertionError ('package:flutter/src/material/tab_controller.dart': Failed assertion: line 202 pos 12: 'value >= 0 && (value < length || length == 0)': is not true.)
```
And jump to the end of the tab list regardless of where you clicked the button.
This commit is contained in:
parent
42f1dcff92
commit
7664e38cfd
2 changed files with 15 additions and 7 deletions
|
|
@ -197,6 +197,7 @@ class _BrowseScreenState extends ConsumerState<BrowseScreen>
|
||||||
if (tab.kind == BrowseTabKind.sources) {
|
if (tab.kind == BrowseTabKind.sources) {
|
||||||
return SourcesScreen(
|
return SourcesScreen(
|
||||||
itemType: tab.type,
|
itemType: tab.type,
|
||||||
|
tabs: _tabList,
|
||||||
tabIndex: (index) => _tabBarController.animateTo(index),
|
tabIndex: (index) => _tabBarController.animateTo(index),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:mangayomi/modules/browse/browse_screen.dart';
|
||||||
import 'package:mangayomi/modules/widgets/custom_sliver_grouped_list_view.dart';
|
import 'package:mangayomi/modules/widgets/custom_sliver_grouped_list_view.dart';
|
||||||
import 'package:isar_community/isar.dart';
|
import 'package:isar_community/isar.dart';
|
||||||
import 'package:mangayomi/main.dart';
|
import 'package:mangayomi/main.dart';
|
||||||
|
|
@ -11,10 +12,12 @@ import 'package:mangayomi/utils/language.dart';
|
||||||
|
|
||||||
class SourcesScreen extends ConsumerStatefulWidget {
|
class SourcesScreen extends ConsumerStatefulWidget {
|
||||||
final Function(int) tabIndex;
|
final Function(int) tabIndex;
|
||||||
|
final List<BrowseTab> tabs;
|
||||||
final ItemType itemType;
|
final ItemType itemType;
|
||||||
const SourcesScreen({
|
const SourcesScreen({
|
||||||
required this.tabIndex,
|
required this.tabIndex,
|
||||||
required this.itemType,
|
required this.itemType,
|
||||||
|
required this.tabs,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -62,13 +65,17 @@ class _SourcesScreenState extends ConsumerState<SourcesScreen> {
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: () => widget.tabIndex(
|
onPressed: () {
|
||||||
widget.itemType == ItemType.manga
|
final extensionIndex = widget.tabs.indexWhere(
|
||||||
? 3
|
(t) =>
|
||||||
: widget.itemType == ItemType.anime
|
t.type == widget.itemType &&
|
||||||
? 4
|
t.kind == BrowseTabKind.extensions,
|
||||||
: 5,
|
);
|
||||||
),
|
|
||||||
|
if (extensionIndex != -1) {
|
||||||
|
widget.tabIndex(extensionIndex);
|
||||||
|
}
|
||||||
|
},
|
||||||
icon: const Icon(Icons.extension_rounded),
|
icon: const Icon(Icons.extension_rounded),
|
||||||
label: Text(context.l10n.show_extensions),
|
label: Text(context.l10n.show_extensions),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue