Navigation now flows entirely through go_router
This commit is contained in:
@@ -8,7 +8,6 @@ import 'package:pshared/models/resources.dart';
|
||||
import 'package:pshared/provider/permissions.dart';
|
||||
|
||||
import 'package:pweb/pages/loader.dart';
|
||||
import 'package:pweb/providers/page_selector.dart';
|
||||
import 'package:pweb/utils/logout.dart';
|
||||
import 'package:pweb/widgets/appbar/app_bar.dart';
|
||||
import 'package:pweb/widgets/sidebar/destinations.dart';
|
||||
@@ -32,9 +31,10 @@ class PageSelector extends StatelessWidget {
|
||||
final permissions = context.read<PermissionsProvider>();
|
||||
if (!permissions.isReady) return Center(child: CircularProgressIndicator());
|
||||
|
||||
final provider = context.watch<PageSelectorProvider>();
|
||||
|
||||
final bool restrictedAccess = !permissions.canRead(ResourceType.chainWallets);
|
||||
final fallbackDestination = restrictedAccess
|
||||
? PayoutDestination.settings
|
||||
: PayoutDestination.dashboard;
|
||||
final allowedDestinations = restrictedAccess
|
||||
? <PayoutDestination>{
|
||||
PayoutDestination.settings,
|
||||
@@ -44,10 +44,10 @@ class PageSelector extends StatelessWidget {
|
||||
}
|
||||
: PayoutDestination.values.toSet();
|
||||
|
||||
final routeDestination = _destinationFromState(routerState) ?? provider.selected;
|
||||
final selected = allowedDestinations.contains(routeDestination)
|
||||
final routeDestination = _destinationFromState(routerState);
|
||||
final selected = routeDestination != null && allowedDestinations.contains(routeDestination)
|
||||
? routeDestination
|
||||
: (restrictedAccess ? PayoutDestination.settings : PayoutDestination.dashboard);
|
||||
: fallbackDestination;
|
||||
|
||||
if (selected != routeDestination) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
@@ -55,10 +55,6 @@ class PageSelector extends StatelessWidget {
|
||||
});
|
||||
}
|
||||
|
||||
if (provider.selected != selected) {
|
||||
provider.syncDestination(selected);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: PayoutAppBar(
|
||||
title: Text(selected.localizedLabel(context)),
|
||||
|
||||
Reference in New Issue
Block a user