feat(l10n): localize rating place and favorite error messages

- add rating_place and error_try_again_later ARB keys (ru/en)
- use S.rating_place in profile screen, plan widget and author card
- use S.current.error_try_again_later in profile plans cubit
- hide rating badge when rating place is null instead of rendering null-й
- initialize localization in profile plans cubit test
This commit is contained in:
2026-11-20 17:42:03 +03:00
parent 0df474b2b5
commit 608016c8ad
10 changed files with 112 additions and 53 deletions

View File

@@ -9,6 +9,7 @@ import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
import 'package:eatvio_app/features/plans/repositories/plan_repository.dart';
import 'package:eatvio_app/features/plans/repositories/plans_repository.dart';
import 'package:eatvio_app/features/profile/presentation/bloc/plans_cubit/plans_state.dart';
import 'package:eatvio_app/generated/l10n.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class PlansCubit extends Cubit<PlansState> {
@@ -16,7 +17,6 @@ class PlansCubit extends Cubit<PlansState> {
final PlanRepository planRepository;
static const Duration _debounceDuration = Duration(milliseconds: 200);
static const String _favoriteErrorMessage = 'Произошла ошибка. Попробуйте ещё раз через некоторое время';
late final StreamSubscription<LikesState> likesStateSubscription;
late final StreamSubscription<FavoriteState> favoriteStateSubscription;
@@ -109,7 +109,7 @@ class PlansCubit extends Cubit<PlansState> {
await reportFrom(e, st, this);
if (isClosed) return;
_updatePlanBySlug(slug, (plan) => plan.copyWith(isFavorite: previousIsFavorite));
showErrorToast(_favoriteErrorMessage);
showErrorToast(S.current.error_try_again_later);
}
});
}

View File

@@ -205,24 +205,27 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
),
const SizedBox(width: 12),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
decoration: BoxDecoration(
color: const Color(0xFFF6FAFF),
borderRadius: BorderRadius.circular(12),
),
child: Text(
'${state.consultantInfo!.ratingPlace}-й в рейтинге',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: appTheme.blueA400,
if (state.consultantInfo!.ratingPlace != null)
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
decoration: BoxDecoration(
color: const Color(0xFFF6FAFF),
borderRadius: BorderRadius.circular(12),
),
child: Text(
S.of(context).rating_place(
state.consultantInfo!.ratingPlace!,
),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: appTheme.blueA400,
),
),
),
),
],
),
if (state
@@ -378,24 +381,27 @@ class _ProfileScreenState extends State<ProfileScreen> {
),
),
const SizedBox(width: 12),
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
decoration: BoxDecoration(
color: const Color(0xFFF6FAFF),
borderRadius: BorderRadius.circular(12),
),
child: Text(
'${consultantInfo.ratingPlace}-й в рейтинге',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: appTheme.blueA400,
if (consultantInfo.ratingPlace != null)
Container(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
decoration: BoxDecoration(
color: const Color(0xFFF6FAFF),
borderRadius: BorderRadius.circular(12),
),
child: Text(
S.of(context).rating_place(
consultantInfo.ratingPlace!,
),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: appTheme.blueA400,
),
),
),
),
],
),
if (consultantInfo.educationModel.hasMedicalEducation == 1)