Compare commits
2 commits
6b70116a63
...
58e79147c7
| Author | SHA1 | Date | |
|---|---|---|---|
| 58e79147c7 | |||
| c290c268e8 |
6 changed files with 29 additions and 80 deletions
|
|
@ -42,6 +42,7 @@ class ErrorHandler {
|
|||
}
|
||||
|
||||
static void showErrorSnackBar(BuildContext context, Object error) {
|
||||
if (!context.mounted) return;
|
||||
final scaffoldMessenger = ScaffoldMessenger.of(context);
|
||||
scaffoldMessenger.hideCurrentSnackBar();
|
||||
|
||||
|
|
|
|||
|
|
@ -286,19 +286,19 @@ class _ProfileScreenState extends ConsumerState<ProfileScreen> {
|
|||
final l10n = AppLocalizations.of(context)!;
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(title, style: const TextStyle(color: AppTheme.errorColor)),
|
||||
content: Text(content),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(l10n.commonCancel),
|
||||
),
|
||||
ElevatedButton(
|
||||
style:
|
||||
ElevatedButton.styleFrom(backgroundColor: AppTheme.errorColor),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(dialogContext);
|
||||
onConfirm();
|
||||
},
|
||||
child: Text(l10n.commonConfirm),
|
||||
|
|
|
|||
|
|
@ -253,13 +253,13 @@ class _HubScreenState extends ConsumerState<HubScreen> {
|
|||
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(l10n.multiplayerTitle),
|
||||
content: Text(l10n.multiplayerDescription),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(dialogContext);
|
||||
_showJoinCodeDialog();
|
||||
},
|
||||
child: Text(l10n.multiplayerJoinButton),
|
||||
|
|
@ -268,14 +268,14 @@ class _HubScreenState extends ConsumerState<HubScreen> {
|
|||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppTheme.primaryColor),
|
||||
onPressed: () async {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(dialogContext);
|
||||
try {
|
||||
final party =
|
||||
await ref.read(partyRepositoryProvider).createParty();
|
||||
if (mounted) context.go('/lobby/${party.id}');
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
if (mounted) ErrorHandler.showErrorSnackBar(context, e);
|
||||
ErrorHandler.showErrorSnackBar(context, e);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -293,7 +293,7 @@ class _HubScreenState extends ConsumerState<HubScreen> {
|
|||
final controller = TextEditingController();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(l10n.multiplayerEnterCodeTitle),
|
||||
content: TextField(
|
||||
controller: controller,
|
||||
|
|
@ -305,21 +305,21 @@ class _HubScreenState extends ConsumerState<HubScreen> {
|
|||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
onPressed: () => Navigator.pop(dialogContext),
|
||||
child: Text(l10n.multiplayerCancelAction),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final code = controller.text.trim().toUpperCase();
|
||||
if (code.isNotEmpty) {
|
||||
Navigator.pop(context);
|
||||
Navigator.pop(dialogContext);
|
||||
try {
|
||||
final party =
|
||||
await ref.read(partyRepositoryProvider).joinParty(code);
|
||||
if (mounted) context.go('/lobby/${party.id}');
|
||||
} catch (e) {
|
||||
if (mounted) {
|
||||
if (mounted) ErrorHandler.showErrorSnackBar(context, e);
|
||||
ErrorHandler.showErrorSnackBar(context, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,11 @@ class PartyRepository {
|
|||
});
|
||||
},
|
||||
onCancel: () async {
|
||||
await unsubscribe?.call();
|
||||
try {
|
||||
await unsubscribe?.call();
|
||||
} catch (e) {
|
||||
log('Safe ignore: Unsubscribe error (likely already disconnected): $e');
|
||||
}
|
||||
log('🔌 Unsubscribed from party $partyId');
|
||||
},
|
||||
);
|
||||
|
|
@ -120,7 +124,11 @@ class PartyRepository {
|
|||
});
|
||||
},
|
||||
onCancel: () async {
|
||||
await unsubscribe?.call();
|
||||
try {
|
||||
await unsubscribe?.call();
|
||||
} catch (e) {
|
||||
log('Safe ignore: Unsubscribe error (likely already disconnected): $e');
|
||||
}
|
||||
log('🔌 Unsubscribed from party members $partyId');
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -141,11 +141,11 @@ class _BattleScreenState extends ConsumerState<BattleScreen> {
|
|||
|
||||
final controller = ref.read(battleControllerProvider.notifier);
|
||||
final battleState = ref.read(battleControllerProvider);
|
||||
|
||||
|
||||
if (battleState.isResting) {
|
||||
controller.tickRest();
|
||||
final newState = ref.read(battleControllerProvider);
|
||||
|
||||
|
||||
if (newState.isResting) {
|
||||
_runRestTimer();
|
||||
} else {
|
||||
|
|
@ -254,7 +254,7 @@ class _BattleScreenState extends ConsumerState<BattleScreen> {
|
|||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => AlertDialog(
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(l10n.battleRaidComplete),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
@ -267,7 +267,7 @@ class _BattleScreenState extends ConsumerState<BattleScreen> {
|
|||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'+$xpEarned XP',
|
||||
style: Theme.of(context).textTheme.headlineMedium?.copyWith(
|
||||
style: Theme.of(dialogContext).textTheme.headlineMedium?.copyWith(
|
||||
color: AppTheme.primaryColor,
|
||||
),
|
||||
),
|
||||
|
|
@ -276,7 +276,7 @@ class _BattleScreenState extends ConsumerState<BattleScreen> {
|
|||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(dialogContext).pop();
|
||||
context.go('/hub');
|
||||
},
|
||||
child: Text(l10n.battleBackToHub),
|
||||
|
|
@ -1079,7 +1079,8 @@ class _BattleScreenState extends ConsumerState<BattleScreen> {
|
|||
children: [
|
||||
_InfoBox(
|
||||
label: l10n.battleWeight,
|
||||
value: '${currentSet.targetWeightTotal} kg',
|
||||
value:
|
||||
'${currentSet.targetWeightTotal} ${l10n.unitKg}',
|
||||
),
|
||||
_InfoBox(
|
||||
label: l10n.battleReps,
|
||||
|
|
|
|||
|
|
@ -1,60 +1,3 @@
|
|||
// import 'dart:convert';
|
||||
// import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
// import 'package:pocketbase/pocketbase.dart';
|
||||
|
||||
// class PbAuthStore extends AuthStore {
|
||||
// final FlutterSecureStorage _storage;
|
||||
// final String _storageKey;
|
||||
|
||||
// PbAuthStore({
|
||||
// FlutterSecureStorage? storage,
|
||||
// String key = 'pb_auth',
|
||||
// }) : _storage = storage ?? const FlutterSecureStorage(),
|
||||
// _storageKey = key,
|
||||
// super();
|
||||
|
||||
// @override
|
||||
// Future<void> save(String newToken, dynamic newRecord) async {
|
||||
// super.save(newToken, newRecord);
|
||||
|
||||
// final encoded = jsonEncode(<String, dynamic>{
|
||||
// 'token': newToken,
|
||||
// 'model': newRecord,
|
||||
// });
|
||||
|
||||
// await _storage.write(key: _storageKey, value: encoded);
|
||||
// }
|
||||
|
||||
// @override
|
||||
// void clear() {
|
||||
// super.clear();
|
||||
// _storage.delete(key: _storageKey);
|
||||
// }
|
||||
|
||||
// Future<void> loadFromStorage() async {
|
||||
// final raw = await _storage.read(key: _storageKey);
|
||||
// if (raw != null && raw.isNotEmpty) {
|
||||
// try {
|
||||
// final decoded = jsonDecode(raw) as Map<String, dynamic>;
|
||||
// final token = decoded['token'] as String?;
|
||||
// final model = decoded['model'];
|
||||
|
||||
// if (token != null && token.isNotEmpty) {
|
||||
// super.save(token, model);
|
||||
// return;
|
||||
// }
|
||||
// } catch (_) {
|
||||
// clear();
|
||||
// }
|
||||
// }
|
||||
|
||||
// const legacyKey = 'auth_token';
|
||||
// final legacyToken = await _storage.read(key: legacyKey);
|
||||
// if (legacyToken != null && legacyToken.isNotEmpty) {
|
||||
// super.save(legacyToken, null);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
import 'dart:convert';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
|
|
@ -87,7 +30,6 @@ class PbAuthStore extends AuthStore {
|
|||
await _storage.delete(key: _saveKey);
|
||||
}
|
||||
|
||||
// Diese Methode rufen wir VOR App-Start auf!
|
||||
Future<void> loadFromStorage() async {
|
||||
final raw = await _storage.read(key: _saveKey);
|
||||
if (raw != null && raw.isNotEmpty) {
|
||||
|
|
@ -106,11 +48,8 @@ class PbAuthStore extends AuthStore {
|
|||
}
|
||||
}
|
||||
|
||||
// super.save schreibt nur in den Speicher (RAM) des AuthStores,
|
||||
// löst aber kein erneutes 'save' (und damit write) aus.
|
||||
super.save(token, model);
|
||||
} catch (e) {
|
||||
// Daten korrupt? Löschen.
|
||||
await clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue