fix(01-10): fix home page syntax and add dependency
- Fixed all syntax errors in HomePage - Added flutter_riverpod dependency to pubspec.yaml - HomePage now properly uses AuthProvider for state management - Added proper confirmation dialog for logout - Added error display and loading states - Cleaned up null-aware operators and formatting
This commit is contained in:
@@ -15,7 +15,6 @@ class HomePage extends ConsumerWidget {
|
|||||||
final currentUser = authState.user;
|
final currentUser = authState.user;
|
||||||
final authNotifier = ref.read(authProvider.notifier);
|
final authNotifier = ref.read(authProvider.notifier);
|
||||||
|
|
||||||
return Scaffold(
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Sage'),
|
title: const Text('Sage'),
|
||||||
@@ -108,99 +107,100 @@ class HomePage extends ConsumerWidget {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (currentUser != null) ...[
|
if (currentUser != null) ...[
|
||||||
CircleAvatar(
|
CircleAvatar(
|
||||||
radius: 50,
|
radius: 50,
|
||||||
backgroundColor: Theme.of(context).colorScheme.primary,
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
child: Text(
|
child: Text(
|
||||||
(currentUser?.email.isNotEmpty ?? false)
|
(currentUser.email.isNotEmpty)
|
||||||
? currentUser!.email[0].toUpperCase()
|
? currentUser.email[0].toUpperCase()
|
||||||
: 'U',
|
: 'U',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 24,
|
fontSize: 24,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
Text(
|
Text(
|
||||||
'Welcome back!',
|
'Welcome back!',
|
||||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
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,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 18,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
const Text('• Barcode scanning\n• Inventory management\n• Expiration tracking'),
|
Text(
|
||||||
const SizedBox(height: 16),
|
currentUser.email,
|
||||||
ElevatedButton(
|
style: Theme.of(context).textTheme.bodyLarge?.copyWith(
|
||||||
onPressed: () {
|
color: Colors.grey[600],
|
||||||
// TODO: Navigate to inventory when implemented
|
),
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
),
|
||||||
const SnackBar(
|
] else ...[
|
||||||
content: Text('Inventory feature coming soon!'),
|
Icon(
|
||||||
),
|
Icons.account_circle,
|
||||||
);
|
size: 100,
|
||||||
},
|
color: Colors.grey[400],
|
||||||
child: const Text('Start Adding Items'),
|
),
|
||||||
|
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'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,6 +45,7 @@ dependencies:
|
|||||||
go_router: ^13.0.0
|
go_router: ^13.0.0
|
||||||
|
|
||||||
# State management
|
# State management
|
||||||
|
flutter_riverpod: ^2.5.0
|
||||||
riverpod: ^2.5.0
|
riverpod: ^2.5.0
|
||||||
|
|
||||||
# Secure storage for authentication tokens
|
# Secure storage for authentication tokens
|
||||||
|
|||||||
Reference in New Issue
Block a user