fix login
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/// Signed-in account details, sync status, and sign-out.
|
||||
/// Signed-in account details, sync status, bank link, and sign-out.
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -8,6 +8,7 @@ import '../providers/auth_provider.dart';
|
||||
import '../providers/bank_provider.dart';
|
||||
import '../providers/sync_provider.dart';
|
||||
import '../providers/tx_meta_provider.dart';
|
||||
import '../utils/connect_bank.dart';
|
||||
import '../utils/constants.dart';
|
||||
import '../widgets/responsive_body.dart';
|
||||
|
||||
@@ -89,12 +90,38 @@ class AccountScreen extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
bank.isLinked ? Icons.link : Icons.link_off_outlined,
|
||||
),
|
||||
title: const Text('Bank link'),
|
||||
subtitle: Text(
|
||||
bank.isLinked
|
||||
? 'Linked · ${bank.status.status}'
|
||||
: bank.hasData
|
||||
? 'Not linked · ${bank.transactions.length} synced txs on device'
|
||||
: 'Not linked · connect to fetch live balance and feed',
|
||||
),
|
||||
trailing: bank.isLinked
|
||||
? null
|
||||
: TextButton(
|
||||
onPressed: bank.isConnecting
|
||||
? null
|
||||
: () => runConnectBank(context, bank),
|
||||
child: Text(
|
||||
bank.isConnecting ? 'Opening…' : 'Connect',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
OutlinedButton.icon(
|
||||
onPressed: () async {
|
||||
await auth.logout();
|
||||
if (!context.mounted) return;
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
},
|
||||
icon: const Icon(Icons.logout),
|
||||
label: const Text('Sign out'),
|
||||
|
||||
@@ -11,7 +11,11 @@ import '../widgets/app_text_field.dart';
|
||||
import '../widgets/responsive_body.dart';
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({super.key});
|
||||
const LoginScreen({super.key, this.asRoot = false});
|
||||
|
||||
/// When true (cold start / auth gate), stay put on success so [AuthGate]
|
||||
/// rebuilds into the shell. When false, pop with `true` for modal sign-in.
|
||||
final bool asRoot;
|
||||
|
||||
@override
|
||||
State<LoginScreen> createState() => _LoginScreenState();
|
||||
@@ -43,7 +47,9 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
password: _passwordController.text,
|
||||
);
|
||||
if (!mounted) return;
|
||||
Navigator.of(context).pop(true);
|
||||
if (!widget.asRoot) {
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
} on ClientException catch (error) {
|
||||
if (!mounted) return;
|
||||
final message = error.response['message'] as String? ??
|
||||
@@ -66,19 +72,25 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: const Text('Sign in')),
|
||||
appBar: AppBar(
|
||||
title: const Text('Sign in'),
|
||||
automaticallyImplyLeading: !widget.asRoot,
|
||||
),
|
||||
body: ResponsiveBody(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.fromLTRB(16, 24, 16, 32),
|
||||
children: [
|
||||
Text(
|
||||
'Sync account',
|
||||
widget.asRoot ? 'Welcome to $kAppName' : 'Sync account',
|
||||
style: theme.textTheme.headlineSmall,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Sign in to link this device with PocketBase. Labels, notes, '
|
||||
'and bank transactions sync across your devices.',
|
||||
widget.asRoot
|
||||
? 'Sign in to sync labels, notes, and transactions across '
|
||||
'your devices. You can connect your bank afterward.'
|
||||
: 'Sign in to link this device with PocketBase. Labels, notes, '
|
||||
'and bank transactions sync across your devices.',
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
),
|
||||
|
||||
@@ -177,6 +177,34 @@ class SettingsScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
Text('Bank', style: theme.textTheme.titleMedium),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
bank.isLinked ? Icons.link : Icons.link_off_outlined,
|
||||
),
|
||||
title: const Text('Bank link'),
|
||||
subtitle: Text(
|
||||
bank.isLinked
|
||||
? 'Linked · ${bank.status.status}'
|
||||
: bank.hasData
|
||||
? 'Not linked · ${bank.transactions.length} synced txs on device'
|
||||
: 'Not linked · connect to fetch live balance and feed',
|
||||
),
|
||||
trailing: bank.isLinked
|
||||
? null
|
||||
: TextButton(
|
||||
onPressed: bank.isConnecting
|
||||
? null
|
||||
: () => runConnectBank(context, bank),
|
||||
child: Text(
|
||||
bank.isConnecting ? 'Opening…' : 'Connect',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
Text('Backend', style: theme.textTheme.titleMedium),
|
||||
const SizedBox(height: 8),
|
||||
Card(
|
||||
@@ -188,30 +216,6 @@ class SettingsScreen extends StatelessWidget {
|
||||
subtitle: Text(bank.apiBaseUrl),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
bank.isLinked
|
||||
? Icons.link
|
||||
: Icons.link_off_outlined,
|
||||
),
|
||||
title: const Text('Bank link'),
|
||||
subtitle: Text(
|
||||
bank.isLinked
|
||||
? 'Linked · ${bank.status.status}'
|
||||
: 'Not linked',
|
||||
),
|
||||
trailing: bank.isLinked
|
||||
? null
|
||||
: TextButton(
|
||||
onPressed: bank.isConnecting
|
||||
? null
|
||||
: () => runConnectBank(context, bank),
|
||||
child: Text(
|
||||
bank.isConnecting ? 'Opening…' : 'Connect',
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.open_in_browser_outlined),
|
||||
title: const Text('Enable Banking redirect'),
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
/// First route shown after launch. Hands off to [MainShell] after a short delay.
|
||||
/// First route shown after launch. Hands off to [AuthGate] after a short delay.
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../utils/constants.dart';
|
||||
import 'main_shell.dart';
|
||||
import 'auth_gate.dart';
|
||||
|
||||
/// Branded splash with a fade-in logo. Replaced by the bottom-nav shell.
|
||||
/// Branded splash with a fade-in logo. Replaced by the auth gate.
|
||||
class SplashScreen extends StatefulWidget {
|
||||
const SplashScreen({super.key});
|
||||
|
||||
@@ -32,17 +32,17 @@ class _SplashScreenState extends State<SplashScreen>
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeOutBack),
|
||||
);
|
||||
_controller.forward();
|
||||
_goToShell();
|
||||
_goToAuthGate();
|
||||
}
|
||||
|
||||
Future<void> _goToShell() async {
|
||||
Future<void> _goToAuthGate() async {
|
||||
await Future<void>.delayed(kSplashDuration);
|
||||
if (!mounted) return;
|
||||
Navigator.of(context).pushReplacement(
|
||||
PageRouteBuilder<void>(
|
||||
pageBuilder: (_, animation, _) => FadeTransition(
|
||||
opacity: animation,
|
||||
child: const MainShell(),
|
||||
child: const AuthGate(),
|
||||
),
|
||||
transitionDuration: const Duration(milliseconds: 400),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user