reworked operation (#12)
Reviewed-on: #12 Co-authored-by: Mark M2 Macbook <marco@catelli.it> Co-committed-by: Mark M2 Macbook <marco@catelli.it>
This commit is contained in:
20
lib/core/utils/app_message.dart
Normal file
20
lib/core/utils/app_message.dart
Normal file
@@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/core/utils/extensions.dart';
|
||||
|
||||
class AppMessage {
|
||||
final String key;
|
||||
final String? argument;
|
||||
|
||||
const AppMessage({required this.key, this.argument});
|
||||
|
||||
String translatedMessage(BuildContext context) {
|
||||
switch (key) {
|
||||
case 'authCubitCheckEmailToConfirmAccount':
|
||||
return context.l10n.authCubitCheckEmailToConfirmAccount;
|
||||
case 'authCubitResetPasswordEmailSentTo':
|
||||
return context.l10n.authCubitResetPasswordEmailSentTo(argument!);
|
||||
default:
|
||||
return 'empty message';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flux/l10n/app_localizations.dart';
|
||||
|
||||
extension MyStringExtensions on String? {
|
||||
// Gestiamo anche il nullable per sicurezza
|
||||
String myFormat() {
|
||||
@@ -40,3 +43,7 @@ extension MyStringExtensions on String? {
|
||||
.join('.'); // Ritorna tutto tranne l'ultima parte
|
||||
}
|
||||
}
|
||||
|
||||
extension LocalizationExtension on BuildContext {
|
||||
AppLocalizations get l10n => AppLocalizations.of(this)!;
|
||||
}
|
||||
Reference in New Issue
Block a user