2024-08-21 12:28:48 +01:00
|
|
|
import 'package:flutter/material.dart';
|
2024-08-23 11:34:38 +01:00
|
|
|
import 'package:mobile/base/variables.dart';
|
|
|
|
import 'package:mobile/models.dart';
|
2024-08-22 12:28:24 +01:00
|
|
|
import 'base/sidemenu.dart';
|
2024-08-23 11:34:38 +01:00
|
|
|
import 'package:mobile/base/variables.dart';
|
|
|
|
|
|
|
|
|
2024-08-20 15:46:13 +01:00
|
|
|
|
2024-08-22 12:28:24 +01:00
|
|
|
|
|
|
|
class ProfilePage extends StatefulWidget {
|
|
|
|
|
2024-08-23 11:34:38 +01:00
|
|
|
const ProfilePage({super.key});
|
|
|
|
//const ProfilePage({super.key, required this.id});
|
|
|
|
|
2024-08-22 12:28:24 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
State<ProfilePage> createState() => _ProfilePageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ProfilePageState extends State<ProfilePage> {
|
2024-08-23 11:34:38 +01:00
|
|
|
late User userData;
|
2024-08-22 12:28:24 +01:00
|
|
|
|
2024-08-23 11:34:38 +01:00
|
|
|
@override
|
|
|
|
void initState() {
|
2024-08-22 12:28:24 +01:00
|
|
|
super.initState();
|
|
|
|
|
2024-08-23 11:34:38 +01:00
|
|
|
// Check if the user is logged in when the page is entered
|
|
|
|
if (loggedIn == false) {
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
const SnackBar(content: Text('Please log in')));
|
|
|
|
Navigator.pushReplacementNamed(context, '/login');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
userData = user!;
|
2024-08-22 12:28:24 +01:00
|
|
|
});
|
2024-08-23 11:34:38 +01:00
|
|
|
}
|
2024-08-22 12:28:24 +01:00
|
|
|
|
|
|
|
|
2024-08-23 11:34:38 +01:00
|
|
|
|
2024-08-21 12:28:48 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-08-22 12:28:24 +01:00
|
|
|
return SideMenu(
|
|
|
|
selectedIndex: 2,
|
|
|
|
body: Stack(
|
|
|
|
children: [
|
|
|
|
const Align(
|
|
|
|
alignment: Alignment.topLeft,
|
|
|
|
child: Padding(
|
|
|
|
padding: EdgeInsets.all(16.0),
|
|
|
|
child: Text(
|
|
|
|
'Your Profile',
|
|
|
|
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Center(
|
|
|
|
child: Column(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
const Icon(
|
|
|
|
Icons.account_circle,
|
|
|
|
size: 100,
|
|
|
|
color: Colors.grey,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 20),
|
|
|
|
const Text(
|
|
|
|
'Username',
|
|
|
|
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
const Text(
|
|
|
|
'email@example.com',
|
|
|
|
style: TextStyle(fontSize: 16, color: Colors.grey),
|
|
|
|
),
|
|
|
|
const SizedBox(height: 50),
|
|
|
|
ElevatedButton(
|
|
|
|
onPressed: () {
|
|
|
|
// Add your edit action here
|
|
|
|
},
|
|
|
|
child: const Text('Edit'),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
2024-08-21 12:28:48 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|