feat: Implement session management with SessionListener and integrate krow_data_connect

This commit is contained in:
Achintha Isuru
2026-02-17 15:19:08 -05:00
parent 8ce37d2306
commit 5b78f339a1
5 changed files with 209 additions and 84 deletions

View File

@@ -1,56 +1,16 @@
import 'dart:async';
import 'package:client_authentication/src/domain/repositories/auth_repository_interface.dart';
import 'package:design_system/design_system.dart';
import 'package:flutter/material.dart';
import 'package:flutter_modular/flutter_modular.dart';
import 'package:krow_core/core.dart';
class ClientIntroPage extends StatefulWidget {
class ClientIntroPage extends StatelessWidget {
const ClientIntroPage({super.key});
@override
State<ClientIntroPage> createState() => _ClientIntroPageState();
}
class _ClientIntroPageState extends State<ClientIntroPage> {
@override
void initState() {
super.initState();
_checkSession();
}
Future<void> _checkSession() async {
// Check session immediately without artificial delay
if (!mounted) return;
try {
final AuthRepositoryInterface authRepo =
Modular.get<AuthRepositoryInterface>();
// Add a timeout to prevent infinite loading
final user = true;
if (mounted) {
if (user != null) {
Modular.to.navigate(ClientPaths.home);
} else {
Modular.to.navigate(ClientPaths.getStarted);
}
}
} catch (e) {
debugPrint('ClientIntroPage: Session check error: $e');
if (mounted) {
Modular.to.navigate(ClientPaths.getStarted);
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.surface,
body: Center(
child: Image.asset(
'assets/logo-blue.png',
package: 'design_system',
UiImageAssets.logoBlue,
width: 120,
),
),