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


import '../../../core/constants/translation_keys.dart';
import '../../../custom_widgets/custom_app_bar.dart';
import '../../../res/app_colors.dart';
import '../../../routes/app_pages.dart';
import '../controllers/faqs_controller.dart';
import '../controllers/faqs_second_screen_controller.dart';

class FaqsSecondScreenView extends GetView<FaqsController> {
  FaqsSecondScreenView({Key? key, this.description, this.title, this.shortTitle}) : super(key: key);

  var secondScreenController = Get.find<FaqsSecondController>();

  String? title;
  String? shortTitle;
  String? description;

  @override
  Widget build(BuildContext context) {
    var faqs = controller.faqsModel;
    return Scaffold(
      appBar: DashBoardAppBar(
        title: TranslationKeys.makeTranslation(TranslationKeys.textFaqs),
        onBackButtonPressed: () {
          Get.back();
        },
      ),
      body: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 20.0, vertical: 20.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(secondScreenController.question.title, style: Theme.of(context).textTheme.titleSmall?.copyWith(color: AppColors.black, fontSize: 20, fontWeight: FontWeight.w500)),
            Column(children: [
              Container(
                margin: const EdgeInsets.only(left: 0, right: 0, bottom: 12, top: 17),
                height: 40,
                padding: const EdgeInsets.symmetric(horizontal: 12.0),
                decoration: BoxDecoration(
                  color: Colors.white,
                  border: Border.all(color: Colors.grey),
                  borderRadius: BorderRadius.circular(20.0),
                ),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    Icon(
                      Icons.search,
                      size: 15.0,
                      color: Colors.grey[800],
                    ),
                    const SizedBox(width: 5.0),
                    Expanded(
                      child: TextField(
                          style: Theme.of(context).textTheme.bodySmall?.copyWith(fontWeight: FontWeight.w400, fontSize: 12),
                          decoration: const InputDecoration(
                            enabledBorder: InputBorder.none,
                            border: InputBorder.none,
                            focusedBorder: InputBorder.none,
                            hintText: 'search your query',
                          ),
                          onChanged: (value) => secondScreenController.searchText.value = value),
                    ),
                  ],
                ),
              ),
            ]),
            const SizedBox(height: 20),
            Obx(() {
              return Expanded(
                child: ListView.builder(
                  itemCount: secondScreenController.filteredListSubQuestions.length,
                  itemBuilder: (context, index) {
                    return Padding(
                      padding: const EdgeInsets.only(bottom: 15.0),
                      child: InkWell(
                        onTap: () {
                          Get.toNamed(Routes.FAQS_THIRD_SCREEN, arguments: secondScreenController.question.subQuestions[index]);
                        },
                        child: Row(
                          children: [
                            Text(
                              secondScreenController.filteredListSubQuestions[index].title,
                              style: context.textTheme.bodySmall!.copyWith(fontSize: 14, fontWeight: FontWeight.w500),
                            ),
                            const Spacer(),
                            const Padding(padding: EdgeInsets.all(0.0), child: Icon(Icons.arrow_forward_ios_outlined, size: 15, color: AppColors.colorGrey500)),
                          ],
                        ),
                      ),
                    );
                  },
                ),
              );
            }),
          ],
        ),
      ),
    );
  }
}
