edit profile picture updated to dispaly picture

This commit is contained in:
LilleBRG 2024-09-09 16:48:37 +02:00
parent ff8dd55d18
commit c2df5ec80e
2 changed files with 47 additions and 14 deletions

View File

@ -143,10 +143,6 @@ class _ProfilePageState extends State<EditProfilePage> {
Navigator.of(context).pop();
Navigator.pushReplacementNamed(context, '/register');
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Something went wrong! Please contact an admin.')),
);
}
},
),
@ -188,16 +184,46 @@ class _ProfilePageState extends State<EditProfilePage> {
controller: confirmPasswordInput,
decoration: InputDecoration(labelText: 'Repeat new password'),
),
Row(
children: [
ElevatedButton(onPressed: _pickImageFromGallery, child: Text('Gallery')),
ElevatedButton(onPressed: _pickImageFromCamera, child: Text('Camera'))
],
),
SizedBox(height: 20),
Text('ProfilePicture:'),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('ProfilePicture',
style: TextStyle(fontSize: 17)),
if (_selectedImage != null)
ClipOval(
child: Image(
image: FileImage(_selectedImage!),
height: 100,
width: 100,
fit: BoxFit.cover,
),
)
else
ClipOval(
child: Image(
image: NetworkImage(user!.profilePicture),
height: 100,
width: 100,
fit: BoxFit.cover,
),
),
if (_selectedImage != null)
Text(_selectedImage!.path.toString()),
//until here
Row(
children: [
Text('Change using'),
TextButton(onPressed: _pickImageFromGallery, child: Text('Gallery')),
SizedBox(width: 5),
Text('or'),
SizedBox(width: 5),
TextButton(onPressed: _pickImageFromCamera, child: Text('Camera'))
],
),
],
),
SizedBox(height: 40),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [

View File

@ -74,12 +74,19 @@ class _ProfilePageState extends State<ProfilePage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
userData?.profilePicture != null ?
const Icon(
ClipOval(
child: Image(
image: NetworkImage(userData!.profilePicture),
height: 100,
width: 100, // Ensure width matches the height to make it fully round
fit: BoxFit.cover, // This makes sure the image fits inside the circle properly
),
)
: const Icon(
Icons.account_circle,
size: 100,
color: Colors.grey,
)
: Image(image: NetworkImage('https://pub-bf709b641048489ca70f693673e3e04c.r2.dev/h4picturebucket/PPb83569bef3b9470782d7b42bc4e552ff.png'), height: 100),
),
const SizedBox(height: 20),
Text(
userData!.username,