import 'package:cs_resources/generated/l10n.dart';
import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:router/componentRouter/component_service_manager.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_button.dart';
import 'package:widgets/my_text_view.dart';

import '../apply/form_terms_page.dart';
import 'form_detail_view_model.dart';

class DetailNotApprovedFragment extends HookConsumerWidget {
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final state = ref.watch(formDetailViewModelProvider);

    return SizedBox(
      width: double.infinity,
      height: double.infinity,
      child: Column(
        children: [
          SingleChildScrollView(
            scrollDirection: Axis.vertical,
            physics: const BouncingScrollPhysics(),
            child: Container(
              width: double.infinity,
              color: context.appColors.whiteBG,
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  //状态
                  MyTextView(
                    S.current.not_approved,
                    marginTop: 17,
                    textColor: context.appColors.textPrimary,
                    fontSize: 24,
                    isFontMedium: true,
                  ),
                  MyTextView(
                    S.current.status,
                    marginTop: 12,
                    textColor: context.appColors.textBlack,
                    fontSize: 17,
                    isFontRegular: true,
                  ),

                  //Send On时间
                  RichText(
                    text: TextSpan(
                      style: TextStyle(fontSize: 15, fontWeight: FontWeight.w400, color: context.appColors.textBlack),
                      children: <TextSpan>[
                        TextSpan(
                          text: S.current.send_on_sometime(' '),
                        ),
                        TextSpan(
                          text: state.forDetail?.createdAt ?? "-",
                          style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: context.appColors.textBlack),
                        ),
                      ],
                    ),
                  ).marginOnly(top: 12),

                  //处理时间
                  RichText(
                    text: TextSpan(
                      style: TextStyle(fontSize: 15, fontWeight: FontWeight.w400, color: context.appColors.textBlack),
                      children: <TextSpan>[
                        TextSpan(
                          text: S.current.not_approved_on_sometime(' '),
                        ),
                        TextSpan(
                          text: state.forDetail?.updateAt ?? "-",
                          style: TextStyle(fontSize: 15, fontWeight: FontWeight.w500, color: context.appColors.textBlack),
                        ),
                      ],
                    ),
                  ).marginOnly(top: 10),

                  //分割线
                  Container(
                    margin: const EdgeInsets.only(top: 19, bottom: 20),
                    width: 260,
                    color: context.appColors.dividerDefault,
                    height: 0.5,
                  ),

                  //拒绝原因
                  MyTextView(
                    "The information you sent is incorrect. Please confirm the information and resubmit!",
                    marginLeft: 50,
                    marginRight: 50,
                    textAlign: TextAlign.center,
                    textColor: context.appColors.textBlack,
                    fontSize: 17,
                    isFontRegular: true,
                  ),

                  //分割线
                  Container(
                    margin: const EdgeInsets.only(top: 19, bottom: 20),
                    width: 260,
                    color: context.appColors.dividerDefault,
                    height: 0.5,
                  ),

                  //提示 Feedback 文本
                  MyTextView(
                    S.current.send_feedback_management,
                    marginBottom: 33,
                    marginLeft: 50,
                    marginRight: 50,
                    textAlign: TextAlign.center,
                    textColor: context.appColors.textBlack,
                    fontSize: 15,
                    isFontRegular: true,
                  ),
                ],
              ),
            ),
          ).expanded(),
          Row(
            children: [
              MyButton(
                onPressed: () {
                  ComponentServiceManager().mainService.startFeedbackCreatePage(context: context);
                },
                text: S.current.send_feedback,
                textColor: Colors.white,
                fontSize: 15,
                fontWeight: FontWeight.w400,
                radius: 7,
                backgroundColor: context.appColors.btnBgDefault,
              ).expanded(),
              const SizedBox(width: 10),
              MyButton(
                onPressed: () {
                  FormTermsPage.startInstance(
                    formType: state.typeId ?? "",
                    estateFormId: state.estateFormId ?? "",
                    formItem: null,
                    enableEdit: false,
                    description: state.forDetail?.description,
                    formContent: state.forDetail?.content,
                  );
                },
                text: S.current.view_application,
                textColor: Colors.white,
                fontSize: 15,
                fontWeight: FontWeight.w400,
                radius: 7,
                backgroundColor: context.appColors.greenBG,
              ).expanded(),
            ],
          ).marginOnly(left: 15, right: 15),
          const SizedBox(height: 17.5),
        ],
      ),
    );
  }
}
