import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:mohem_flutter_app/classes/colors.dart';
import 'package:mohem_flutter_app/extensions/string_extensions.dart';
import 'package:mohem_flutter_app/extensions/int_extensions.dart';
import 'package:mohem_flutter_app/generated/locale_keys.g.dart';
import 'package:mohem_flutter_app/ui/work_list/sheets/selected_item_sheet.dart';
import 'package:mohem_flutter_app/widgets/bottom_sheet.dart';
import 'package:mohem_flutter_app/widgets/button/default_button.dart';
import 'package:mohem_flutter_app/widgets/circular_avatar.dart';
import 'package:mohem_flutter_app/widgets/input_widget.dart';
import 'package:mohem_flutter_app/widgets/radio/show_radio.dart';
import 'package:mohem_flutter_app/extensions/widget_extensions.dart';

class RequestMoreInfoSheet extends StatelessWidget {
  TextEditingController username = TextEditingController();

  @override
  Widget build(BuildContext context) {
    List<String> related = [
      "Amjad Khan",
      "Munahi Nasser",
    ];
    List<String> favorites = [
      "Amjad Khan",
      "Muhammad Ahmed",
      "Majid Ali",
      "Faris Mahmoud",
    ];
    return Container(
      width: double.infinity,
      height: MediaQuery.of(context).size.height - 80,
      child: Column(
        children: [
          Expanded(
            child: SingleChildScrollView(
              child: Padding(
                padding: EdgeInsets.all(21),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    "Request more info".toText24(),
                    24.height,
                    LocaleKeys.search.tr().toText16(),
                    12.height,
                    Row(
                      children: [
                        Expanded(
                          flex: 2,
                          child: ShowRadio(
                              title: "Name", value: "Name", groupValue: "Name"),
                        ),
                        Expanded(
                          flex: 3,
                          child: ShowRadio(
                              title: "User Name",
                              value: "User Name",
                              groupValue: "Name"),
                        ),
                        Expanded(
                          flex: 2,
                          child: ShowRadio(
                              title: "Email",
                              value: "Email",
                              groupValue: "Name"),
                        ),
                      ],
                    ),
                    20.height,
                    InputWidget(
                      "Search By Username",
                      "",
                      username,
                      isBackgroundEnable: true,
                    ),
                    24.height,
                    "Related".toText16(),
                    12.height,
                    ListView.separated(
                      itemBuilder: (context, index) {
                        return showItem(context, related[index]);
                      },
                      separatorBuilder: (context, index) {
                        return Container(
                          color: MyColors.borderColor,
                          width: double.infinity,
                          height: 1,
                          margin: EdgeInsets.only(top: 8, bottom: 8),
                        );
                      },
                      physics: NeverScrollableScrollPhysics(),
                      shrinkWrap: true,
                      itemCount: related.length,
                      padding: EdgeInsets.only(top: 8, bottom: 8),
                    ),
                    24.height,
                    "Favorites".toText16(),
                    12.height,
                    ListView.separated(
                      itemBuilder: (context, index) {
                        return showItem(context, favorites[index],
                            isEnabled: true);
                      },
                      separatorBuilder: (context, index) {
                        return Container(
                          color: MyColors.borderColor,
                          width: double.infinity,
                          height: 1,
                          margin: EdgeInsets.only(top: 8, bottom: 8),
                        );
                      },
                      physics: NeverScrollableScrollPhysics(),
                      shrinkWrap: true,
                      itemCount: favorites.length,
                      padding: EdgeInsets.only(top: 8, bottom: 8),
                    ),
                  ],
                ),
              ),
            ),
          ),
          Container(
            width: double.infinity,
            height: 1,
            color: MyColors.borderColor,
          ),
          DefaultButton(
            LocaleKeys.cancel.tr(),
            () {
              Navigator.pop(context);
            },
            textColor: Colors.black,
            colors: [
              Color(0xffE6E6E6),
              Color(0xffE6E6E6),
            ],
          ).insideContainer
        ],
      ),
    );
  }

  Widget showItem(BuildContext context, String name, {bool isEnabled = false}) {
    return InkWell(
      onTap: () {
        // showMyBottomSheet(context, child: SelectedItemSheet("Request more info"));
      },
      child: Row(
        children: [
          CircularAvatar(
            height: 30,
            width: 30,
          ),
          16.width,
          Expanded(
            child: name.toText12(),
          ),
          Icon(
            Icons.star,
            size: 16,
            color: isEnabled ? MyColors.yellowColor : MyColors.borderColor,
          ),
        ],
      ),
    );
  }
}
