sign in with pocketbase working

This commit is contained in:
davmar
2026-09-09 19:59:38 +02:00
parent ae464ff304
commit c6d1fdb19e
27 changed files with 1267 additions and 312 deletions
+80
View File
@@ -2,9 +2,88 @@
library;
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/auth_provider.dart';
import '../screens/account_screen.dart';
import '../screens/login_screen.dart';
import '../screens/settings_screen.dart';
Widget authAppBarAction(BuildContext context) {
final auth = context.watch<AuthController>();
if (auth.isLoggedIn) {
return PopupMenuButton<_AccountMenuAction>(
tooltip: auth.displayName,
offset: const Offset(0, 48),
onSelected: (action) async {
switch (action) {
case _AccountMenuAction.account:
await Navigator.of(context).push(
MaterialPageRoute<void>(builder: (_) => const AccountScreen()),
);
case _AccountMenuAction.logout:
await auth.logout();
}
},
itemBuilder: (context) {
final email = auth.email;
return [
if (email != null)
PopupMenuItem<_AccountMenuAction>(
enabled: false,
child: Text(
email,
style: Theme.of(context).textTheme.bodySmall,
),
),
const PopupMenuItem<_AccountMenuAction>(
value: _AccountMenuAction.account,
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: Icon(Icons.person_outline),
title: Text('Account'),
),
),
const PopupMenuItem<_AccountMenuAction>(
value: _AccountMenuAction.logout,
child: ListTile(
contentPadding: EdgeInsets.zero,
leading: Icon(Icons.logout),
title: Text('Sign out'),
),
),
];
},
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: CircleAvatar(
radius: 16,
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
child: Text(
auth.initials,
style: Theme.of(context).textTheme.labelLarge?.copyWith(
color: Theme.of(context).colorScheme.onPrimaryContainer,
),
),
),
),
);
}
return IconButton(
tooltip: 'Sign in',
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute<bool>(builder: (_) => const LoginScreen()),
);
},
icon: const Icon(Icons.person_outline),
);
}
enum _AccountMenuAction { account, logout }
List<Widget> bankAppBarActions({
required BuildContext context,
VoidCallback? onRefresh,
@@ -17,6 +96,7 @@ List<Widget> bankAppBarActions({
onPressed: refreshing ? null : onRefresh,
icon: const Icon(Icons.refresh),
),
authAppBarAction(context),
IconButton(
tooltip: 'Settings',
onPressed: () {