import 'dart:convert';
import 'dart:io';
import 'package:card_swiper/card_swiper.dart';
import 'package:country_code_picker/country_code_picker.dart';
import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shimmer_animation/shimmer_animation.dart';
import 'package:sixam_mart/common/widgets/confirmation_dialog.dart';
import 'package:sixam_mart/common/widgets/custom_asset_image_widget.dart';
import 'package:sixam_mart/features/auth/widgets/business/base_card_widget.dart';
import 'package:sixam_mart/features/auth/widgets/business/web_business_plan_widget.dart';
import 'package:sixam_mart/features/auth/widgets/module_view_widget.dart';
import 'package:sixam_mart/features/auth/widgets/web_registration_stepper_widget.dart';
import 'package:sixam_mart/features/business/widgets/package_card_widget.dart';
import 'package:sixam_mart/features/dashboard/screens/dashboard_screen.dart';
import 'package:sixam_mart/features/language/controllers/language_controller.dart';
import 'package:sixam_mart/features/splash/controllers/splash_controller.dart';
import 'package:sixam_mart/features/auth/domain/models/store_body_model.dart';
import 'package:sixam_mart/common/models/translation.dart';
import 'package:sixam_mart/common/models/config_model.dart';
import 'package:sixam_mart/features/auth/controllers/store_registration_controller.dart';
import 'package:sixam_mart/features/auth/widgets/custom_time_picker_widget.dart';
import 'package:sixam_mart/features/auth/widgets/pass_view_widget.dart';
import 'package:sixam_mart/features/auth/widgets/select_location_view_widget.dart';
import 'package:sixam_mart/helper/responsive_helper.dart';
import 'package:sixam_mart/helper/validate_check.dart';
import 'package:sixam_mart/util/dimensions.dart';
import 'package:sixam_mart/util/images.dart';
import 'package:sixam_mart/util/styles.dart';
import 'package:sixam_mart/common/widgets/custom_app_bar.dart';
import 'package:sixam_mart/common/widgets/custom_button.dart';
import 'package:sixam_mart/common/widgets/custom_snackbar.dart';
import 'package:sixam_mart/common/widgets/custom_text_field.dart';
import 'package:sixam_mart/common/widgets/footer_view.dart';
import 'package:sixam_mart/common/widgets/menu_drawer.dart';
import 'package:sixam_mart/common/widgets/web_page_title_widget.dart';

import '../widgets/vendor_info_widget.dart';

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

  @override
  State<StoreRegistrationScreen> createState() => _StoreRegistrationScreenState();
}

class _StoreRegistrationScreenState extends State<StoreRegistrationScreen> with TickerProviderStateMixin {

  final List<TextEditingController> _nameController = [];
  final List<TextEditingController> _addressController = [];
  final TextEditingController _tinNumberController = TextEditingController();
  final TextEditingController _fNameController = TextEditingController();
  final TextEditingController _lNameController = TextEditingController();
  final TextEditingController _phoneController = TextEditingController();
  final TextEditingController _emailController = TextEditingController();
  final TextEditingController _passwordController = TextEditingController();
  final TextEditingController _confirmPasswordController = TextEditingController();
  final List<FocusNode> _nameFocus = [];
  final List<FocusNode> _addressFocus = [];
  final FocusNode _fNameFocus = FocusNode();
  final FocusNode _lNameFocus = FocusNode();
  final FocusNode _phoneFocus = FocusNode();
  final FocusNode _emailFocus = FocusNode();
  final FocusNode _passwordFocus = FocusNode();
  final FocusNode _confirmPasswordFocus = FocusNode();
  final List<Language>? _languageList = Get.find<SplashController>().configModel!.language;
  final ScrollController _scrollController = ScrollController();
  final GlobalKey _storeInfoScrollKey = GlobalKey();
  final GlobalKey _storePrefScrollKey = GlobalKey();
  final GlobalKey _locationInfoScrollKey = GlobalKey();

  String? _countryDialCode;
  bool firstTime = true;
  TabController? _tabController;
  final List<Tab> _tabs =[];

  GlobalKey<FormState>? _formKeyFirst;
  GlobalKey<FormState>? _formKeySecond;

  @override
  void initState() {
    super.initState();
    _tabController = TabController(length: _languageList!.length, initialIndex: 0, vsync: this);
    _countryDialCode = CountryCode.fromCountryCode(Get.find<SplashController>().configModel!.country!).dialCode;
    for (var language in _languageList) {
      if (kDebugMode) {
        print(language);
      }
      _nameController.add(TextEditingController());
      _addressController.add(TextEditingController());
      _nameFocus.add(FocusNode());
      _addressFocus.add(FocusNode());
    }
    Get.find<StoreRegistrationController>().resetData();
    Get.find<StoreRegistrationController>().storeStatusChange(0.1, isUpdate: false);
    Get.find<StoreRegistrationController>().getZoneList(resetAddress: true);
    Get.find<StoreRegistrationController>().selectModuleIndex(-1, canUpdate: false);
    if(Get.find<StoreRegistrationController>().showPassView){
      Get.find<StoreRegistrationController>().showHidePass(isUpdate: false);
    }
    Get.find<StoreRegistrationController>().resetBusiness();
    Get.find<StoreRegistrationController>().clearPickupZone();
    Get.find<StoreRegistrationController>().setZoneIndex(-1, canUpdate: false);

    for (var language in _languageList) {
      _tabs.add(Tab(text: language.value));
    }
    _formKeyFirst = GlobalKey<FormState>();
    _formKeySecond = GlobalKey<FormState>();
  }

  Future<void> _showBackPressedDialogue(String title)async {
    Get.dialog(ConfirmationDialog(icon: Images.support,
      title: title,
      description: 'are_you_sure_to_go_back'.tr, isLogOut: true,
      onYesPressed: () {
        if(Get.isDialogOpen!){
          Get.back();
        }
        if(ResponsiveHelper.isDesktop(Get.context)) {
          Get.back();
        }else {
          Get.off(() => const DashboardScreen(pageIndex: 4));
        }
      },
    ), useSafeArea: false);
  }

  @override
  Widget build(BuildContext context) {

    bool isDesktop = ResponsiveHelper.isDesktop(context);

    return PopScope(
      canPop: false,
      onPopInvokedWithResult: (didPop, result) async{
        if(Get.find<StoreRegistrationController>().storeStatus == 0.6 && firstTime){
          Get.find<StoreRegistrationController>().storeStatusChange(0.1);
          firstTime = false;
        }else if(Get.find<StoreRegistrationController>().storeStatus == 0.9){
          Get.find<StoreRegistrationController>().storeStatusChange(0.6);
        }else{
          Get.back();
          // await _showBackPressedDialogue('your_registration_not_setup_yet'.tr);
        }
      },
      child: Scaffold(
        appBar: CustomAppBar(title: 'vendor_registration'.tr,
          onBackPressed: () async {
            if(Get.find<StoreRegistrationController>().storeStatus != 0.1 && firstTime){
              Get.find<StoreRegistrationController>().storeStatusChange(0.1);
              firstTime = false;
            }else{
              await _showBackPressedDialogue('your_registration_not_setup_yet'.tr);
            }
          },
          menuWidget: Padding(
            padding: const EdgeInsets.only(right: Dimensions.paddingSizeLarge),
            child: GestureDetector(
              onTap: () {
                showVendorInfoSheet(context);
              },
              child: Tooltip(
                message: 'Learn about vendor benefits',
                child: Icon(Icons.info, color: Theme.of(context).disabledColor),
              ),
            ),
          )
        ),
        endDrawer: const MenuDrawer(), endDrawerEnableOpenDragGesture: false,
        body: SafeArea(child: GetBuilder<StoreRegistrationController>(builder: (storeRegController) {

          if(storeRegController.storeAddress != null && _languageList!.isNotEmpty){
            _addressController[0].text = storeRegController.storeAddress.toString();
          }

          return isDesktop ? webView(storeRegController, isDesktop) : Column(children: [

            storeRegController.storeStatus == 0.9 ? SizedBox() : Padding(padding: const EdgeInsets.all(Dimensions.paddingSizeDefault),
              child: SizedBox(height: 40,
                child: Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
                  _tabButton(title: 'vendor_info'.tr, index: 0, isSelected: storeRegController.storeStatus == 0.1, onTap: () {
                    storeRegController.storeStatusChange(0.1);
                  }),
                  SizedBox(width: Dimensions.paddingSizeSmall),

                  _tabButton(title: 'owner_info'.tr, index: 1, isSelected: storeRegController.storeStatus == 0.6, onTap: () {
                    if(storeRegController.storeStatus == 0.1){
                      _submitData(storeRegController, isDesktop);
                    }else{
                      storeRegController.storeStatusChange(0.6);
                    }
                  }),
                ]),
              ),
            ),

            Expanded(
              child: SingleChildScrollView(controller: _scrollController,
                padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeDefault, vertical: Dimensions.paddingSizeSmall),
                child: Column(children: [
                  Visibility(visible: storeRegController.storeStatus == 0.1,
                    child: Form(key: _formKeyFirst,
                      child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
                        sectionCard(title: 'basic_info'.tr,
                          child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
                            SizedBox(height: 40,
                              child: Align(
                                alignment: Alignment.centerLeft,
                                child: TabBar(
                                  tabAlignment: TabAlignment.start,
                                  controller: _tabController,
                                  indicatorColor: Theme.of(context).primaryColor,
                                  indicatorWeight: 3,
                                  labelColor: Theme.of(context).primaryColor,
                                  unselectedLabelColor: Theme.of(context).disabledColor,
                                  unselectedLabelStyle: robotoRegular.copyWith(color: Theme.of(context).disabledColor, fontSize: Dimensions.fontSizeSmall),
                                  labelStyle: robotoBold.copyWith(fontSize: Dimensions.fontSizeDefault, color: Theme.of(context).primaryColor),
                                  labelPadding: const EdgeInsets.only(right: Dimensions.radiusDefault),
                                  isScrollable: true,
                                  indicatorSize: TabBarIndicatorSize.tab,
                                  tabs: _tabs,
                                  onTap: (int ? value) {
                                    setState(() {});
                                  },
                                ),
                              ),
                            ),
                            const Padding(padding: EdgeInsets.only(bottom: Dimensions.paddingSizeLarge), child: Divider(height: 0)),

                            CustomTextField(
                              titleText: 'business_name'.tr,
                              labelText: 'business_name'.tr,
                              controller: _nameController[_tabController!.index],
                              focusNode: _nameFocus[_tabController!.index],
                              nextFocus: _tabController!.index != _languageList!.length-1 ? _addressFocus[_tabController!.index] : _addressFocus[0],
                              inputType: TextInputType.name,
                              capitalization: TextCapitalization.words,
                              required: true,
                              validator: (value) => ValidateCheck.validateEmptyText(value, "vendor_name_field_is_required".tr),
                            ),

                            const SizedBox(height: Dimensions.paddingSizeDefault),

                            Container(
                              padding: EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeSmall, vertical: Dimensions.paddingSizeDefault),
                              decoration: BoxDecoration(color: Theme.of(context).hintColor.withValues(alpha: 0.07), borderRadius: BorderRadius.circular(12)),
                              child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
                                Row(children: [
                                  Text('business_logo'.tr, style: robotoBold.copyWith(color: Theme.of(context).textTheme.bodyLarge?.color?.withValues(alpha: 0.7))),
                                  Text(' *'.tr, style: robotoRegular.copyWith(color: Theme.of(context).colorScheme.error)),
                                ]),
                                const SizedBox(height: Dimensions.paddingSizeDefault),

                                Align(alignment: Alignment.center, child: Stack(children: [
                                  ClipRRect(
                                    borderRadius: BorderRadius.circular(Dimensions.radiusSmall),
                                    child: storeRegController.pickedLogo != null ? GetPlatform.isWeb ? Image.network(
                                      storeRegController.pickedLogo!.path, width: 150, height: 120, fit: BoxFit.cover,
                                    ) : Image.file(
                                      File(storeRegController.pickedLogo!.path), width: 150, height: 120, fit: BoxFit.cover,
                                    ) : Container(color: Theme.of(context).cardColor, width: 150, height: 120,
                                      child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
                                        Image.asset(Images.uploadIcon, width: 60),
                                        const SizedBox(height: Dimensions.paddingSizeSmall),
                                        Padding(
                                          padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeSmall),
                                          child: Text('click_to_upload'.tr, style: robotoRegular.copyWith(color: Colors.blueAccent), textAlign: TextAlign.center),
                                        ),
                                      ]),
                                    ),
                                  ),
                                  Positioned(
                                    bottom: 0, right: 0, top: 0, left: 0,
                                    child: InkWell(
                                      onTap: () => storeRegController.pickImage(true, false),
                                      child: DottedBorder(
                                        options: RoundedRectDottedBorderOptions(
                                          color: Theme.of(context).disabledColor.withValues(alpha: 0.6),
                                          strokeWidth: 1,
                                          strokeCap: StrokeCap.butt,
                                          dashPattern: const [5, 5],
                                          padding: const EdgeInsets.all(0),
                                          radius: const Radius.circular(Dimensions.radiusDefault),
                                        ),
                                        child: Center(child: Visibility(
                                          visible: storeRegController.pickedLogo != null,
                                          child: Container(
                                            padding: const EdgeInsets.all(25),
                                            decoration: BoxDecoration(border: Border.all(width: 2, color: Colors.white), shape: BoxShape.circle),
                                            child: const Icon(CupertinoIcons.photo_camera_solid, color: Colors.white),
                                          ),
                                        )),
                                      ),
                                    ),
                                  ),
                                ])),
                                SizedBox(height: Dimensions.paddingSizeDefault),
                                Align( alignment: Alignment.center, child: Text('JPG, JPEG, PNG, Less Than 1MB', style: robotoRegular.copyWith(color: Theme.of(context).disabledColor),)),
                                Align( alignment: Alignment.center, child: Text('(Ratio 1:1)', style: robotoMedium.copyWith(color: Colors.black54))),
                              ]),
                            ),
                            const SizedBox(height: Dimensions.paddingSizeDefault),
                            Container(
                              padding: EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeSmall, vertical: Dimensions.paddingSizeDefault),
                              decoration: BoxDecoration(color: Theme.of(context).hintColor.withValues(alpha: 0.07), borderRadius: BorderRadius.circular(12)),
                              child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
                                Row(children: [
                                      Text('business_cover'.tr, style: robotoBold.copyWith(color: Theme.of(context).textTheme.bodyLarge?.color?.withValues(alpha: 0.7))),
                                      Text(' *'.tr, style: robotoRegular.copyWith(color: Theme.of(context).colorScheme.error)),
                                    ]),
                                const SizedBox(height: Dimensions.paddingSizeDefault),
                                Align(alignment: Alignment.center, child: Stack(children: [
                                  Padding(padding: const EdgeInsets.all(5.0), child: ClipRRect(
                                    borderRadius: BorderRadius.circular(Dimensions.radiusSmall),
                                    child: storeRegController.pickedCover != null ? GetPlatform.isWeb ? Image.network(
                                      storeRegController.pickedCover!.path, width: context.width, height: 120, fit: BoxFit.cover,
                                    ) : Image.file(
                                      File(storeRegController.pickedCover!.path), width: context.width, height: 120, fit: BoxFit.cover,
                                    ) : Container(color: Theme.of(context).cardColor,  height: 120, width: 280,
                                      child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
                                        Image.asset(Images.uploadIcon, width: 60),
                                        const SizedBox(height: Dimensions.paddingSizeSmall),
                                        Text('click_to_upload'.tr, style: robotoRegular.copyWith(color: Colors.blueAccent), textAlign: TextAlign.center),
                                      ]),
                                    ),
                                  )),
                                  Positioned(
                                      bottom: 0, right: 0, top: 0, left: 0,
                                      child: InkWell(
                                        onTap: () => storeRegController.pickImage(false, false),
                                        child: DottedBorder(
                                          options: RoundedRectDottedBorderOptions(
                                            color: Theme.of(context).disabledColor.withValues(alpha: 0.6),
                                            strokeWidth: 1,
                                            strokeCap: StrokeCap.butt,
                                            dashPattern: const [5, 5],
                                            padding: const EdgeInsets.all(0),
                                            radius: const Radius.circular(Dimensions.radiusDefault),
                                          ),
                                          child: Center(child: Visibility(visible: storeRegController.pickedCover != null,
                                            child: Container(
                                              padding: const EdgeInsets.all(25),
                                              decoration: BoxDecoration(border: Border.all(width: 3, color: Colors.white), shape: BoxShape.circle),
                                              child: const Icon(CupertinoIcons.photo_camera_solid, color: Colors.white, size: 50),
                                            ),
                                          )),
                                        ),
                                      ),
                                    ),
                                ])),
                                SizedBox(height: Dimensions.paddingSizeDefault),
                                Align( alignment: Alignment.center, child: Text('JPG, JPEG, PNG Less Than 2MB', style: robotoRegular.copyWith(color: Theme.of(context).disabledColor),)),
                                Align( alignment: Alignment.center, child: Text('(Ratio 2:1)', style: robotoMedium.copyWith(color: Colors.black54))),
                              ]),
                            ),
                          ]),
                        ),

                        const SizedBox(height: Dimensions.paddingSizeDefault),

                        sectionCard(title: 'location_info'.tr,
                          child: storeRegController.zoneList != null ? SelectLocationViewWidget(
                            fromView: true, addressController: _addressController[0], addressFocus: _addressFocus[0],
                          ) : Container(
                            padding: const EdgeInsets.all(Dimensions.paddingSizeSmall),
                            decoration: BoxDecoration(
                              color: Theme.of(context).cardColor,
                              borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                              boxShadow: [BoxShadow(color: Colors.grey.withValues(alpha: 0.1), spreadRadius: 1, blurRadius: 10, offset: const Offset(0, 1))],
                            ),
                            child: Column(children: [
                              Shimmer(child: Container(
                                height: 45, width: context.width,
                                decoration: BoxDecoration(color: Theme.of(context).shadowColor, borderRadius: BorderRadius.circular(Dimensions.radiusDefault)),
                              )),
                              const SizedBox(height: Dimensions.paddingSizeLarge),

                              Shimmer(child: Container(
                                height: 220, width: context.width,
                                decoration: BoxDecoration(color: Theme.of(context).shadowColor, borderRadius: BorderRadius.circular(Dimensions.radiusDefault)),
                              )),
                              const SizedBox(height: Dimensions.paddingSizeLarge),

                              Shimmer(child: Container(
                                height: 100, width: context.width,
                                decoration: BoxDecoration(color: Theme.of(context).shadowColor, borderRadius: BorderRadius.circular(Dimensions.radiusDefault)),
                              )),
                            ]),
                          ),
                        ),
                        const SizedBox(height: Dimensions.paddingSizeDefault),

                        sectionCard(
                          title: 'business_info'.tr,
                          gap: Dimensions.paddingSizeLarge,
                          child: Column(children: [
                            ModuleViewWidget(isEnable: storeRegController.selectedZoneIndex != -1),
                            const SizedBox(height: Dimensions.paddingSizeExtraLarge),

                            InkWell(
                              onTap: () {
                                Get.dialog(const CustomTimePickerWidget());
                              },
                              child: Stack(clipBehavior: Clip.none, children: [
                                Container(
                                  height: 50,
                                  decoration: BoxDecoration(color: Theme.of(context).cardColor, borderRadius: BorderRadius.circular(Dimensions.radiusDefault), border: Border.all(color: Theme.of(context).disabledColor, width: 0.5)),
                                  padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeLarge),
                                  child: Row(children: [
                                    Expanded(child: Text('${storeRegController.storeMinTime} : ${storeRegController.storeMaxTime} ${storeRegController.storeTimeUnit}', style: robotoMedium)),
                                    Icon(Icons.access_time_filled, color: Theme.of(context).primaryColor,)
                                  ]),
                                ),

                                Positioned(left: 10, top: -15, child: Container(
                                  decoration: BoxDecoration(color: Theme.of(context).cardColor),
                                  padding: const EdgeInsets.all(5),
                                  child: Text('select_estimated_delivery_time'.tr, style: robotoRegular.copyWith(color: Theme.of(context).disabledColor)),
                                )),
                              ]),
                            ),
                          ]),
                        ),
                        const SizedBox(height: Dimensions.paddingSizeDefault),

                        sectionCard(
                          title: 'business_tin'.tr,
                          child: Column(children: [
                            CustomTextField(
                              hintText: 'taxpayer_identification_number_tin'.tr,
                              labelText: 'tin_number'.tr,
                              controller: _tinNumberController,
                              inputAction: TextInputAction.done,
                              inputType: TextInputType.text,
                              onChanged: (value) {},
                            ),
                            const SizedBox(height: Dimensions.paddingSizeExtremeLarge),

                            InkWell(
                              onTap: () async {
                                final DateTime? pickedDate = await showDatePicker(context: context, firstDate: DateTime.now(), initialDate: DateTime.now(), lastDate: DateTime(2100),);

                                if (pickedDate != null) {
                                  storeRegController.setTinExpireDate(pickedDate);
                                }
                              },
                              child: Stack(clipBehavior: Clip.none, children: [
                                Container(height: 50,
                                  decoration: BoxDecoration(color: Theme.of(context).cardColor, borderRadius: BorderRadius.circular(Dimensions.radiusDefault), border: Border.all(color: Theme.of(context).disabledColor, width: 0.5),),
                                  padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeLarge),
                                  child: Row(children: [
                                    Expanded(child: Text(storeRegController.tinExpireDate ?? 'tap_to_add_date'.tr, style: robotoRegular.copyWith(color: Theme.of(context).disabledColor))),
                                    Icon(Icons.calendar_month, color: Theme.of(context).disabledColor),
                                  ]),
                                ),

                                Positioned(left: 10, top: -15, child: Container(
                                  decoration: BoxDecoration(color: Theme.of(context).cardColor),
                                  padding: const EdgeInsets.all(5),
                                  child: Text('expire_date'.tr, style: robotoRegular.copyWith(color: Theme.of(context).disabledColor)),
                                )),
                              ]),
                            ),
                            const SizedBox(height: Dimensions.paddingSizeLarge),

                            Container(
                              padding: EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeSmall, vertical: Dimensions.paddingSizeDefault),
                              decoration: BoxDecoration(color: Theme.of(context).hintColor.withValues(alpha: 0.07), borderRadius: BorderRadius.circular(12)),
                              child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
                                Text('tin_certificate'.tr, style: robotoSemiBold.copyWith(fontSize: Dimensions.fontSizeLarge)),
                                Text('vehicle_doc_format'.tr, style: robotoRegular.copyWith(fontSize: Dimensions.fontSizeSmall, color: Theme.of(context).disabledColor)),
                                const SizedBox(height: Dimensions.paddingSizeLarge),
                                storeRegController.tinFiles!.isEmpty ? InkWell(
                                  onTap: () {
                                    storeRegController.pickFiles();
                                  },
                                  child: DottedBorder(
                                    options: RoundedRectDottedBorderOptions(radius: const Radius.circular(Dimensions.radiusDefault), dashPattern: const [8, 4], strokeWidth: 1, color: Get.isDarkMode ? Colors.white.withValues(alpha: 0.2) : Colors.grey,),
                                    child: Container(height: 120, width: double.infinity,
                                      decoration: BoxDecoration(color: Get.isDarkMode ? Colors.white.withValues(alpha: 0.05) : Colors.transparent, borderRadius: BorderRadius.circular(Dimensions.radiusDefault),),
                                      child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
                                        const SizedBox(width: Dimensions.paddingSizeSmall),
                                        CustomAssetImageWidget(Images.featherUploadCloudIcon, height: 40, width: 40, color: Get.isDarkMode ? Colors.grey : null),
                                        const SizedBox(width: Dimensions.paddingSizeSmall),
                                        Text('select_a_file'.tr, style: robotoBold.copyWith(fontSize: Dimensions.fontSizeDefault, color: Colors.blue)),
                                        Text('JPG, JPEG, PNG Less Than 10MB', style: robotoRegular.copyWith(color: Theme.of(context).disabledColor)),
                                      ]),
                                    ),
                                  ),
                                ) : DottedBorder(
                                  options: RoundedRectDottedBorderOptions(radius: const Radius.circular(Dimensions.radiusDefault), dashPattern: const [8, 4], strokeWidth: 1, color: const Color(0xFFE5E5E5),),
                                  child: SizedBox(width: double.infinity, child: Stack(children: [
                                    Container(padding: const EdgeInsets.only(left: Dimensions.paddingSizeDefault), height: 120, width: double.infinity,
                                      decoration: BoxDecoration(color: const Color(0xFFFAFAFA), borderRadius: BorderRadius.circular(Dimensions.radiusDefault)),
                                      child: Row(children: [
                                        Flexible(child: Column(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [
                                          Builder(builder: (context) {
                                            final filePath = storeRegController.tinFiles![0].paths[0];
                                            final fileName = filePath!.split('/').last.toLowerCase();
                                            if (fileName.endsWith('.pdf')) {
                                              return Row(children: [
                                                const Icon(Icons.picture_as_pdf, size: 40, color: Colors.red),
                                                const SizedBox(width: 10),
                                                Expanded(child: Text(fileName, overflow: TextOverflow.ellipsis)),
                                                const SizedBox(width: 35),
                                              ]);
                                            } else if (fileName.endsWith('.doc') || fileName.endsWith('.docx')) {
                                              return Row(children: [
                                                const Icon(Icons.description, size: 40, color: Colors.blue),
                                                const SizedBox(width: 10),
                                                Expanded(child: Text(fileName, overflow: TextOverflow.ellipsis)),
                                                const SizedBox(width: 35),
                                              ]);
                                            } else {
                                              return Row(children: [
                                                const Icon(Icons.insert_drive_file, size: 40, color: Colors.grey),
                                                const SizedBox(width: 10),
                                                Expanded(child: Text(fileName, overflow: TextOverflow.ellipsis)),
                                                const SizedBox(width: 35),
                                              ]);
                                            }
                                          }),
                                        ])),
                                      ]),
                                    ),
                                    Positioned(right: 0, top: 0, child: InkWell(
                                      onTap: () {
                                        storeRegController.removeFile(0);
                                      },
                                      child: const Padding(
                                        padding: EdgeInsets.all(Dimensions.paddingSizeSmall),
                                        child: Icon(Icons.delete_forever, color: Colors.red),
                                      ),
                                    )),
                                  ])),
                                ),
                              ]),
                            ),
                          ]),
                        ),
                      ]),
                    ),
                  ),

                  Visibility(
                    visible: storeRegController.storeStatus == 0.6,
                    child: Form(
                      key: _formKeySecond,
                      child: Column(mainAxisAlignment: MainAxisAlignment.start, children: [

                        sectionCard(
                          title: 'basic_information'.tr,
                          gap: Dimensions.paddingSizeLarge,
                          child: Column(children: [
                            CustomTextField(
                              titleText: 'write_first_name'.tr,
                              controller: _fNameController,
                              focusNode: _fNameFocus,
                              nextFocus: _lNameFocus,
                              inputType: TextInputType.name,
                              capitalization: TextCapitalization.words,
                              prefixIcon: CupertinoIcons.person_crop_circle_fill,
                              iconSize: 25,
                              required: true,
                              labelText: 'first_name'.tr,
                              validator: (value) => ValidateCheck.validateEmptyText(value, "first_name_field_is_required".tr),
                            ),
                            const SizedBox(height: Dimensions.paddingSizeExtraLarge),

                            CustomTextField(
                              titleText: 'write_last_name'.tr,
                              controller: _lNameController,
                              focusNode: _lNameFocus,
                              nextFocus: _phoneFocus,
                              prefixIcon: CupertinoIcons.person_crop_circle_fill,
                              iconSize: 25,
                              inputType: TextInputType.name,
                              capitalization: TextCapitalization.words,
                              required: true,
                              labelText: 'last_name'.tr,
                              validator: (value) => ValidateCheck.validateEmptyText(value, "last_name_field_is_required".tr),
                            ),
                            const SizedBox(height: Dimensions.paddingSizeExtraLarge),

                            CustomTextField(
                              titleText: 'enter_phone_number'.tr,
                              controller: _phoneController,
                              focusNode: _phoneFocus,
                              nextFocus: _emailFocus,
                              inputType: TextInputType.phone,
                              isPhone: true,
                              showTitle: isDesktop,
                              onCountryChanged: (CountryCode countryCode) {
                                _countryDialCode = countryCode.dialCode;
                              },
                              countryDialCode: _countryDialCode != null ? CountryCode.fromCountryCode(Get.find<SplashController>().configModel!.country!).code
                                  : Get.find<LocalizationController>().locale.countryCode,
                              required: true,
                              labelText: 'phone'.tr,
                              validator: (value) => ValidateCheck.validateEmptyText(value, null),
                            ),
                          ]),
                        ),
                        const SizedBox(height: Dimensions.paddingSizeDefault),

                        sectionCard(
                          title: 'account_information'.tr,
                          gap: Dimensions.paddingSizeLarge,
                          child: Column(mainAxisAlignment: MainAxisAlignment.start, children: [
                            CustomTextField(
                              titleText: 'write_email'.tr,
                              controller: _emailController,
                              focusNode: _emailFocus,
                              nextFocus: _passwordFocus,
                              inputType: TextInputType.emailAddress,
                              prefixIcon: Icons.email,
                              iconSize: 25,
                              required: true,
                              labelText: 'email'.tr,
                              validator: (value) => ValidateCheck.validateEmail(value),
                            ),
                            const SizedBox(height: Dimensions.paddingSizeExtraLarge),

                            GetBuilder<StoreRegistrationController>(builder: (storeRegController) {
                              return Column(mainAxisAlignment: MainAxisAlignment.start, children: [
                                CustomTextField(
                                  titleText: '8+characters'.tr,
                                  controller: _passwordController,
                                  focusNode: _passwordFocus,
                                  nextFocus: _confirmPasswordFocus,
                                  inputType: TextInputType.visiblePassword,
                                  prefixIcon: Icons.lock,
                                  iconSize: 25,
                                  isPassword: true,
                                  onChanged: (value){
                                    if(value != null && value.isNotEmpty){
                                      if(!storeRegController.showPassView){
                                        storeRegController.showHidePass();
                                      }
                                      storeRegController.validPassCheck(value);
                                    }else{
                                      if(storeRegController.showPassView){
                                        storeRegController.showHidePass();
                                      }
                                    }
                                  },
                                  required: true,
                                  labelText: 'password'.tr,
                                  validator: (value) => ValidateCheck.validateEmptyText(value, "password_field_is_required".tr),
                                ),

                                storeRegController.showPassView ? const PassViewWidget() : const SizedBox(),
                              ]);
                            }),
                            const SizedBox(height: Dimensions.paddingSizeExtraLarge),

                            CustomTextField(
                              titleText: '8+characters'.tr,
                              controller: _confirmPasswordController,
                              focusNode: _confirmPasswordFocus,
                              inputType: TextInputType.visiblePassword,
                              inputAction: TextInputAction.done,
                              prefixIcon: Icons.lock,
                              iconSize: 25,
                              isPassword: true,
                              required: true,
                              labelText: 'confirm_password'.tr,
                              validator: (value) => ValidateCheck.validateEmptyText(value, "password_field_is_required".tr),
                            ),
                          ]),
                        ),
                      ]),
                    ),
                  ),

                  Visibility(
                    visible: storeRegController.storeStatus == 0.9,
                    child: Column(children: [

                      Padding(
                        padding: const EdgeInsets.only(top: Dimensions.paddingSizeLarge, bottom: Dimensions.paddingSizeExtremeLarge),
                        child: Center(child: Text('choose_your_business_plan'.tr, style: robotoBold)),
                      ),

                      Padding(
                        padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeLarge),
                        child: Row(children: [

                          Get.find<SplashController>().configModel!.commissionBusinessModel != 0 ? Expanded(
                            child: BaseCardWidget(storeRegistrationController: storeRegController, title: 'commission_base'.tr,
                              index: 0, onTap: ()=> storeRegController.setBusiness(0),
                            ),
                          ) : const SizedBox(),
                          SizedBox(width: Get.find<SplashController>().configModel!.commissionBusinessModel != 0 ? Dimensions.paddingSizeDefault : 0),

                          Get.find<SplashController>().configModel!.subscriptionBusinessModel != 0 ? Expanded(
                            child: BaseCardWidget(storeRegistrationController: storeRegController, title: 'subscription_base'.tr,
                              index: 1, onTap: ()=> storeRegController.setBusiness(1),
                            ),
                          ) : const SizedBox(),

                        ]),
                      ),
                      const SizedBox(height: Dimensions.paddingSizeExtraLarge),

                      storeRegController.businessIndex == 0 ? Padding(
                        padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeLarge),
                        child: Text(
                          "${'vendor_will_pay'.tr} ${Get.find<SplashController>().configModel!.adminCommission}% ${'commission_to'.tr} ${Get.find<SplashController>().configModel!.businessName} ${'from_each_order_You_will_get_access_of_all'.tr}",
                          style: robotoRegular.copyWith(fontSize: Dimensions.fontSizeSmall, color: Theme.of(context).textTheme.bodyLarge?.color?.withValues(alpha: 0.7)), textAlign: TextAlign.justify, textScaler: const TextScaler.linear(1.1),
                        ),
                      ) : Column(children: [
                        Padding(
                          padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeLarge),
                          child: Text(
                            'run_vendor_by_purchasing_subscription_packages'.tr,
                            style: robotoRegular.copyWith(fontSize: Dimensions.fontSizeSmall, color: Theme.of(context).textTheme.bodyLarge?.color?.withValues(alpha: 0.7)), textAlign: TextAlign.justify, textScaler: const TextScaler.linear(1.1),
                          ),
                        ),
                        const SizedBox(height: Dimensions.paddingSizeLarge),

                        storeRegController.packageModel != null ? SizedBox(
                          height: 420,
                          child: storeRegController.packageModel!.packages!.isNotEmpty ? Swiper(
                            itemCount: storeRegController.packageModel!.packages!.length,
                            viewportFraction: 0.60,
                            itemBuilder: (context, index) {
                              return PackageCardWidget(
                                canSelect: storeRegController.activeSubscriptionIndex == index,
                                packages: storeRegController.packageModel!.packages![index],
                              );
                            },
                            onIndexChanged: (index) {
                              storeRegController.selectSubscriptionCard(index);
                            },

                          ) : Center(child: Column(mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Image.asset(Images.emptyBox, height: 150),
                                const SizedBox(height: Dimensions.paddingSizeLarge),
                                Text('no_package_available'.tr, style: robotoMedium),
                              ]),
                          ),
                        ) : const CircularProgressIndicator(),

                      ]),

                    ]),
                  ),

                  const SizedBox(height: Dimensions.paddingSizeLarge),
                ]),
              ),
            ),

            isDesktop ? const SizedBox() : buttonView(isDesktop),
          ]);
        })),
      ),
    );
  }

  Widget webView(StoreRegistrationController storeRegController, bool isDesktop) {
    return SingleChildScrollView(
      child: Column(children: [
        WebScreenTitleWidget(title: 'join_as_vendor'.tr),

        Center(child: SizedBox(
          width: Dimensions.webMaxWidth,
          child: Padding(
            padding: const EdgeInsets.only(top: 25, bottom: 35),
            child: RegistrationStepperWidget(status: storeRegController.storeStatus == 0.9 ? 'business' : ''),
          ),
        )),

        FooterView(
          child: SizedBox(
            width: Dimensions.webMaxWidth,
            child: Column(children: [
              storeRegController.storeStatus != 0.9 ? Column(
                children: [
                  Row(children: [
                    CustomAssetImageWidget(Images.shopIcon, height: 20, width: 20, color: Theme.of(context).textTheme.bodyLarge!.color),
                    const SizedBox(width: Dimensions.paddingSizeSmall),

                    Text('vendor_information'.tr, style: robotoMedium.copyWith(fontSize: Dimensions.fontSizeDefault)),
                  ]),
                  const SizedBox(height: Dimensions.paddingSizeSmall),

                  Container(
                    decoration: BoxDecoration(
                      color: Theme.of(context).cardColor,
                      borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                      boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 5, spreadRadius: 1)],
                    ),
                    padding: const EdgeInsets.all(Dimensions.paddingSizeDefault),
                    margin: const EdgeInsets.symmetric(vertical: Dimensions.paddingSizeSmall),
                    child: Column(mainAxisAlignment: MainAxisAlignment.start, children: [

                      Row(children: [
                        Container(
                          height:  40,
                          width: 500,
                          color: Colors.transparent,
                          child: TabBar(
                            tabAlignment: TabAlignment.start,
                            controller: _tabController,
                            indicatorColor: Theme.of(context).primaryColor,
                            indicatorWeight: 3,
                            labelColor: Theme.of(context).primaryColor,
                            unselectedLabelColor: Theme.of(context).disabledColor,
                            unselectedLabelStyle: robotoRegular.copyWith(color: Theme.of(context).disabledColor, fontSize: Dimensions.fontSizeSmall),
                            labelStyle: robotoBold.copyWith(fontSize: Dimensions.fontSizeSmall, color: Theme.of(context).primaryColor),
                            labelPadding: const EdgeInsets.symmetric(horizontal: Dimensions.radiusDefault, vertical: 0 ),
                            isScrollable: true,
                            indicatorSize: TabBarIndicatorSize.tab,
                            tabs: _tabs,
                            onTap: (int ? value) {
                              setState(() {});
                            },
                          ),
                        ),
                      ]),
                      const SizedBox(height: Dimensions.paddingSizeSmall),

                      Row(crossAxisAlignment: CrossAxisAlignment.start, children: [

                        Expanded(
                          child: Column( children: [
                            const SizedBox(height: Dimensions.paddingSizeSmall),

                            CustomTextField(
                              titleText: 'write_vendor_name'.tr,
                              labelText: 'vendor_name'.tr,
                              controller: _nameController[_tabController!.index],
                              focusNode: _nameFocus[_tabController!.index],
                              nextFocus: _tabController!.index != _languageList!.length-1 ? _addressFocus[_tabController!.index] : _addressFocus[0],
                              inputType: TextInputType.name,
                              prefixImage: Images.shopIcon,
                              capitalization: TextCapitalization.words,
                              required: true,
                              validator: (value) => ValidateCheck.validateEmptyText(value, "vendor_name_field_is_required".tr),
                            ),
                            const SizedBox(height: Dimensions.paddingSizeExtraOverLarge),

                            ModuleViewWidget(isEnable: storeRegController.selectedZoneIndex != -1,),
                            const SizedBox(height: Dimensions.paddingSizeExtraOverLarge),

                            CustomTextField(
                              titleText: 'write_vendor_address'.tr,
                              labelText: 'address'.tr,
                              controller: _addressController[0],
                              focusNode: _addressFocus[0],
                              inputAction: TextInputAction.done,
                              inputType: TextInputType.text,
                              capitalization: TextCapitalization.sentences,
                              maxLines: 3,
                              required: true,
                              validator: (value) => ValidateCheck.validateEmptyText(value, "vendor_address_field_is_required".tr),
                            ),

                          ]),
                        ),
                        const SizedBox(height: Dimensions.paddingSizeSmall),

                        Expanded(
                          child: Column( children: [
                            const SizedBox(height: Dimensions.paddingSizeSmall),
                            storeRegController.zoneList != null ? const SelectLocationViewWidget(fromView: true, mapView: true, resetZoneIndex: false) : const Center(child: CircularProgressIndicator()),
                          ]),
                        ),

                      ]),
                    ]),
                  ),
                  const SizedBox(height: Dimensions.paddingSizeDefault),

                  Row(children: [
                    const Icon(Icons.person),
                    const SizedBox(width: Dimensions.paddingSizeSmall),
                    Text('general_information'.tr, style: robotoMedium.copyWith(fontSize: Dimensions.fontSizeDefault))
                  ]),
                  const SizedBox(height: Dimensions.paddingSizeSmall),

                  Container(
                    decoration: BoxDecoration(
                      color: Theme.of(context).cardColor,
                      borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                      boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 5, spreadRadius: 1)],
                    ),
                    padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeDefault, vertical: Dimensions.paddingSizeLarge),
                    margin: const EdgeInsets.symmetric(vertical: Dimensions.paddingSizeSmall),
                    child: Column(children: [

                      Row(crossAxisAlignment: CrossAxisAlignment.start, children: [

                        Expanded(child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [

                          InkWell(
                            onTap: () {
                              Get.dialog(const CustomTimePickerWidget());
                            },
                            child: Stack(
                              clipBehavior: Clip.none,
                              children: [
                                Container(
                                  height: 50,
                                  decoration: BoxDecoration(
                                    color: Theme.of(context).cardColor,
                                    borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                                    border: Border.all(color: Theme.of(context).disabledColor, width: 0.5),
                                  ),
                                  padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeLarge),
                                  child: Row(children: [
                                    Expanded(child: Text(
                                      '${storeRegController.storeMinTime} : ${storeRegController.storeMaxTime} ${storeRegController.storeTimeUnit}',
                                      style: robotoMedium,
                                    )),
                                    Icon(Icons.access_time_filled, color: Theme.of(context).primaryColor,)
                                  ]),
                                ),

                                Positioned(
                                  left: 10, top: -15,
                                  child: Container(
                                    decoration: BoxDecoration(
                                      color: Theme.of(context).cardColor,
                                    ),
                                    padding: const EdgeInsets.all(5),
                                    child: Text('select_time'.tr, style: robotoRegular.copyWith(color: Theme.of(context).disabledColor, fontSize: Dimensions.fontSizeExtraSmall)),
                                  ),
                                ),
                              ],
                            ),
                          ),

                        ])),

                        Expanded(child:  Row( children: [

                          Expanded(flex: 4,
                            child: Align(alignment: Alignment.center, child: Stack(children: [
                              Padding(
                                padding: const EdgeInsets.all(5.0),
                                child: ClipRRect(
                                  borderRadius: BorderRadius.circular(Dimensions.radiusSmall),
                                  child: storeRegController.pickedLogo != null ? GetPlatform.isWeb ? Image.network(
                                    storeRegController.pickedLogo!.path, width: 150, height: 120, fit: BoxFit.cover,
                                  ) : Image.file(
                                    File(storeRegController.pickedLogo!.path), width: 150, height: 120, fit: BoxFit.cover,
                                  ) : SizedBox(
                                    width: 150, height: 120,
                                    child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [

                                      Icon(CupertinoIcons.photo_camera_solid, size: 30, color: Theme.of(context).disabledColor.withValues(alpha: 0.6)),
                                      const SizedBox(height: Dimensions.paddingSizeSmall),

                                      Padding(
                                        padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeSmall),
                                        child: Text(
                                          '${'upload_vendor_logo'.tr} (${'1:1'})',
                                          style: robotoRegular.copyWith(fontSize: Dimensions.fontSizeExtraSmall, color: Theme.of(context).textTheme.bodyLarge?.color?.withValues(alpha: 0.7)), textAlign: TextAlign.center,
                                        ),
                                      ),

                                      Padding(
                                        padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeSmall),
                                        child: Text(
                                          'upload_jpg_png_gif_maximum_2_mb'.tr,
                                          style: robotoRegular.copyWith(color: Theme.of(context).disabledColor.withValues(alpha: 0.6), fontSize: Dimensions.fontSizeOverSmall),
                                          textAlign: TextAlign.center,
                                        ),
                                      ),

                                    ]),
                                  ),
                                ),
                              ),
                              Positioned(
                                bottom: 0, right: 0, top: 0, left: 0,
                                child: InkWell(
                                  onTap: () => storeRegController.pickImage(true, false),
                                  child: DottedBorder(
                                    options: RoundedRectDottedBorderOptions(
                                      color: Theme.of(context).primaryColor,
                                      strokeWidth: 1,
                                      strokeCap: StrokeCap.butt,
                                      dashPattern: const [5, 5],
                                      padding: const EdgeInsets.all(0),
                                      radius: const Radius.circular(Dimensions.radiusDefault),
                                    ),
                                    child: Center(
                                      child: Visibility(
                                        visible: storeRegController.pickedLogo != null,
                                        child: Container(
                                          padding: const EdgeInsets.all(25),
                                          decoration: BoxDecoration(
                                            border: Border.all(width: 2, color: Colors.white),
                                            shape: BoxShape.circle,
                                          ),
                                          child: const Icon(CupertinoIcons.photo_camera_solid, color: Colors.white),
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ),
                            ])),
                          ),

                          Expanded(flex: 6,
                            child: Stack(children: [
                              Padding(
                                padding: const EdgeInsets.all(5.0),
                                child: ClipRRect(
                                  borderRadius: BorderRadius.circular(Dimensions.radiusSmall),
                                  child: storeRegController.pickedCover != null ? GetPlatform.isWeb ? Image.network(
                                    storeRegController.pickedCover!.path, width: context.width, height: 120, fit: BoxFit.cover,
                                  ) : Image.file(
                                    File(storeRegController.pickedCover!.path), width: context.width, height: 120, fit: BoxFit.cover,
                                  ) : SizedBox(
                                    width: context.width, height: 120,
                                    child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [

                                      Icon(CupertinoIcons.photo_camera_solid, size: 30, color: Theme.of(context).disabledColor.withValues(alpha: 0.6)),

                                      Text(
                                        '${'upload_vendor_cover'.tr} (${'3:1'})',
                                        style: robotoRegular.copyWith(color: Theme.of(context).textTheme.bodyLarge?.color?.withValues(alpha: 0.7), fontSize: Dimensions.fontSizeExtraSmall), textAlign: TextAlign.center,
                                      ),

                                      Padding(
                                        padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeSmall),
                                        child: Text(
                                          'upload_jpg_png_gif_maximum_2_mb'.tr,
                                          style: robotoRegular.copyWith(color: Theme.of(context).disabledColor.withValues(alpha: 0.6), fontSize: Dimensions.fontSizeOverSmall),
                                          textAlign: TextAlign.center,
                                        ),
                                      ),

                                    ]),
                                  ),
                                ),
                              ),

                              Positioned(
                                bottom: 0, right: 0, top: 0, left: 0,
                                child: InkWell(
                                  onTap: () => storeRegController.pickImage(false, false),
                                  child: DottedBorder(
                                    options: RoundedRectDottedBorderOptions(
                                      color: Theme.of(context).primaryColor,
                                      strokeWidth: 1,
                                      strokeCap: StrokeCap.butt,
                                      dashPattern: const [5, 5],
                                      padding: const EdgeInsets.all(0),
                                      radius: const Radius.circular(Dimensions.radiusDefault),
                                    ),
                                    child: Center(
                                      child: Visibility(
                                        visible: storeRegController.pickedCover != null,
                                        child: Container(
                                          padding: const EdgeInsets.all(25),
                                          decoration: BoxDecoration(
                                            border: Border.all(width: 3, color: Colors.white),
                                            shape: BoxShape.circle,
                                          ),
                                          child: const Icon(CupertinoIcons.photo_camera_solid, color: Colors.white, size: 50),
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ),
                            ]),
                          ),


                        ])),

                      ]),

                    ]),
                  ),
                  const SizedBox(height: Dimensions.paddingSizeDefault),

                  Row(children: [
                    const Icon(Icons.business),
                    const SizedBox(width: Dimensions.paddingSizeSmall),
                    Text('business_tin'.tr, style: robotoMedium.copyWith(fontSize: Dimensions.fontSizeDefault))
                  ]),
                  const SizedBox(height: Dimensions.paddingSizeSmall),

                  Container(
                    decoration: BoxDecoration(
                      color: Theme.of(context).cardColor,
                      borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                      boxShadow: [BoxShadow(color: Colors.grey.withValues(alpha: 0.1), spreadRadius: 1, blurRadius: 10, offset: const Offset(0, 1))],
                    ),
                    padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeSmall, vertical: Dimensions.paddingSizeDefault),
                    child: Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
                      Expanded(
                        child: Column(crossAxisAlignment: CrossAxisAlignment.center, children: [

                          CustomTextField(
                            hintText: 'taxpayer_identification_number_tin'.tr,
                            labelText: 'tin'.tr,
                            controller: _tinNumberController,
                            inputAction: TextInputAction.done,
                            inputType: TextInputType.number,
                          ),
                          const SizedBox(height: Dimensions.paddingSizeExtremeLarge),

                          InkWell(
                            onTap: () async {
                              final DateTime? pickedDate = await showDatePicker(
                                context: context,
                                firstDate: DateTime.now(),
                                initialDate: DateTime.now(),
                                lastDate: DateTime(2100),
                              );

                              if (pickedDate != null) {
                                storeRegController.setTinExpireDate(pickedDate);
                              }
                            },
                            child: Stack(
                              clipBehavior: Clip.none,
                              children: [
                                Container(
                                  height: 50,
                                  decoration: BoxDecoration(
                                    color: Theme.of(context).cardColor,
                                    borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                                    border: Border.all(color: Theme.of(context).disabledColor, width: 0.5),
                                  ),
                                  padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeLarge),
                                  child: Row(children: [
                                    Expanded(child: Text(
                                      storeRegController.tinExpireDate ?? 'select_date'.tr,
                                      style: robotoMedium,
                                    )),
                                    Icon(Icons.calendar_month, color: Theme.of(context).primaryColor),
                                  ]),
                                ),

                                Positioned(
                                  left: 10, top: -15,
                                  child: Container(
                                    decoration: BoxDecoration(
                                      color: Theme.of(context).cardColor,
                                    ),
                                    padding: const EdgeInsets.all(5),
                                    child: Text('expire_date'.tr, style: robotoRegular.copyWith(color: Theme.of(context).disabledColor)),
                                  ),
                                ),
                              ],
                            ),
                          ),

                        ]),
                      ),
                      const SizedBox(width: Dimensions.paddingSizeExtraLarge),

                      Expanded(
                        child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [

                          Row(children: [
                            Text('tin_certificate'.tr, style: robotoRegular.copyWith(fontSize: Dimensions.fontSizeLarge)),
                            Text('(${'vehicle_doc_format'.tr})', style: robotoRegular.copyWith(fontSize: Dimensions.fontSizeSmall, color: Theme.of(context).disabledColor)),

                          ]),

                          const SizedBox(height: Dimensions.paddingSizeLarge),

                          storeRegController.tinFiles!.isEmpty ? InkWell(
                            onTap: () {
                              storeRegController.pickFiles();
                            },
                            child: DottedBorder(
                              options: RoundedRectDottedBorderOptions(
                                radius: const Radius.circular(Dimensions.radiusDefault),
                                dashPattern: const [8, 4],
                                strokeWidth: 1,
                                color: Get.isDarkMode ? Colors.white.withValues(alpha: 0.2) : const Color(0xFFE5E5E5),
                              ),
                              child: Container(
                                height: 120,
                                width: double.infinity,
                                decoration: BoxDecoration(
                                  color: Get.isDarkMode ? Colors.white.withValues(alpha: 0.05) : const Color(0xFFFAFAFA),
                                  borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                                ),
                                child: Row(
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    const SizedBox(width: Dimensions.paddingSizeSmall),
                                    CustomAssetImageWidget(Images.uploadIcon, height: 40, width: 40, color: Get.isDarkMode ? Colors.grey : null),
                                    const SizedBox(width: Dimensions.paddingSizeSmall),
                                    RichText(
                                      textAlign: TextAlign.center,
                                      text: TextSpan(
                                        children: [
                                          TextSpan(
                                            text: 'click_to_upload'.tr,
                                            style: robotoBold.copyWith(fontSize: Dimensions.fontSizeSmall, color: Colors.blue),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ),
                          ) : DottedBorder(
                            options: RoundedRectDottedBorderOptions(
                              radius: const Radius.circular(Dimensions.radiusDefault),
                              dashPattern: const [8, 4],
                              strokeWidth: 1,
                              color: const Color(0xFFE5E5E5),
                            ),
                            child: SizedBox(
                              height: 120,
                              width: double.infinity,
                              child: Stack(
                                children: [
                                  Container(
                                    padding: const EdgeInsets.only(left: Dimensions.paddingSizeDefault),
                                    height: 120,
                                    width: double.infinity,
                                    decoration: BoxDecoration(
                                      color: const Color(0xFFFAFAFA),
                                      borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                                    ),
                                    child: Row(
                                      children: [
                                        Flexible(
                                          child: SizedBox(
                                            height: 120,
                                            child: Column(
                                              mainAxisAlignment: MainAxisAlignment.center,
                                              crossAxisAlignment: CrossAxisAlignment.start,
                                              children: [
                                                Builder(
                                                  builder: (context) {
                                                    final file = storeRegController.tinFiles![0].files[0];
                                                    final fileName = file.name.toLowerCase();

                                                    if (fileName.endsWith('.pdf')) {
                                                      // Show PDF preview
                                                      return Row(
                                                        children: [
                                                          const Icon(Icons.picture_as_pdf, size: 40, color: Colors.red),
                                                          const SizedBox(width: 10),
                                                          Expanded(
                                                            child: Text(
                                                              fileName,
                                                              overflow: TextOverflow.ellipsis,
                                                            ),
                                                          ),
                                                          const SizedBox(width: 35),
                                                        ],
                                                      );
                                                    } else if (fileName.endsWith('.doc') || fileName.endsWith('.docx')) {
                                                      // Show Word document preview
                                                      return Row(
                                                        children: [
                                                          const Icon(Icons.description, size: 40, color: Colors.blue),
                                                          const SizedBox(width: 10),
                                                          Expanded(
                                                            child: Text(
                                                              fileName,
                                                              overflow: TextOverflow.ellipsis,
                                                            ),
                                                          ),
                                                          const SizedBox(width: 35),
                                                        ],
                                                      );
                                                    } else {
                                                      // Show generic file preview
                                                      return Row(
                                                        children: [
                                                          const Icon(Icons.insert_drive_file, size: 40, color: Colors.grey),
                                                          const SizedBox(width: 10),
                                                          Expanded(
                                                            child: Text(
                                                              fileName,
                                                              overflow: TextOverflow.ellipsis,
                                                            ),
                                                          ),
                                                          const SizedBox(width: 35),
                                                        ],
                                                      );
                                                    }
                                                  },
                                                ),
                                              ],
                                            ),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                  Positioned(
                                    right: 0,
                                    top: 0,
                                    child: InkWell(
                                      onTap: () {
                                        storeRegController.removeFile(0);
                                      },
                                      child: const Padding(
                                        padding: EdgeInsets.all(Dimensions.paddingSizeSmall),
                                        child: Icon(Icons.delete_forever, color: Colors.red),
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),

                        ]),
                      ),
                    ]),
                  ),
                  const SizedBox(height: Dimensions.paddingSizeDefault),

                  Form(
                    key: _formKeySecond,
                    child: Row(children: [
                      const Icon(Icons.person),
                      const SizedBox(width: Dimensions.paddingSizeSmall),
                      Text('owner_information'.tr, style: robotoMedium.copyWith(fontSize: Dimensions.fontSizeDefault))
                    ]),
                  ),
                  const SizedBox(height: Dimensions.paddingSizeSmall),

                  Container(
                    decoration: BoxDecoration(
                      color: Theme.of(context).cardColor,
                      borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                      boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 5, spreadRadius: 1)],
                    ),
                    padding: const EdgeInsets.all(Dimensions.paddingSizeDefault),
                    margin: const EdgeInsets.symmetric(vertical: Dimensions.paddingSizeSmall),
                    child: Column(children: [

                      Row(children: [

                        Expanded(child: CustomTextField(
                          titleText: 'write_first_name'.tr,
                          controller: _fNameController,
                          focusNode: _fNameFocus,
                          nextFocus: _lNameFocus,
                          inputType: TextInputType.name,
                          capitalization: TextCapitalization.words,
                          prefixIcon: CupertinoIcons.person_crop_circle_fill,
                          iconSize: 25,
                          required: true,
                          labelText: 'first_name'.tr,
                          validator: (value) => ValidateCheck.validateEmptyText(value, "first_name_field_is_required".tr),
                        )),
                        const SizedBox(width: Dimensions.paddingSizeLarge),

                        Expanded(child: CustomTextField(
                          titleText: 'write_last_name'.tr,
                          controller: _lNameController,
                          focusNode: _lNameFocus,
                          nextFocus: _phoneFocus,
                          prefixIcon: CupertinoIcons.person_crop_circle_fill,
                          iconSize: 25,
                          inputType: TextInputType.name,
                          capitalization: TextCapitalization.words,
                          required: true,
                          labelText: 'last_name'.tr,
                          validator: (value) => ValidateCheck.validateEmptyText(value, "last_name_field_is_required".tr),
                        )),
                        const SizedBox(width: Dimensions.paddingSizeLarge),

                        Expanded(
                          child: CustomTextField(
                            titleText: 'enter_phone_number'.tr,
                            controller: _phoneController,
                            focusNode: _phoneFocus,
                            nextFocus: _emailFocus,
                            inputType: TextInputType.phone,
                            isPhone: true,
                            onCountryChanged: (CountryCode countryCode) {
                              _countryDialCode = countryCode.dialCode;
                            },
                            countryDialCode: _countryDialCode != null ? CountryCode.fromCountryCode(Get.find<SplashController>().configModel!.country!).code
                                : Get.find<LocalizationController>().locale.countryCode,
                            required: true,
                            labelText: 'phone'.tr,
                            validator: (value) => ValidateCheck.validateEmptyText(value, null),
                          ),
                        ),

                      ]),
                      const SizedBox(height: Dimensions.paddingSizeLarge),

                    ]),
                  ),
                  const SizedBox(height: Dimensions.paddingSizeDefault),

                  Row(children: [
                    const Icon(Icons.lock),
                    const SizedBox(width: Dimensions.paddingSizeSmall),
                    Text('login_info'.tr, style: robotoMedium.copyWith(fontSize: Dimensions.fontSizeDefault))
                  ]),
                  const SizedBox(height: Dimensions.paddingSizeSmall),

                  Container(
                    decoration: BoxDecoration(
                      color: Theme.of(context).cardColor,
                      borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
                      boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 5, spreadRadius: 1)],
                    ),
                    padding: const EdgeInsets.all(Dimensions.paddingSizeDefault),
                    margin: const EdgeInsets.symmetric(vertical: Dimensions.paddingSizeSmall),
                    child: Column(children: [

                      Row(crossAxisAlignment: CrossAxisAlignment.start, children: [

                        Expanded(
                          child: CustomTextField(
                            titleText: 'write_email'.tr,
                            controller: _emailController,
                            focusNode: _emailFocus,
                            nextFocus: _passwordFocus,
                            inputType: TextInputType.emailAddress,
                            prefixIcon: Icons.email,
                            iconSize: 25,
                            required: true,
                            labelText: 'email'.tr,
                            validator: (value) => ValidateCheck.validateEmail(value),
                          ),
                        ),
                        const SizedBox(width: Dimensions.paddingSizeLarge),

                        Expanded(
                          child: Column(children: [

                            CustomTextField(
                              titleText: '8+characters'.tr,
                              controller: _passwordController,
                              focusNode: _passwordFocus,
                              nextFocus: _confirmPasswordFocus,
                              inputType: TextInputType.visiblePassword,
                              prefixIcon: Icons.lock,
                              iconSize: 25,
                              isPassword: true,
                              onChanged: (value){
                                if(value != null && value.isNotEmpty){
                                  if(!storeRegController.showPassView){
                                    storeRegController.showHidePass();
                                  }
                                  storeRegController.validPassCheck(value);
                                }else{
                                  if(storeRegController.showPassView){
                                    storeRegController.showHidePass();
                                  }
                                }
                              },
                              required: true,
                              labelText: 'password'.tr,
                              validator: (value) => ValidateCheck.validateEmptyText(value, "password_field_is_required".tr),
                            ),

                            storeRegController.showPassView ? const PassViewWidget() : const SizedBox(),

                          ]),
                        ),
                        const SizedBox(width: Dimensions.paddingSizeLarge),

                        Expanded(child: CustomTextField(
                          titleText: '8+characters'.tr,
                          controller: _confirmPasswordController,
                          focusNode: _confirmPasswordFocus,
                          inputType: TextInputType.visiblePassword,
                          inputAction: TextInputAction.done,
                          prefixIcon: Icons.lock,
                          iconSize: 25,
                          isPassword: true,
                          required: true,
                          labelText: 'confirm_password'.tr,
                          validator: (value) => ValidateCheck.validateEmptyText(value, "password_field_is_required".tr),
                        )),
                      ]),
                      const SizedBox(height: Dimensions.paddingSizeLarge),
                    ]),
                  ),
                ],
              ) : const SizedBox(),

              storeRegController.storeStatus == 0.9 ? const WebBusinessPlanWidget() : const SizedBox(),
              const SizedBox(height: 40),

              Row(mainAxisAlignment: MainAxisAlignment.end, children: [

                Container(
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(Dimensions.radiusSmall),
                    border: Border.all(color: Theme.of(context).disabledColor.withValues(alpha: 0.3)),
                  ),
                  width: 165,
                  child: CustomButton(
                    transparent: true,
                    textColor: Theme.of(context).disabledColor,
                    radius: Dimensions.radiusSmall,
                    onPressed: () {
                      if(storeRegController.storeStatus == 0.9){
                        storeRegController.storeStatusChange(0.6);
                      }
                      else{
                        _phoneController.text = '';
                        _emailController.text = '';
                        _fNameController.text = '';
                        _lNameController.text = '';
                        _lNameController.text = '';
                        _tinNumberController.text = '';
                        _passwordController.text = '';
                        _confirmPasswordController.text = '';
                        for(int i =0; i< _nameController.length; i++ ){
                          _nameController[i].text = '';
                        }
                        for(int i =0; i< _addressController.length; i++ ){
                          _addressController[i].text = '';
                        }
                        storeRegController.resetStoreRegistration();
                      }
                    },
                    buttonText: storeRegController.storeStatus == 0.9 ? 'back'.tr : 'reset'.tr,
                    isBold: false,
                    fontSize: Dimensions.fontSizeSmall,
                  ),
                ),

                const SizedBox( width: Dimensions.paddingSizeLarge),
                SizedBox(width: 165, child: buttonView(isDesktop)),
              ]),
              const SizedBox(height: 30),

            ]),
          ),
        ),
      ]),
    );
  }

  Widget buttonView(bool isDesktop){
    return GetBuilder<StoreRegistrationController>(builder: (storeRegController) {
      return Container(
        padding: EdgeInsets.symmetric(horizontal: isDesktop ? 0 : Dimensions.paddingSizeDefault),
        decoration: isDesktop ? null : BoxDecoration(
          color: Theme.of(context).cardColor,
          boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 5, spreadRadius: 1)],
        ),
        child: Column(children: [
          !isDesktop ? Padding(
            padding: const EdgeInsets.only(bottom: Dimensions.paddingSizeDefault),
            child: Row(children: [
              Expanded(child: Container(
                height: 2,
                decoration: BoxDecoration(color: storeRegController.storeStatus == 0.1 ? Theme.of(context).primaryColor : storeRegController.storeStatus == 0.6 ? Theme.of(context).primaryColor : Colors.grey[300], borderRadius: BorderRadius.circular(2)),
              )),
              Expanded(child: Container(
                height: 2,
                decoration: BoxDecoration(color: storeRegController.storeStatus == 0.6 ? Theme.of(context).primaryColor : Colors.grey[300], borderRadius: BorderRadius.circular(2)),
              )),
              Expanded(child: Container(
                height: 2,
                decoration: BoxDecoration(color: storeRegController.storeStatus != 0.1 && storeRegController.storeStatus != 0.6 ? Theme.of(context).primaryColor : Colors.grey[300], borderRadius: BorderRadius.circular(2)),
              )),
            ]),
          ) : const SizedBox(),

          CustomButton(
            fontSize: isDesktop ? Dimensions.fontSizeSmall : Dimensions.fontSizeDefault,
            isBold: isDesktop ? false : true,
            radius: isDesktop ? Dimensions.radiusSmall : Dimensions.radiusDefault,
            isLoading: storeRegController.isLoading,
            buttonText: storeRegController.storeStatus == 0.1 && !isDesktop ? 'next'.tr : 'submit'.tr,
            color: Theme.of(context).primaryColor,
            onPressed: (storeRegController.storeStatus == 0.1 && !isDesktop && !storeRegController.inZone) || (isDesktop && !storeRegController.inZone) ? null :() async{
              _submitData(storeRegController, isDesktop);
            },
          ),
          SizedBox(height: isDesktop ? 0 : Dimensions.paddingSizeDefault),
        ]),
      );
    });
  }

  Future<void> _submitData(StoreRegistrationController storeRegController, bool isDesktop) async {
    bool defaultDataNull = false;
    for(int index=0; index<_languageList!.length; index++) {
      if(_languageList[index].key == 'en') {
        if (_nameController[index].text.trim().isEmpty || _addressController[index].text.trim().isEmpty) {
          defaultDataNull = true;
        }
        break;
      }
    }
    String tin = _tinNumberController.text.trim();
    String minTime = storeRegController.storeMinTime;
    String maxTime = storeRegController.storeMaxTime;
    String fName = _fNameController.text.trim();
    String lName = _lNameController.text.trim();
    String phone = _phoneController.text.trim();
    String email = _emailController.text.trim();
    String password = _passwordController.text.trim();
    String confirmPassword = _confirmPasswordController.text.trim();
    bool valid = false;
    try {
      double.parse(maxTime);
      double.parse(minTime);
      valid = true;
    } on FormatException {
      valid = false;
    }

    if(storeRegController.storeStatus == 0.1 || storeRegController.storeStatus == 0.6) {
      if(storeRegController.storeStatus == 0.1 && !isDesktop){
        if(defaultDataNull) {
          _scrollToKey(_storeInfoScrollKey);
        }
        if(_formKeyFirst!.currentState!.validate()){
          if(defaultDataNull) {
            showCustomSnackBar('enter_vendor_name'.tr);
          }else if(storeRegController.pickedLogo == null) {
            _scrollToKey(_storeInfoScrollKey);
            showCustomSnackBar('select_vendor_logo'.tr);
          }else if(storeRegController.pickedCover == null) {
            _scrollToKey(_storeInfoScrollKey);
            showCustomSnackBar('select_vendor_cover_photo'.tr);
          }else if(storeRegController.selectedZoneIndex == -1) {
            _scrollToKey(_locationInfoScrollKey);
            showCustomSnackBar('please_select_zone'.tr);
          }else if(storeRegController.selectedModuleIndex == -1) {
            _scrollToKey(_locationInfoScrollKey);
            showCustomSnackBar('please_select_module_first'.tr);
          }else if(storeRegController.restaurantLocation == null) {
            showCustomSnackBar('set_vendor_location'.tr);
            _scrollToKey(_locationInfoScrollKey);
          }else if(minTime.isEmpty) {
            showCustomSnackBar('enter_minimum_delivery_time'.tr);
          }else if(maxTime.isEmpty) {
            showCustomSnackBar('enter_maximum_delivery_time'.tr);
          }else if(!valid) {
            _scrollToKey(_storePrefScrollKey);
            showCustomSnackBar('please_enter_the_max_min_delivery_time'.tr);
          }else if(valid && double.parse(minTime) > double.parse(maxTime)) {
            showCustomSnackBar('maximum_delivery_time_can_not_be_smaller_then_minimum_delivery_time'.tr);
          }else{
            _scrollController.jumpTo(_scrollController.position.minScrollExtent);
            storeRegController.storeStatusChange(0.6);
            firstTime = true;
          }
        }
      }else{
        if(isDesktop){
          if(defaultDataNull) {
            showCustomSnackBar('enter_vendor_name'.tr);
            return;
          }else if(storeRegController.restaurantLocation == null) {
            showCustomSnackBar('set_vendor_location'.tr);
            return;
          }else if(storeRegController.selectedZoneIndex == -1) {
            showCustomSnackBar('please_select_zone'.tr);
            return;
          }else if(storeRegController.selectedModuleIndex == -1) {
            showCustomSnackBar('please_select_module_first'.tr);
            return;
          }else if(minTime.isEmpty) {
            showCustomSnackBar('enter_minimum_delivery_time'.tr);
            return;
          }else if(maxTime.isEmpty) {
            showCustomSnackBar('enter_maximum_delivery_time'.tr);
            return;
          }else if(!valid) {
            showCustomSnackBar('please_enter_the_max_min_delivery_time'.tr);
            return;
          }else if(valid && double.parse(minTime) > double.parse(maxTime)) {
            showCustomSnackBar('maximum_delivery_time_can_not_be_smaller_then_minimum_delivery_time'.tr);
            return;
          }else if(storeRegController.pickedLogo == null) {
            showCustomSnackBar('select_vendor_logo'.tr);
            return;
          }else if(storeRegController.pickedCover == null) {
            showCustomSnackBar('select_vendor_cover_photo'.tr);
            return;
          }
        }
        if((storeRegController.storeStatus == 0.6 && _formKeySecond!.currentState!.validate()) || isDesktop){
          if(fName.isEmpty) {
            showCustomSnackBar('enter_your_first_name'.tr);
          }else if(lName.isEmpty) {
            showCustomSnackBar('enter_your_last_name'.tr);
          }else if(phone.isEmpty) {
            showCustomSnackBar('enter_phone_number'.tr);
          }else if(email.isEmpty) {
            showCustomSnackBar('enter_email_address'.tr);
          }else if(!GetUtils.isEmail(email)) {
            showCustomSnackBar('enter_a_valid_email_address'.tr);
          }else if(password.isEmpty) {
            showCustomSnackBar('enter_password'.tr);
          }else if(password.length < 8) {
            showCustomSnackBar('password_should_be'.tr);
          }else if(password != confirmPassword) {
            showCustomSnackBar('confirm_password_does_not_matched'.tr);
          }else if(!storeRegController.spatialCheck || !storeRegController.lowercaseCheck || !storeRegController.uppercaseCheck || !storeRegController.numberCheck || !storeRegController.lengthCheck) {
            showCustomSnackBar('provide_valid_password'.tr);
          }else {
            storeRegController.storeStatusChange(0.9);
          }
        }
      }
    } else {

      List<Translation> translation = [];
      for(int index=0; index<_languageList.length; index++) {
        translation.add(Translation(
          locale: _languageList[index].key, key: 'name',
          value: _nameController[index].text.trim().isNotEmpty ? _nameController[index].text.trim()
              : _nameController[0].text.trim(),
        ));
        translation.add(Translation(
          locale: _languageList[index].key, key: 'address',
          value: _addressController[index].text.trim().isNotEmpty ? _addressController[index].text.trim()
              : _addressController[0].text.trim(),
        ));
      }

      storeRegController.registerStore(StoreBodyModel(
        translation: jsonEncode(translation), minDeliveryTime: minTime,
        maxDeliveryTime: maxTime, lat: storeRegController.restaurantLocation!.latitude.toString(), email: email,
        lng: storeRegController.restaurantLocation!.longitude.toString(), fName: fName, lName: lName, phone: _countryDialCode! + phone,
        password: password, zoneId: storeRegController.zoneList![storeRegController.selectedZoneIndex!].id.toString(),
        moduleId: storeRegController.moduleList![storeRegController.selectedModuleIndex!].id.toString(),
        deliveryTimeType: storeRegController.storeTimeUnit,
        businessPlan: storeRegController.businessIndex == 0 ? 'commission' : 'subscription',
        packageId: storeRegController.businessIndex == 0 ? '' : storeRegController.packageModel!.packages![storeRegController.activeSubscriptionIndex].id!.toString(),
        pickUpZoneIds: storeRegController.pickupZoneIdList.map((e) => e.toString()).toList(),
        tin: tin, tinExpireDate: storeRegController.tinExpireDate,
      ));
    }
  }

  void _scrollToKey(GlobalKey scrollKey) {
    final context = scrollKey.currentContext;
    if (context != null) {
      Scrollable.ensureVisible(
        context,
        duration: const Duration(seconds: 1),
        curve: Curves.easeInOut,
      );
    }
  }

  Widget _tabButton({required String title, required int index, bool isSelected = false, required Function() onTap}) {
    return InkWell(
      borderRadius: BorderRadius.circular(100),
      onTap: onTap,
      child: Container(
        height: 50,
        padding: const EdgeInsets.symmetric(horizontal: Dimensions.paddingSizeDefault, vertical: Dimensions.paddingSizeExtraSmall),
        decoration: BoxDecoration(
          color: isSelected ? Theme.of(context).primaryColor : Theme.of(context).disabledColor.withValues(alpha: 0.2),
          borderRadius: BorderRadius.circular(100),
        ),
        child: Center(
          child: Text(
            title.tr,
            style: robotoRegular.copyWith(color: isSelected ? Theme.of(context).cardColor : Theme.of(context).hintColor, fontWeight: isSelected ? FontWeight.bold : FontWeight.normal),
          ),
        ),
      ),
    );
  }

  Widget sectionCard({required String title, required Widget child, double? gap}) {
    return Container(
      width: double.infinity,
      padding: const EdgeInsets.all(Dimensions.paddingSizeSmall),
      decoration: BoxDecoration(
        color: Theme.of(context).cardColor,
        borderRadius: BorderRadius.circular(Dimensions.radiusDefault),
        boxShadow: const [BoxShadow(color: Colors.black12, blurRadius: 5, spreadRadius: 1)],
      ),
      child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
        Text(title, style: robotoSemiBold.copyWith(fontSize: Dimensions.fontSizeLarge)),
        SizedBox(height: gap ?? Dimensions.paddingSizeSmall),

        child,
      ]),
    );
  }
}
