import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/common/text_field/custom_text_field.dart';
import 'package:syncrow_web/pages/routines/bloc/routine_bloc/routine_bloc.dart';
import 'package:syncrow_web/pages/routines/widgets/routines_title_widget.dart';
import 'package:syncrow_web/utils/color_manager.dart';
import 'package:syncrow_web/utils/helpers/responsice_layout_helper/responsive_layout_helper.dart';

class ConditionTitleAndSearchBar extends StatelessWidget with HelperResponsiveLayout {
  const ConditionTitleAndSearchBar({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    final isMedium = isMediumScreenSize(context);
    final isSmall = isSmallScreenSize(context);
    return isMedium || isSmall
        ? Wrap(
            spacing: 10,
            runSpacing: 10,
            children: [
              const TitleRoutine(title: 'Conditions', subtitle: '(IF)'),
              StatefulTextField(
                title: '',
                width: 250,
                height: 40,
                hintText: 'Search',
                elevation: 0,
                borderRadius: 15,
                icon: Icons.search,
                hintColor: ColorsManager.grayColor,
                boxDecoration: BoxDecoration(
                  color: ColorsManager.boxColor,
                  borderRadius: BorderRadius.circular(15),
                ),
                controller: TextEditingController(),
                // onSubmitted: (value) {
                //   context.read<RoutineBloc>().add(SearchRoutines(value));
                // },
                onChanged: (value) {
                  context.read<RoutineBloc>().add(SearchRoutines(value));
                },
              ),
            ],
          )
        : Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              const TitleRoutine(title: 'Conditions', subtitle: '(IF)'),
              StatefulTextField(
                title: '',
                width: 250,
                height: 40,
                hintText: 'Search',
                elevation: 0,
                borderRadius: 15,
                icon: Icons.search,
                hintColor: ColorsManager.grayColor,
                boxDecoration: BoxDecoration(
                  color: ColorsManager.boxColor,
                  borderRadius: BorderRadius.circular(15),
                ),
                controller: TextEditingController(),
                // onSubmitted: (value) {
                //   context.read<RoutineBloc>().add(SearchRoutines(value));
                // },
                onChanged: (value) {
                  context.read<RoutineBloc>().add(SearchRoutines(value));
                },
              ),
            ],
          );
  }
}
