import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:generp/Utils/commonWidgets.dart';
import 'package:generp/screens/genTracker/ScanEnterGeneratorIDScreen.dart';

import '../../Utils/app_colors.dart';
class Gentrackerdashboard extends StatefulWidget {
  const Gentrackerdashboard({super.key});

  @override
  State<Gentrackerdashboard> createState() => _GentrackerdashboardState();
}

class _GentrackerdashboardState extends State<Gentrackerdashboard> {
  @override
  Widget build(BuildContext context) {
    return WillPopScope(
      onWillPop: () => onBackPressed(context),
      child: Scaffold(
        resizeToAvoidBottomInset: true,
        backgroundColor: AppColors.scaffold_bg_color,
        appBar: appbar(context, "Gen Tracker"),
        body: SafeArea(
          child: GridView.builder(
            padding: EdgeInsets.symmetric(vertical: 10,horizontal: 10),
            itemCount: 4,
            gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 2,
              crossAxisSpacing: 10,
              mainAxisSpacing: 10,
            ),
            itemBuilder: (context, index) {
              final names = [
                "Generator Details",
                "Register Complaint",
                "Tag Location",
                "Tag Generator",
          
              ];
              final icons = [
                "gent_gen_det",
                "gent_reg_comp",
                "gent_tag_loc",
                "gent_tag_den",
              ];
              return InkResponse(
                onTap: () {
                  switch (names[index]) {
                    case "Generator Details":
                      Navigator.push(context,MaterialPageRoute(builder: (context) => Scanentergeneratoridscreen(from: "Generator Details",)));
                      break;
                    case "Register Complaint":
                      Navigator.push(context,MaterialPageRoute(builder: (context) => Scanentergeneratoridscreen(from: "Register Complaint",)));
                      break;
                    case "Tag Location":
                      Navigator.push(context, MaterialPageRoute(builder: (context)=>Scanentergeneratoridscreen(from: "Tag Location",)));
                      break;
                    case "Tag Generator":
                      Navigator.push(context, MaterialPageRoute(builder: (context)=>Scanentergeneratoridscreen(from: "Tag Generator",)));
                      break;
          
                    default:
                      print("111");
                      break;
                  }
                },
                child: Container(
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(30),
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      SvgPicture.asset(
                        "assets/svg/${icons[index]}.svg",
                      ),
                      SizedBox(height: 10,),
                      Text(names[index]),
                    ],
                  ),
                ),
              );
            },
          ),
        ),
      ),
    );
  }
}
