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
+16 -32
View File
@@ -1,5 +1,6 @@
import 'dart:async';
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -145,19 +146,17 @@ class AppRoutes {
/// the selected element (or null if dismissed). The timetable view renders
/// the chosen plan inline. Gated behind the `viewForeignTimetables`
/// capability at the call site.
static Future<TimetableElementRef?> openElementPicker(
static Future<TimetableElementRef?> openElementPicker(BuildContext context) =>
_pushForResult(context, const ElementPickerPage());
// pushScreen casts its internal MaterialPageRoute to `Route<T>`, which blows
// up for a concrete (record) T — so push untyped (T = dynamic, like every
// other caller) and cast the popped result ourselves.
static Future<T?> _pushForResult<T>(
BuildContext context,
) async {
// pushScreen casts its internal MaterialPageRoute to `Route<T>`, which
// blows up for a concrete (record) T — so push untyped (T = dynamic, like
// every other caller) and cast the popped result ourselves.
final result = await pushScreen(
context,
withNavBar: false,
screen: const ElementPickerPage(),
);
return result as TimetableElementRef?;
}
Widget screen,
) async =>
(await pushScreen(context, withNavBar: false, screen: screen)) as T?;
/// Opens the user/group picker for sharing a file and resolves to the chosen
/// recipient (or null if dismissed). Which kinds are offered is gated by the
@@ -166,19 +165,10 @@ class AppRoutes {
BuildContext context, {
required bool allowUsers,
required bool allowGroups,
}) async {
// Push untyped (T = dynamic) and cast the popped result ourselves —
// pushScreen can't carry a concrete non-Widget T (see openElementPicker).
final result = await pushScreen(
context,
withNavBar: false,
screen: ShareePickerPage(
allowUsers: allowUsers,
allowGroups: allowGroups,
),
);
return result as ShareeRef?;
}
}) => _pushForResult(
context,
ShareePickerPage(allowUsers: allowUsers, allowGroups: allowGroups),
);
static void openMarianumMessage(
BuildContext context,
@@ -452,13 +442,7 @@ class AppRoutes {
static GetRoomResponseObject? _findRoomByToken(
GetRoomResponse? rooms,
String token,
) {
if (rooms == null) return null;
for (final room in rooms.data) {
if (room.token == token) return room;
}
return null;
}
) => rooms?.data.firstWhereOrNull((room) => room.token == token);
/// Pushes a module from the "Mehr" tab list. Modules already in the bottom
/// bar are switched to via [goToTab] instead.