simplified code across the app and consolidated duplicated helpers

This commit is contained in:
2026-09-27 17:29:54 +02:00
parent 3e856d0b1c
commit ee1240f71a
155 changed files with 1772 additions and 2546 deletions
+13 -25
View File
@@ -177,9 +177,7 @@ class AppModule {
for (final missing in Modules.values) {
if (!seen.add(missing)) continue;
var insertAt = 0;
for (final predecessor in Modules.values.takeWhile(
(m) => m != missing,
)) {
for (final predecessor in Modules.values.takeWhile((m) => m != missing)) {
final pos = order.indexOf(predecessor);
if (pos >= insertAt) insertAt = pos + 1;
}
@@ -231,33 +229,26 @@ class AppModule {
static const int minBottomBarSlots = 3;
static const int maxBottomBarSlots = 5;
static int resolveBottomBarSlotCount(BuildContext context) {
static int _slotCount(BuildContext context, int available) {
final settings = context.read<SettingsCubit>().val().modulesSettings;
final available = modules(context).length;
int desired;
if (settings.autoFillBottomBar) {
// 4 content tabs so the bar shows 5 entries including "Mehr" — enough
// for the Ticker module without pushing "Dateien" into the overflow.
desired = 4;
} else {
desired = settings.fixedBottomBarSlots;
}
desired = desired.clamp(minBottomBarSlots, maxBottomBarSlots);
return desired.clamp(0, available);
// 4 content tabs so the bar shows 5 entries including "Mehr" — enough
// for the Ticker module without pushing "Dateien" into the overflow.
final desired = settings.autoFillBottomBar
? 4
: settings.fixedBottomBarSlots;
return desired
.clamp(minBottomBarSlots, maxBottomBarSlots)
.clamp(0, available);
}
static List<AppModule> getBottomBarModules(BuildContext context) {
final all = modules(context).values.toList();
final slots = resolveBottomBarSlotCount(context);
return all.take(slots).toList();
return all.take(_slotCount(context, all.length)).toList();
}
static List<AppModule> getOverhangModules(BuildContext context) {
final all = modules(context).values.toList();
final slots = resolveBottomBarSlotCount(context);
return all.skip(slots).toList();
return all.skip(_slotCount(context, all.length)).toList();
}
Widget toListTile(
@@ -290,10 +281,7 @@ class AppModule {
: const Icon(Icons.arrow_right),
);
PersistentTabConfig toBottomTab(
BuildContext context, {
Widget Function(IconData icon)? iconBuilder,
}) => PersistentTabConfig(
PersistentTabConfig toBottomTab(BuildContext context) => PersistentTabConfig(
screen: Breaker(breaker: breakerArea, child: create()),
item: ItemConfig(
activeForegroundColor: Theme.of(context).primaryColor,