284299b946
Complete Flutter app (Android + iOS) mirroring the web frontend: - Core: Riverpod state, Dio networking with auth interceptor + auto-refresh, go_router navigation, flutter_secure_storage, light/dark theme with MedievalSharp/Crimson Pro fonts, German l10n - Market: search with text/GPS/radius/date/sort filters, list + map views (flutter_map + OSM), detail screen with opening hours, admission prices, single-marker map, pagination - Auth: login (password + magic link tabs), register, OAuth button placeholders, 2FA code prompt on 401, sealed auth state provider - User: profile view/edit/delete with confirm dialog, 2FA setup/disable on security screen - GPS: geolocator with IP-based fallback (geojs.io) matching web behavior - Platform: Android internet + location permissions, iOS NSLocation description - Tests: date/currency/distance formatter unit tests (13 passing) - Zero analysis issues, debug APK builds successfully
34 lines
1023 B
Dart
34 lines
1023 B
Dart
import 'package:dio/dio.dart';
|
|
import '../../../core/config/api_config.dart';
|
|
import '../domain/models/profile_data.dart';
|
|
import '../domain/models/update_profile_request.dart';
|
|
|
|
class UserApi {
|
|
final Dio _dio;
|
|
|
|
UserApi(this._dio);
|
|
|
|
Future<ProfileData> getProfile() async {
|
|
final response = await _dio.get('${ApiConfig.apiPrefix}/users/me');
|
|
final data = (response.data as Map<String, dynamic>)['data'] as Map<String, dynamic>;
|
|
return ProfileData.fromJson(data);
|
|
}
|
|
|
|
Future<ProfileData> updateProfile(UpdateProfileRequest request) async {
|
|
final response = await _dio.patch(
|
|
'${ApiConfig.apiPrefix}/users/me',
|
|
data: request.toJson(),
|
|
);
|
|
final data = (response.data as Map<String, dynamic>)['data'] as Map<String, dynamic>;
|
|
return ProfileData.fromJson(data);
|
|
}
|
|
|
|
Future<void> deleteAccount() async {
|
|
await _dio.delete('${ApiConfig.apiPrefix}/users/me');
|
|
}
|
|
|
|
Future<void> restoreAccount() async {
|
|
await _dio.post('${ApiConfig.apiPrefix}/users/me/restore');
|
|
}
|
|
}
|