import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:get/get.dart';
import 'package:google_fonts/google_fonts.dart';

class OrderStatusUpdateScreen extends StatefulWidget {
  const OrderStatusUpdateScreen({super.key});

  @override
  State<OrderStatusUpdateScreen> createState() =>
      _OrderStatusUpdateScreenState();
}

class _OrderStatusUpdateScreenState extends State<OrderStatusUpdateScreen> {
  String _groupValue = "Pending";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      extendBodyBehindAppBar: true,
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: Colors.transparent,
        elevation: 0,
        leading: GestureDetector(
          onTap: () {},
          child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: SvgPicture.asset(
              'assets/svg/menu.svg',
            ),
          ),
        ),
        actions: [
          GestureDetector(
            onTap: () => Get.back(),
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: SvgPicture.asset(
                'assets/svg/back_arrow.svg',
              ),
            ),
          ),
        ],
        title: const Text(
          "Order Status Update",
        ),
      ),
      body: Stack(
        fit: StackFit.expand,
        children: [
          Image.asset(
            'assets/images/image_1.png',
            fit: BoxFit.cover,
          ),
          SafeArea(
            child: SingleChildScrollView(
              child: Column(
                children: [
                  SizedBox(
                    height: Get.height * 0.02,
                  ),
                  SizedBox(
                    height: Get.height * 0.65,
                    child: Card(
                      margin: const EdgeInsets.symmetric(horizontal: 18),
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(19),
                        side: const BorderSide(color: Color(0xFFFDFDFD)),
                      ),
                      color: const Color(0xFFB4D1E5).withOpacity(0.9),
                      child: Padding(
                        padding: const EdgeInsets.all(12.0),
                        child: Column(
                          mainAxisSize: MainAxisSize.min,
                          children: [
                            Card(
                              child: Column(
                                children: [
                                  SizedBox(
                                    width: Get.width,
                                    child: Padding(
                                      padding:
                                          const EdgeInsets.fromLTRB(8, 8, 8, 0),
                                      child: Text(
                                        "Order ID: 123456",
                                        style: GoogleFonts.roboto(
                                          fontSize: Get.width * 0.04,
                                          fontWeight: FontWeight.w400,
                                        ),
                                      ),
                                    ),
                                  ),
                                  SizedBox(
                                    width: Get.width,
                                    child: Padding(
                                      padding:
                                          const EdgeInsets.fromLTRB(8, 8, 8, 8),
                                      child: Text(
                                        "Retail Distributor: XYZ",
                                        style: GoogleFonts.roboto(
                                          fontSize: Get.width * 0.04,
                                          fontWeight: FontWeight.w400,
                                        ),
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            SizedBox(height: Get.height * 0.01),
                            Card(
                              child: SizedBox(
                                width: Get.width,
                                child: Padding(
                                  padding: const EdgeInsets.all(8.0),
                                  child: Text(
                                    "Current Status: Pending",
                                    style: GoogleFonts.roboto(
                                      fontSize: Get.width * 0.045,
                                      fontWeight: FontWeight.w600,
                                    ),
                                  ),
                                ),
                              ),
                            ),
                            SizedBox(height: Get.height * 0.01),
                            Card(
                              child: Column(
                                children: [
                                  SizedBox(
                                    width: Get.width,
                                    child: Padding(
                                      padding:
                                          const EdgeInsets.fromLTRB(8, 8, 8, 0),
                                      child: Text(
                                        "Update Status:",
                                        style: GoogleFonts.roboto(
                                          fontSize: Get.width * 0.04,
                                          fontWeight: FontWeight.w600,
                                        ),
                                      ),
                                    ),
                                  ),
                                  SizedBox(
                                    height: Get.height * 0.25,
                                    child: ListView(
                                      padding: EdgeInsets.zero,
                                      children: [
                                        RadioListTile(
                                          value: "Pending",
                                          groupValue: _groupValue,
                                          onChanged: (value) {
                                            setState(() {
                                              _groupValue = value.toString();
                                            });
                                          },
                                          title: const Text("Pending"),
                                        ),
                                        RadioListTile(
                                          value: "Fulfilled",
                                          groupValue: _groupValue,
                                          onChanged: (value) {
                                            setState(() {
                                              _groupValue = value.toString();
                                            });
                                          },
                                          title: const Text("Fulfilled"),
                                        ),
                                        RadioListTile(
                                          value: "Delivered",
                                          groupValue: _groupValue,
                                          onChanged: (value) {
                                            setState(() {
                                              _groupValue = value.toString();
                                            });
                                          },
                                          title: const Text("Delivered"),
                                        )
                                      ],
                                    ),
                                  )
                                ],
                              ),
                            ),
                          ],
                        ),
                      ),
                    ),
                  ),
                  SizedBox(height: Get.height * 0.04),
                  SizedBox(
                    width: Get.width * 0.9,
                    height: Get.height * 0.06,
                    child: ElevatedButton(
                      onPressed: () {},
                      style: ElevatedButton.styleFrom(
                        foregroundColor: Colors.white,
                        backgroundColor: const Color(0xFF00784C),
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(10),
                        ),
                      ),
                      child: Text(
                        "Update Status",
                        style: GoogleFonts.roboto(
                          fontSize: Get.width * 0.04,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
