diff --git a/lib/Presentation/home_page/bloc/state.g.dart b/lib/Presentation/home_page/bloc/state.g.dart
index 258a914..114ac25 100644
--- a/lib/Presentation/home_page/bloc/state.g.dart
+++ b/lib/Presentation/home_page/bloc/state.g.dart
@@ -72,7 +72,8 @@ class _$HomeStateCWProxyImpl implements _$HomeStateCWProxy {
// ignore: cast_nullable_to_non_nullable
: isLoading as bool,
isPaginationLoading:
- isPaginationLoading == const $CopyWithPlaceholder() || isPaginationLoading == null
+ isPaginationLoading == const $CopyWithPlaceholder() ||
+ isPaginationLoading == null
? _value.isPaginationLoading
// ignore: cast_nullable_to_non_nullable
: isPaginationLoading as bool,
diff --git a/lib/Presentation/home_page/home_page.dart b/lib/Presentation/home_page/home_page.dart
index f48e881..138d0e5 100644
--- a/lib/Presentation/home_page/home_page.dart
+++ b/lib/Presentation/home_page/home_page.dart
@@ -1,9 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
+import 'package:labs_petrushin/Presentation/common/svg_objects.dart';
import 'package:labs_petrushin/Presentation/home_page/bloc/bloc.dart';
import 'package:labs_petrushin/Presentation/home_page/bloc/events.dart';
import 'package:labs_petrushin/Presentation/home_page/bloc/state.dart';
+import 'package:labs_petrushin/Presentation/locale_bloc/locale_bloc.dart';
+import 'package:labs_petrushin/Presentation/locale_bloc/locale_events.dart';
+import 'package:labs_petrushin/Presentation/locale_bloc/locale_state.dart';
import 'package:labs_petrushin/components/extensions/context_x.dart';
import '../../Presentation/detailPage.dart';
import '../../components/util/Debounce.dart';
@@ -77,11 +81,28 @@ class BodyState extends State
{
padding: const EdgeInsets.all(12),
child: CupertinoSearchTextField(
controller: searchController,
+ placeholder: context.locale.search,
onChanged: (search) {
Debounce.run(() => context.read().add(HomeLoadDataEvent(search: search)));
},
),
),
+ GestureDetector(
+ onTap: () => context.read().add(const ChangeLocaleEvent()),
+ child: SizedBox.square(
+ dimension: 50,
+ child: Padding(
+ padding: const EdgeInsets.only(right: 12),
+ child: BlocBuilder(
+ builder: (context, state) {
+ return state.currentLocale.languageCode == 'ru'
+ ? const SvgRu()
+ : const SvgUk();
+ },
+ ),
+ ),
+ ),
+ ),
BlocBuilder(
builder: (context, state) => state.error != null
? Text(
diff --git a/lib/Presentation/locale_bloc/locale_bloc.dart b/lib/Presentation/locale_bloc/locale_bloc.dart
new file mode 100644
index 0000000..8f8b1df
--- /dev/null
+++ b/lib/Presentation/locale_bloc/locale_bloc.dart
@@ -0,0 +1,19 @@
+import 'dart:async';
+import 'dart:ui';
+
+import 'package:labs_petrushin/components/locale/l10n/app_locale.dart';
+import 'package:labs_petrushin/Presentation/locale_bloc/locale_events.dart';
+import 'package:labs_petrushin/Presentation/locale_bloc/locale_state.dart';
+import 'package:flutter_bloc/flutter_bloc.dart';
+
+class LocaleBloc extends Bloc {
+ LocaleBloc(Locale defaultLocale) : super(LocaleState(currentLocale: defaultLocale)) {
+ on(_onChangeLocale);
+ }
+
+ FutureOr _onChangeLocale(ChangeLocaleEvent event, Emitter emit) async {
+ final toChange = AppLocale.supportedLocales
+ .firstWhere((e) => e.languageCode != state.currentLocale.languageCode);
+ emit(state.copyWith(currentLocale: toChange));
+ }
+}
\ No newline at end of file
diff --git a/lib/Presentation/locale_bloc/locale_events.dart b/lib/Presentation/locale_bloc/locale_events.dart
new file mode 100644
index 0000000..f345ef9
--- /dev/null
+++ b/lib/Presentation/locale_bloc/locale_events.dart
@@ -0,0 +1,7 @@
+abstract class LocaleEvent {
+ const LocaleEvent();
+}
+
+class ChangeLocaleEvent extends LocaleEvent {
+ const ChangeLocaleEvent();
+}
\ No newline at end of file
diff --git a/lib/Presentation/locale_bloc/locale_state.dart b/lib/Presentation/locale_bloc/locale_state.dart
new file mode 100644
index 0000000..9c26abe
--- /dev/null
+++ b/lib/Presentation/locale_bloc/locale_state.dart
@@ -0,0 +1,15 @@
+import 'package:equatable/equatable.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:copy_with_extension/copy_with_extension.dart';
+
+part 'locale_state.g.dart';
+
+@CopyWith()
+class LocaleState extends Equatable {
+ final Locale currentLocale;
+
+ const LocaleState({required this.currentLocale});
+
+ @override
+ List