c829f78984
- Opprettet Flutter-prosjekt med alle nødvendige avhengigheter - Implementert datamodeller (User, TimeRegistration, TariffProfile, Deviation, AuditLog) - Implementert tjenester (AuthService, TimeService) - Implementert Riverpod providers for state management - Opprettet autentiseringsskjermer (login, signup, reset password) - Opprettet hjemmeskjerm med timer-funksjonalitet - Opprettet placeholder-skjermer for historikk, rapporter og profil - Lagt til norsk dokumentasjon i README
91 lines
3.0 KiB
Dart
91 lines
3.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../providers/auth_provider.dart';
|
|
|
|
class ProfileScreen extends ConsumerWidget {
|
|
const ProfileScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final userData = ref.watch(userDataProvider);
|
|
final signOut = ref.read(signOutProvider);
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Profil'),
|
|
),
|
|
body: userData.when(
|
|
data: (user) {
|
|
if (user == null) {
|
|
return const Center(child: Text('Ingen brukerdata'));
|
|
}
|
|
|
|
return ListView(
|
|
padding: const EdgeInsets.all(16.0),
|
|
children: [
|
|
Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Column(
|
|
children: [
|
|
CircleAvatar(
|
|
radius: 40,
|
|
child: Text(
|
|
user.displayName.isNotEmpty
|
|
? user.displayName[0].toUpperCase()
|
|
: '?',
|
|
style: const TextStyle(fontSize: 32),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
user.displayName,
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
),
|
|
Text(
|
|
user.email,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Colors.grey,
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Chip(
|
|
label: Text(
|
|
user.role.name == 'employee'
|
|
? 'Ansatt'
|
|
: user.role.name == 'admin'
|
|
? 'Administrator'
|
|
: 'Systemadministrator',
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.business),
|
|
title: const Text('Organisasjon'),
|
|
subtitle: Text(user.organizationId),
|
|
),
|
|
|
|
const Divider(),
|
|
|
|
ListTile(
|
|
leading: const Icon(Icons.logout),
|
|
title: const Text('Logg ut'),
|
|
onTap: () async {
|
|
await signOut();
|
|
},
|
|
),
|
|
],
|
|
);
|
|
},
|
|
loading: () => const Center(child: CircularProgressIndicator()),
|
|
error: (error, _) => Center(child: Text('Feil: $error')),
|
|
),
|
|
);
|
|
}
|
|
}
|