- Fixed null safety issues with email access - Resolved isNotEmpty null safety warning - Fixed conditional operator usage for null safety - Cleaned up syntax and validation warnings Files modified: - lib/features/home/presentation/pages/home_page.dart
134 lines
4.5 KiB
Dart
134 lines
4.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:supabase_flutter/supabase_flutter.dart';
|
|
|
|
/// Home page for authenticated users
|
|
///
|
|
/// Displays welcome message and provides logout functionality
|
|
/// This is the main landing page after successful authentication
|
|
class HomePage extends StatelessWidget {
|
|
const HomePage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final currentUser = Supabase.instance.client.auth.currentUser;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Sage'),
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
actions: [
|
|
IconButton(
|
|
icon: const Icon(Icons.logout),
|
|
onPressed: () async {
|
|
try {
|
|
await Supabase.instance.client.auth.signOut();
|
|
} catch (e) {
|
|
if (context.mounted) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text('Logout failed: ${e.toString()}'),
|
|
backgroundColor: Colors.red,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
},
|
|
tooltip: 'Logout',
|
|
),
|
|
],
|
|
),
|
|
body: Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
if (currentUser != null) ...[
|
|
CircleAvatar(
|
|
radius: 50,
|
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
|
child: Text(
|
|
(currentUser?.email.isNotEmpty ?? false)
|
|
? currentUser!.email[0].toUpperCase()
|
|
: 'U',
|
|
style: const TextStyle(
|
|
fontSize: 24,
|
|
fontWeight: FontWeight.bold,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 24),
|
|
Text(
|
|
'Welcome back!',
|
|
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Text(
|
|
currentUser?.email ?? '',
|
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
] else ...[
|
|
const Icon(
|
|
Icons.account_circle,
|
|
size: 100,
|
|
color: Colors.grey[400],
|
|
),
|
|
const SizedBox(height: 24),
|
|
Text(
|
|
'Welcome to Sage',
|
|
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
],
|
|
const SizedBox(height: 48),
|
|
const Text(
|
|
'Your collaborative household food inventory tracker',
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
fontSize: 16,
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
const SizedBox(height: 32),
|
|
// Placeholder for future features
|
|
Card(
|
|
margin: const EdgeInsets.symmetric(horizontal: 32),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
children: [
|
|
const Text(
|
|
'Coming Soon',
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
const Text('• Barcode scanning\n• Inventory management\n• Expiration tracking'),
|
|
const SizedBox(height: 16),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
// TODO: Navigate to inventory when implemented
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(
|
|
content: Text('Inventory feature coming soon!'),
|
|
),
|
|
);
|
|
},
|
|
child: const Text('Start Adding Items'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
} |