HopSpotFrontend/lib/pages/profile_settings.dart

111 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:pvt15/pages/google_sign_in_page.dart';
import 'package:google_sign_in/google_sign_in.dart';
class ProfileSettings extends StatelessWidget {
final GoogleSignInAccount? user;
const ProfileSettings({super.key, required this.user});
@override
Widget build(BuildContext context) {
final name = user?.displayName ?? 'Ej inloggad';
final email = user?.email ?? 'Inte tillgänglig';
return Scaffold(
appBar: AppBar(title: const Text('Profil/Inställningar')),
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color(0xFFA800DB), Color(0xFFFF31E0)],
),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ListView(
shrinkWrap: true,
padding: const EdgeInsets.all(16),
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(
Icons.account_circle,
size: 96,
color: Colors.grey,
),
const SizedBox(height: 8),
Text(
name,
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
fontSize: 32,
),
textAlign: TextAlign.center,
),
],
),
const SizedBox(height: 8),
_infoTile(
Icons.person,
user?.displayName ?? 'Ej inloggad',
'Användarnamn',
),
const SizedBox(height: 8),
_infoTile(
Icons.mail,
user?.email ?? 'Inte tillgänglig',
'E-mail',
),
],
),
Container(
width: 256,
margin: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(32),
),
child: ListTile(
leading: const Icon(Icons.logout),
title: const Text('Logga ut'),
onTap: () async {
await GoogleSignIn().signOut();
Navigator.of(context).pushReplacement(
MaterialPageRoute(builder: (context) => GoogleSignInPage()),
);
},
),
),
],
),
),
);
}
Widget _infoTile(IconData icon, String title, String subtitle) {
return Container(
margin: const EdgeInsets.symmetric(vertical: 4),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(32),
),
child: ListTile(
leading: Icon(icon, size: 32, color: Colors.black),
title: Text(
title,
style: const TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
subtitle: Text(subtitle, style: const TextStyle(color: Colors.black)),
),
);
}
}