import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/modules/cm_module/service_request_detail_provider.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';

import 'bottom_sheets/service_request_bottomsheet.dart';

class InitialVisitCard extends StatefulWidget {
  const InitialVisitCard({Key? key}) : super(key: key);

  @override
  State<InitialVisitCard> createState() => _InitialVisitCardState();
}

class _InitialVisitCardState extends State<InitialVisitCard> {
  @override
  void initState() {
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Consumer<ServiceRequestDetailProvider>(builder: (context, ServiceRequestDetailProvider requestDetailProvider, snapshot) {
      return Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
            Text(
              requestDetailProvider.needVisitHelperModel!.visitDate != null ? requestDetailProvider.needVisitHelperModel!.visitDate.toString().toInitialVisitCardFormat : '',
              textAlign: TextAlign.end,
              style: AppTextStyles.heading6.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.black10),
            ),
            Row(
              children: [
                "reminder_icon".toSvgAsset(height: 21, width: 21).onPress(() {
                  ServiceRequestBottomSheet.getReminderTimeList(context: context);
                  ServiceRequestBottomSheet.initialVisitReminderBottomSheet(context: context, reminder: requestDetailProvider.currentWorkOrder?.data?.setReminder);
                }),
                24.width,
                "edit_icon".toSvgAsset(height: 21, width: 21).onPress(() {
                  ServiceRequestBottomSheet.initialVisitBottomSheet(context: context);
                }),
              ],
            ),
          ]),
          2.height,
          context.translation.visitDateAndTime.bodyText2(context).custom(color: AppColor.neutral120),
          12.height,
          if (requestDetailProvider.needVisitHelperModel?.comment != null) ...[
            requestDetailProvider.needVisitHelperModel!.comment!.bodyText2(context).custom(color: AppColor.neutral120),
          ]
        ],
      ).toShadowContainer(context,margin:const  EdgeInsets.only(top: 12));
    });
  }
}
