import 'package:enaklo_pos/core/extensions/build_context_ext.dart';
import 'package:flutter/material.dart';

import '../../../core/components/search_input.dart';
import '../../../core/constants/colors.dart';

class SettingsTitle extends StatelessWidget {
  final String title;
  final String? subtitle;
  final TextEditingController? controller;
  final Function(String value)? onChanged;
  final List<Widget>? actionWidget;

  const SettingsTitle(
    this.title, {
    super.key,
    this.controller,
    this.onChanged,
    this.actionWidget,
    this.subtitle,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      height: context.deviceHeight * 0.1,
      padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 12.0),
      decoration: BoxDecoration(
        color: AppColors.white,
        border: Border(
          bottom: BorderSide(
            color: AppColors.background,
            width: 1.0,
          ),
        ),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text(
                title,
                style: TextStyle(
                  color: AppColors.black,
                  fontSize: 20,
                  fontWeight: FontWeight.w600,
                ),
              ),
              if (subtitle != null)
                Text(
                  subtitle ?? '',
                  style: TextStyle(
                    color: AppColors.grey,
                    fontSize: 14,
                  ),
                ),
            ],
          ),
          if (controller != null)
            SizedBox(
              width: 300.0,
              child: SearchInput(
                controller: controller!,
                onChanged: onChanged,
                hintText: 'Search for food, coffe, etc..',
              ),
            ),
          if (actionWidget != null) ...actionWidget!,
        ],
      ),
    );
  }
}
