import 'package:flutter/material.dart';
import 'package:flutter_font_icons/flutter_font_icons.dart';
import 'package:go_router/go_router.dart';
import 'package:tacban/assets/theme/colors.dart';
import 'package:tacban/src/app/home/screens/categoria_screen.dart';
import 'package:tacban/src/app/home/widgets/card_info_card.dart';
import 'package:tacban/src/app/home/widgets/card_info_card_v2.dart';
import 'package:tacban/src/shared/utils/responsive/responsive_metrics.dart';
import 'package:tacban/src/shared/widgets/inputs/search_controller.dart';

class HomeScreen extends StatefulWidget {
  static String path = '/homescreen';
  const HomeScreen({super.key});

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
  final GlobalKey<FormState> _formKey = GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    Radius radius = const Radius.circular(30);
    return Scaffold(
      key: _scaffoldKey,
      extendBodyBehindAppBar: true,
      appBar: const PreferredSize(
        preferredSize: Size.fromHeight(0),
        child: SizedBox(), 
      ),
      body: SingleChildScrollView(
        child: Container(
          decoration: BoxDecoration(
            color: Theme.of(context).primaryColor,
            image: const DecorationImage(
              image: AssetImage('lib/assets/images/bg_header.png'),
              fit: BoxFit.cover,
            )
          ),
          child: Column(
            children: [
              const SizedBox(height: 40),
              SafeArea(
                bottom: false,
                child: SizedBox(
                  child: Padding(
                    padding: const EdgeInsets.only(left: 20, right: 20, top: 20, bottom: 20),
                    child: Row(
                      children: [
                        Expanded(
                          child: Column(
                            children: [
                              SizedBox(
                                width: double.infinity,
                                child: Text(
                                  "Ola!",
                                  textAlign: TextAlign.start,
                                  style: Theme.of(context).textTheme.bodySmall?.copyWith(
                                    fontWeight: FontWeight.w100,
                                    color: AppColorLight.text04Color,
                                    fontSize: 18
                                  )
                                )
                              ),
                              SizedBox(
                                width: double.infinity,
                                child: Text(
                                  "Steeve bernard",
                                  textAlign: TextAlign.start,
                                  style: Theme.of(context).textTheme.bodySmall?.copyWith(
                                    fontWeight: FontWeight.bold,
                                    color: AppColorLight.text06Color,
                                    fontSize: 24
                                  )
                                )
                              ),
                              
                            ]
                          )
                        ),
                        CircleAvatar(
                          backgroundColor: AppColorLight.secondaryColor,
                          radius: 30,
                          child: Text(
                            "S",
                            textAlign: TextAlign.start,
                            style: Theme.of(context).textTheme.bodyMedium?.copyWith(
                              fontWeight: FontWeight.bold,
                              color: AppColorLight.text06Color,
                              fontSize: 27
                            )
                          ),
                        )
                      ],
                    ),
                  )
                ),
              ),
              ClipRRect(
                borderRadius: BorderRadius.only(
                  topLeft: radius,
                  topRight: radius
                ),
                child: Container(
                  padding: const EdgeInsets.symmetric(horizontal: 20),
                  decoration: BoxDecoration(
                    color: Theme.of(context).scaffoldBackgroundColor
                  ),
                  child: Form(
                    key: _formKey,
                    child: Center(
                      child: SingleChildScrollView(
                        child: Column(
                          children: [
                            const SizedBox(height: 15),
                            SizedBox(
                              width: double.infinity,
                              child: Text(
                                "Escolha o segmento desejado",
                                textAlign: TextAlign.start,
                                style: Theme.of(context).textTheme.bodyMedium?.copyWith(
                                  fontWeight: FontWeight.w600,
                                  color: AppColorLight.text02Color,
                                  fontSize: 20
                                )
                              )
                            ),
                            // SizedBox(
                            //   width: double.infinity,
                            //   child: Text(
                            //     "Novo registro de dados",
                            //     textAlign: TextAlign.start,
                            //     style: Theme.of(context).textTheme.bodySmall?.copyWith(
                            //       fontWeight: FontWeight.w100,
                            //       color: AppColorLight.text03Color,
                            //       fontSize: 15
                            //     )
                            //   )
                            // ),
                            // const SizedBox(height: 20),
                            // SearchInput(
                            //   hintText: 'Pesquisar',
                            //   showIcon: true,
                            //   prefixIcon: Feather.search,
                            //   textInputType: TextInputType.text,
                            //   textInputAction: TextInputAction.search,
                            //   onFieldSubmitted: (value) async {
                            //   }
                            // ),
                            const SizedBox(height: 20),
                            Row(
                              children: [
                                CardInfoCardV2Widget(
                                  svg: 'lib/assets/images/image_05.jpeg',
                                  title: 'Inseticida',
                                  onTap: (){
                                    context.push(CategoriaScreen.path, extra: 'Algodão');
                                  },
                                ),
                                SizedBox(width: 20),
                                CardInfoCardWidget(
                                  svg: 'lib/assets/images/masculino.png',
                                  title: 'Herbicida',
                                  onTap: (){
                                    context.push(CategoriaScreen.path, extra: 'Café');
                                  }
                                )
                              ]
                            ),
                            const SizedBox(height: 20),
                            Row(
                              children: [
                                CardInfoCardWidget(
                                  svg: 'lib/assets/images/masculino.png',
                                  title: 'Fungicida',
                                  onTap: (){
                                    context.push(CategoriaScreen.path, extra: 'Cana');
                                  },
                                ),
                                SizedBox(width: 20),
                                CardInfoCardWidget(
                                  svg: 'lib/assets/images/masculino.png',
                                  title: 'Nutrição foliar',
                                  onTap: (){
                                    context.push(CategoriaScreen.path, extra: 'Milho');
                                  }
                                )
                              ]
                            ),
                            const SizedBox(height: 20),
                            Row(
                              children: [
                                CardInfoCardWidget(
                                  svg: 'lib/assets/images/masculino.png',
                                  title: 'Tecnologia de Aplicação',
                                  onTap: (){
                                    context.push(CategoriaScreen.path, extra: 'Soja');
                                  },
                                ),
                                // SizedBox(width: 20),
                                // CardInfoCardWidget(
                                //   svg: 'lib/assets/images/trigo.png',
                                //   title: 'Trigo',
                                //   onTap: (){
                                //     context.push(CategoriaScreen.path, extra: 'Trijo');
                                //   }
                                // )
                              ]
                            ),
                            const SizedBox(height: 20),
                            const SizedBox(height: 20),
                          ]
                        ),
                      )
                    )
                  )
                )
              )
            ],
          ),
        ),
      )
    );
  }
}