Files
velocity-pay-flutter/lib/screens/profile_screen.dart
2025-06-10 22:17:38 +02:00

186 lines
5.3 KiB
Dart

import 'package:flutter/material.dart';
class ProfileScreen extends StatefulWidget {
const ProfileScreen({super.key});
@override
State<ProfileScreen> createState() => _ProfileScreenState();
}
class _ProfileScreenState extends State<ProfileScreen> {
final List<Map<String, dynamic>> _menuItems = [
{
'title': 'Personal Information',
'icon': Icons.person_outline,
'onTap': () {},
},
{
'title': 'Payment Methods',
'icon': Icons.credit_card_outlined,
'onTap': () {},
},
{
'title': 'Security',
'icon': Icons.lock_outline,
'onTap': () {},
},
{
'title': 'Notifications',
'icon': Icons.notifications_outlined,
'onTap': () {},
},
{
'title': 'Help & Support',
'icon': Icons.help_outline,
'onTap': () {},
},
{
'title': 'About',
'icon': Icons.info_outline,
'onTap': () {},
},
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBar(
expandedHeight: 200,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
background: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Theme.of(context).colorScheme.primary,
Theme.of(context).colorScheme.primary.withOpacity(0.8),
],
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(height: 40),
const CircleAvatar(
radius: 50,
backgroundColor: Colors.white,
child: Icon(
Icons.person,
size: 50,
color: Colors.grey,
),
),
const SizedBox(height: 16),
const Text(
'John Doe',
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 4),
Text(
'john.doe@example.com',
style: TextStyle(
color: Colors.white.withOpacity(0.8),
fontSize: 16,
),
),
],
),
),
),
),
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Text(
'Account Settings',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 16),
..._menuItems.map((item) => _buildMenuItem(item)),
const SizedBox(height: 24),
_buildLogoutButton(),
],
),
),
),
],
),
);
}
Widget _buildMenuItem(Map<String, dynamic> item) {
return Card(
margin: const EdgeInsets.only(bottom: 12),
child: ListTile(
leading: Icon(
item['icon'] as IconData,
color: Theme.of(context).colorScheme.primary,
),
title: Text(
item['title'] as String,
style: const TextStyle(
fontWeight: FontWeight.w500,
),
),
trailing: const Icon(Icons.chevron_right),
onTap: item['onTap'] as VoidCallback,
),
);
}
Widget _buildLogoutButton() {
return SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text('Logout'),
content: const Text('Are you sure you want to logout?'),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
TextButton(
onPressed: () {
Navigator.pop(context);
// TODO: Implement logout logic
},
child: const Text('Logout'),
),
],
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.error,
foregroundColor: Colors.white,
padding: const EdgeInsets.symmetric(vertical: 16),
),
child: const Text(
'Logout',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
);
}
}