// ignore_for_file: use_build_context_synchronously
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:file_picker/file_picker.dart';
import 'package:image_picker/image_picker.dart';
import 'package:provider/provider.dart';
import '../Premium_viewModel/Premium_view_model_screen.dart';
import '../../../../utils/image_constant.dart';
import '../../../../utils/size_utils.dart';
import '../../../../theme/app_style.dart';
import '../../../../widgets/app_bar/appbar_image.dart';
import '../../../../widgets/app_bar/appbar_title.dart';
import '../../../../widgets/app_bar/custom_app_bar.dart';
import '../../../../widgets/custom_button.dart';
import '../../../../widgets/custom_text_form_field.dart'; 
import '../../../../widgets/custom_dropdown_field.dart';
import 'dart:math';
import 'package:qr_flutter/qr_flutter.dart';
import 'package:barcode_widget/barcode_widget.dart';
import 'package:intl/intl.dart';
 
import 'package:autocomplete_textfield/autocomplete_textfield.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import 'package:fluttertoast/fluttertoast.dart';
import '../../../../Reuseable/reusable_date_picker_field.dart';
import '../../../../Reuseable/reusable_date_time_picker_field.dart'
;import 'package:multi_select_flutter/multi_select_flutter.dart';
import 'package:just_audio/just_audio.dart';
import 'package:video_player/video_player.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:lottie/lottie.dart';
import '../../../../utils/toast_messages/toast_message_util.dart';
import 'dart:io';
import '../../../../Reuseable/reusable_text_field.dart';
import '../../../../Reuseable/reusable_dropdown_field.dart';








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

  @override
  _premiumCreateEntityScreenState createState() => _premiumCreateEntityScreenState();
}

class _premiumCreateEntityScreenState extends State<premiumCreateEntityScreen> {

final Map<String, dynamic> formData = {};
  final _formKey = GlobalKey<FormState>();
  final TextEditingController nameController = TextEditingController();


  late final Function(String) onPaymentSelectedcheckout_field;

void _showPaymentOptionscheckout_field() {
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text('Select Payment Method'),
          content: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              GestureDetector(
                onTap: () {
                  onPaymentSelectedcheckout_field('Paytm');
                  Navigator.of(context).pop();
                },
                child: Column(
                  children: [
                    Image.asset(
                      'assets/images/paytm1.png', // Replace with the path to your Paytm image
                      height: 80,
                    ),
                    Text('Paytm'),
                  ],
                ),
              ),
              SizedBox(height: 20),
              GestureDetector(
                onTap: () {
                  onPaymentSelectedcheckout_field('Razorpay');
                  Navigator.of(context).pop();
                },
                child: Column(
                  children: [
                    Image.asset(
                      'assets/images/razorpay.png', // Replace with the path to your Razorpay image
                      height: 80,
                    ),
                    Text('Razorpay'),
                  ],
                ),
              ),
            ],
          ),
          actions: [
            TextButton(
              onPressed: () {
                Navigator.of(context).pop();
              },
              child: Text('Close'),
            ),
          ],
        );
      },
    );
  }


  final TextEditingController approved_fieldController = TextEditingController();




 @override
  void initState() {
    super.initState(); 
    final provider = Provider.of<PremiumViewModelScreen>(context, listen: false);








} 

  

  @override
  Widget build(BuildContext context) {
    final provider = Provider.of<PremiumViewModelScreen>(context, listen: false);
    return Scaffold(
      appBar: CustomAppBar(
          height: getVerticalSize(49),
          leadingWidth: 40,
          leading: AppbarImage(
              height: getSize(24),
              width: getSize(24),
              svgPath: ImageConstant.imgArrowleftBlueGray900,
              margin: getMargin(left: 16, top: 12, bottom: 13),
              onTap: () {
                Navigator.pop(context);
              }),
          centerTitle: true,
          title: AppbarTitle(text: "Create Premium"),
 actions: [








],
 ),
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.all(16),
          child: Form(
            key: _formKey,
            child: Column(
              children: [
 ReusableTextField(
                  controller: nameController,

  onSaved:(value) => formData['name'] = value ,
  label:"Enter Name",
  // ValidationProperties
),

  SizedBox(height: 16),




Column(
        children: [
          Center(
            child: SizedBox(
              height: MediaQuery.of(context).size.height*0.2,
              child: LottieBuilder.network('https://lottie.host/87ee095f-c45e-4171-afc6-c2dd90def749/FdaBGpEjHs.json',repeat: false,frameRate: FrameRate(120),),
            ),
          ),
          Text("Successfull!",style: GoogleFonts.getFont('Lato',color: Colors.black,fontSize: 26,fontWeight: FontWeight.bold),),
          Text("Transaction successful of  \$340",style: GoogleFonts.getFont('Lato',color: Colors.grey,fontSize: 18,fontWeight: FontWeight.w500),),
          SizedBox(height: 30,),
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 10.0),
            child: Divider(color: Colors.grey,thickness: 0.5,),
          ),
          ListTile(
            leading: Text("Transaction Number",style:GoogleFonts.getFont('Lato',color: Colors.grey,fontSize: 16,fontWeight: FontWeight.w400),),
            trailing: Text("123 456 789",style:GoogleFonts.getFont('Lato',color: Colors.black,fontSize: 16,fontWeight: FontWeight.bold),),
          ),
          ListTile(
            leading: Text("Date",style:GoogleFonts.getFont('Lato',color: Colors.grey,fontSize: 16,fontWeight: FontWeight.w400),),
            trailing: Text("20 May 2023 | 10:09",style:GoogleFonts.getFont('Lato',color: Colors.black,fontSize: 16,fontWeight: FontWeight.bold),),
          ),
          ListTile(
            leading: Text("Status",style:GoogleFonts.getFont('Lato',color: Colors.grey,fontSize: 16,fontWeight: FontWeight.w400),),
            trailing: IntrinsicWidth(
              child: Container(
                  decoration: BoxDecoration(
                    color: Colors.greenAccent.withOpacity(0.3),
                    borderRadius: BorderRadius.circular(18)
                  ),
                  child: Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 12.0),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        const Icon(Icons.check,color: Colors.green,),
                        Text("success",style:GoogleFonts.getFont('Lato',color: Colors.greenAccent.shade700,fontSize: 16,fontWeight: FontWeight.bold),),
                      ],
                    ),
                  )),
            ),
          ),
          ListTile(
            leading: Text("Type of Transaction",style:GoogleFonts.getFont('Lato',color: Colors.grey,fontSize: 16,fontWeight: FontWeight.w400),),
            trailing: Text("Credit card",style:GoogleFonts.getFont('Lato',color: Colors.black,fontSize: 16,fontWeight: FontWeight.bold),),
          ),
          ListTile(
            leading: Text("Total",style:GoogleFonts.getFont('Lato',color: Colors.grey,fontSize: 16,fontWeight: FontWeight.w400),),
            trailing: Text("\$340",style:GoogleFonts.getFont('Lato',color: Colors.black,fontSize: 16,fontWeight: FontWeight.bold),),
          ),
        ],
      ),



   const SizedBox(width: 8),
CustomButton(
                  height: getVerticalSize(50),
                  text: "Checkout",
                  margin: getMargin(top: 24, bottom: 5),
                  onTap: _showPaymentOptionscheckout_field,
                ),   ],
          ),
              ),
            ),
          ),
     );
  }
}