Remove outdated Flutter migration documents and add new technical descriptions and profile repository implementation

- Deleted `next_steps_flutter.md` and `teknisk_beskrivning_flutter.md` files as they were outdated.
- Added new `next_steps_flutter.md` and `teknisk_beskrivning_flutter.md` files with updated migration plans and technical descriptions for the Flutter frontend.
- Implemented `profile_repository.dart` to handle profile data retrieval and updates using the API.

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Nils-Johan Gynther
2026-04-23 16:40:02 +02:00
parent 6312fd5ce1
commit a5c13a4b3c
20 changed files with 2237 additions and 117 deletions
@@ -1,12 +1,122 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../../../core/api/api_error_mapper.dart';
import '../../data/profile_repository.dart';
class ProfileScreen extends StatelessWidget {
class ProfileScreen extends ConsumerStatefulWidget {
const ProfileScreen({super.key});
@override
ConsumerState<ProfileScreen> createState() => _ProfileScreenState();
}
class _ProfileScreenState extends ConsumerState<ProfileScreen> {
final _formKey = GlobalKey<FormState>();
String _username = '';
String _email = '';
bool _isLoading = true;
@override
void initState() {
super.initState();
_loadProfile();
}
Future<void> _loadProfile() async {
try {
final profile = await ref.read(profileRepositoryProvider).getProfile();
setState(() {
_username = profile['username'] ?? '';
_email = profile['email'] ?? '';
_isLoading = false;
});
} catch (e) {
_showErrorMessage(e);
setState(() {
_isLoading = false;
});
}
}
Future<void> _updateProfile() async {
if (_formKey.currentState!.validate()) {
_formKey.currentState!.save();
setState(() {
_isLoading = true;
});
try {
await ref.read(profileRepositoryProvider).updateProfile({
'username': _username,
'email': _email,
});
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Profil uppdaterad!')),
);
} catch (e) {
_showErrorMessage(e);
} finally {
setState(() {
_isLoading = false;
});
}
}
}
void _showErrorMessage(dynamic error) {
final message = mapErrorToUserMessage(error, context);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(message)),
);
}
@override
Widget build(BuildContext context) {
return const Center(
child: Text('Profilsida (grundversion)'),
return Scaffold(
appBar: AppBar(
title: const Text('Användarprofil'),
),
body: _isLoading
? const Center(child: CircularProgressIndicator())
: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
children: <Widget>[
TextFormField(
decoration: const InputDecoration(labelText: 'Användarnamn'),
initialValue: _username,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Ange ett användarnamn';
}
return null;
},
onSaved: (value) => _username = value!,
),
TextFormField(
decoration: const InputDecoration(labelText: 'E-post'),
initialValue: _email,
validator: (value) {
if (value == null || value.isEmpty) {
return 'Ange en e-postadress';
}
if (!RegExp(r'^[^@]+@[^@]+\.[^@]+').hasMatch(value)) {
return 'Ange en giltig e-postadress';
}
return null;
},
onSaved: (value) => _email = value!,
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: _updateProfile,
child: const Text('Spara'),
),
],
),
),
),
);
}
}