feat: add accessibility setting and conditionally disable animations

This commit is contained in:
Anton Stubenbord
2023-11-16 23:44:02 +01:00
parent a17f658df5
commit 12be81d93b
21 changed files with 304 additions and 77 deletions

View File

@@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart';
import 'package:go_router/go_router.dart';
import 'package:hive_flutter/adapters.dart';
import 'package:paperless_api/paperless_api.dart';
import 'package:paperless_mobile/accessibility/accessible_page.dart';
import 'package:paperless_mobile/core/database/hive/hive_config.dart';
import 'package:paperless_mobile/core/database/tables/global_settings.dart';
import 'package:paperless_mobile/core/database/tables/local_user_account.dart';
@@ -141,32 +142,39 @@ class AuthenticatedRoute extends ShellRouteData {
const AuthenticatedRoute();
@override
Widget builder(
Page<void> pageBuilder(
BuildContext context,
GoRouterState state,
Widget navigator,
) {
final currentUserId = Hive.box<GlobalSettings>(HiveBoxes.globalSettings)
.getValue()!
.loggedInUserId;
if (currentUserId == null) {
return const SizedBox.shrink();
}
final authenticatedUser =
Hive.box<LocalUserAccount>(HiveBoxes.localUserAccount).get(
currentUserId,
)!;
final apiFactory = context.read<PaperlessApiFactory>();
return HomeShellWidget(
localUserId: authenticatedUser.id,
paperlessApiVersion: authenticatedUser.apiVersion,
paperlessProviderFactory: apiFactory,
child: ChangeNotifierProvider(
create: (context) => ConsumptionChangeNotifier()
..loadFromConsumptionDirectory(userId: currentUserId),
child: EventListenerShell(
child: navigator,
),
return accessiblePlatformPage(
child: Builder(
builder: (context) {
final currentUserId =
Hive.box<GlobalSettings>(HiveBoxes.globalSettings)
.getValue()!
.loggedInUserId;
if (currentUserId == null) {
return const SizedBox.shrink();
}
final authenticatedUser =
Hive.box<LocalUserAccount>(HiveBoxes.localUserAccount).get(
currentUserId,
)!;
final apiFactory = context.read<PaperlessApiFactory>();
return HomeShellWidget(
localUserId: authenticatedUser.id,
paperlessApiVersion: authenticatedUser.apiVersion,
paperlessProviderFactory: apiFactory,
child: ChangeNotifierProvider(
create: (context) => ConsumptionChangeNotifier()
..loadFromConsumptionDirectory(userId: currentUserId),
child: EventListenerShell(
child: navigator,
),
),
);
},
),
);
}