import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../../../../application/outlet/selected_outlet/selected_outlet_bloc.dart';
import '../../../../common/theme/theme.dart';
import '../../../components/spacer/spacer.dart';
import 'header_outlet_bottom_sheet.dart';

class HeaderOutletSelector extends StatelessWidget {
  const HeaderOutletSelector({super.key});

  @override
  Widget build(BuildContext context) {
    return BlocBuilder<SelectedOutletBloc, SelectedOutletState>(
      builder: (context, state) {
        return GestureDetector(
          onTap: () => HeaderOutletBottomSheet.show(context),
          child: Container(
            padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
            decoration: BoxDecoration(
              color: AppColor.primary.withOpacity(0.8),
              borderRadius: BorderRadius.circular(12),
              border: Border.all(color: AppColor.white.withOpacity(0.3)),
              boxShadow: [
                BoxShadow(
                  color: Colors.black.withOpacity(0.15),
                  blurRadius: 10,
                  spreadRadius: 0,
                  offset: const Offset(0, 4),
                ),
              ],
            ),
            child: Row(
              children: [
                Icon(
                  Icons.location_on_outlined,
                  color: AppColor.white,
                  size: 18,
                ),
                const SpaceWidth(8),
                Expanded(
                  child: Text(
                    state.displayName,
                    style: AppStyle.md.copyWith(
                      color: AppColor.white,
                      fontWeight: FontWeight.w600,
                    ),
                    maxLines: 1,
                    overflow: TextOverflow.ellipsis,
                  ),
                ),
                Icon(
                  Icons.keyboard_arrow_down_rounded,
                  color: AppColor.white,
                  size: 20,
                ),
              ],
            ),
          ),
        );
      },
    );
  }
}
