conflicts resolution
This commit is contained in:
@@ -6,16 +6,19 @@ import 'package:cached_network_image/cached_network_image.dart';
|
||||
|
||||
import 'package:pshared/provider/account.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class AccountAvatar extends StatelessWidget {
|
||||
const AccountAvatar({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
return Consumer<AccountProvider>(
|
||||
builder: (context, provider, _) => UserAccountsDrawerHeader(
|
||||
accountName: Text(provider.account?.name ?? 'John Doe'),
|
||||
accountEmail: Text(provider.account?.login ?? 'john.doe@acme.com'),
|
||||
accountName: Text(provider.account?.name ?? loc.userNamePlaceholder),
|
||||
accountEmail: Text(provider.account?.login ?? loc.usernameHint),
|
||||
currentAccountPicture: CircleAvatar(
|
||||
backgroundImage: (provider.account?.avatarUrl?.isNotEmpty ?? false)
|
||||
? CachedNetworkImageProvider(provider.account!.avatarUrl!)
|
||||
|
||||
@@ -13,4 +13,4 @@ T? protectedWidgetctx<T extends Widget>(BuildContext context, ResourceType resou
|
||||
|
||||
T? protectedWidget<T extends Widget>(PermissionsProvider provider, ResourceType resource, T child, {perm.Action? action}) {
|
||||
return provider.canAccessResource(resource, action: action) ? child : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ enum PayoutDestination {
|
||||
case PayoutDestination.addrecipient:
|
||||
return loc.addRecipient;
|
||||
case PayoutDestination.editwallet:
|
||||
return 'Edit Wallet';
|
||||
return loc.editWallet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:pshared/models/resources.dart';
|
||||
|
||||
import 'package:pshared/provider/account.dart';
|
||||
import 'package:pshared/provider/permissions.dart';
|
||||
|
||||
import 'package:pweb/pages/address_book/form/page.dart';
|
||||
import 'package:pweb/pages/address_book/page/page.dart';
|
||||
@@ -13,25 +15,50 @@ import 'package:pweb/pages/report/page.dart';
|
||||
import 'package:pweb/pages/settings/profile/page.dart';
|
||||
import 'package:pweb/pages/dashboard/dashboard.dart';
|
||||
import 'package:pweb/providers/page_selector.dart';
|
||||
import 'package:pweb/app/router/pages.dart';
|
||||
import 'package:pweb/widgets/appbar/app_bar.dart';
|
||||
import 'package:pweb/widgets/sidebar/destinations.dart';
|
||||
import 'package:pweb/widgets/sidebar/sidebar.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class PageSelector extends StatelessWidget {
|
||||
const PageSelector({super.key});
|
||||
|
||||
void _logout(BuildContext context) => context.read<AccountProvider>().logout();
|
||||
void _logout(BuildContext context) {
|
||||
context.read<AccountProvider>().logout();
|
||||
navigateAndReplace(context, Pages.login);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Consumer<PageSelectorProvider>(builder:(context, provider, _) {
|
||||
Widget build(BuildContext context) {
|
||||
final provider = context.watch<PageSelectorProvider>();
|
||||
final permissions = context.watch<PermissionsProvider>();
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
|
||||
final bool restrictedAccess = !permissions.canRead(ResourceType.chainWallets);
|
||||
final allowedDestinations = restrictedAccess
|
||||
? <PayoutDestination>{
|
||||
PayoutDestination.settings,
|
||||
PayoutDestination.methods,
|
||||
PayoutDestination.editwallet,
|
||||
}
|
||||
: PayoutDestination.values.toSet();
|
||||
|
||||
final selected = allowedDestinations.contains(provider.selected)
|
||||
? provider.selected
|
||||
: (restrictedAccess ? PayoutDestination.settings : PayoutDestination.dashboard);
|
||||
|
||||
if (selected != provider.selected) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => provider.selectPage(selected));
|
||||
}
|
||||
|
||||
Widget content;
|
||||
switch (provider.selected) {
|
||||
switch (selected) {
|
||||
case PayoutDestination.dashboard:
|
||||
content = DashboardPage(
|
||||
onRecipientSelected: (recipient) =>
|
||||
provider.selectRecipient(recipient),
|
||||
onRecipientSelected: (recipient) => provider.selectRecipient(recipient),
|
||||
onGoToPaymentWithoutRecipient: provider.startPaymentWithoutRecipient,
|
||||
);
|
||||
break;
|
||||
@@ -79,16 +106,16 @@ class PageSelector extends StatelessWidget {
|
||||
? WalletEditPage(
|
||||
onBack: provider.goBackFromWalletEdit,
|
||||
)
|
||||
: const Center(child: Text('No wallet selected')); //TODO Localize
|
||||
: Center(child: Text(loc.noWalletSelected));
|
||||
break;
|
||||
|
||||
default:
|
||||
content = Text(provider.selected.name);
|
||||
content = Text(selected.name);
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: PayoutAppBar(
|
||||
title: Text(provider.selected.localizedLabel(context)),
|
||||
title: Text(selected.localizedLabel(context)),
|
||||
onAddFundsPressed: () {},
|
||||
onLogout: () => _logout(context),
|
||||
),
|
||||
@@ -99,7 +126,7 @@ class PageSelector extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
PayoutSidebar(
|
||||
selected: provider.selected,
|
||||
selected: selected,
|
||||
onSelected: provider.selectPage,
|
||||
onLogout: () => _logout(context),
|
||||
),
|
||||
@@ -108,5 +135,5 @@ class PageSelector extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ class PayoutSidebar extends StatelessWidget {
|
||||
this.onLogout,
|
||||
this.userName,
|
||||
this.avatarUrl,
|
||||
this.items,
|
||||
});
|
||||
|
||||
final PayoutDestination selected;
|
||||
@@ -21,11 +22,13 @@ class PayoutSidebar extends StatelessWidget {
|
||||
|
||||
final String? userName;
|
||||
final String? avatarUrl;
|
||||
final List<PayoutDestination>? items;
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final items = [
|
||||
final menuItems = items ??
|
||||
<PayoutDestination>[
|
||||
PayoutDestination.dashboard,
|
||||
PayoutDestination.recipients,
|
||||
PayoutDestination.methods,
|
||||
@@ -49,11 +52,11 @@ class PayoutSidebar extends StatelessWidget {
|
||||
theme: theme,
|
||||
avatarUrl: avatarUrl,
|
||||
userName: userName,
|
||||
items: items,
|
||||
items: menuItems,
|
||||
selected: selected,
|
||||
onSelected: onSelected,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pweb/widgets/sidebar/destinations.dart';
|
||||
|
||||
import 'package:pweb/generated/i18n/app_localizations.dart';
|
||||
|
||||
|
||||
class UserProfileCard extends StatelessWidget {
|
||||
final ThemeData theme;
|
||||
@@ -21,6 +23,7 @@ class UserProfileCard extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
bool isSelected = selected == PayoutDestination.settings;
|
||||
final backgroundColor = isSelected
|
||||
? theme.colorScheme.primaryContainer
|
||||
@@ -52,7 +55,7 @@ class UserProfileCard extends StatelessWidget {
|
||||
const SizedBox(width: 8),
|
||||
Flexible(
|
||||
child: Text(
|
||||
userName ?? 'User Name',
|
||||
userName ?? loc.userNamePlaceholder,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w500,
|
||||
@@ -67,4 +70,4 @@ class UserProfileCard extends StatelessWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user