66 lines
2.0 KiB
Dart
66 lines
2.0 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:laba1/components/extensions/context_x.dart';
|
|
|
|
import '../components/utils/debounce.dart';
|
|
import 'comon/svg_objects.dart';
|
|
import 'home_page/bloc/bloc.dart';
|
|
import 'locale_bloc/locale_bloc.dart';
|
|
import 'locale_bloc/locale_events.dart';
|
|
import 'locale_bloc/locale_state.dart';
|
|
|
|
class Header extends StatelessWidget {
|
|
final TextEditingController searchController;
|
|
final String placeholder;
|
|
final ValueChanged<String> onChanged;
|
|
|
|
const Header({
|
|
Key? key,
|
|
required this.searchController,
|
|
required this.placeholder,
|
|
required this.onChanged,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Expanded(
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8),
|
|
child: CupertinoSearchTextField(
|
|
borderRadius: const BorderRadius.only(
|
|
bottomLeft: Radius.circular(20),
|
|
bottomRight: Radius.circular(20),
|
|
),
|
|
backgroundColor: Colors.amberAccent,
|
|
controller: searchController,
|
|
placeholder: placeholder,
|
|
onChanged: onChanged,
|
|
),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () =>
|
|
context.read<LocaleBloc>().add(const ChangeLocaleEvent()),
|
|
child: SizedBox.square(
|
|
dimension: 40,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(right: 8),
|
|
child: BlocBuilder<LocaleBloc, LocaleState>(
|
|
builder: (context, state) {
|
|
return state.currentLocale.languageCode == 'ru'
|
|
? const SvgRu()
|
|
: const SvgUk();
|
|
},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|