

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:location/utils/common_expand.dart';

import '../../../base/base_page.dart';
import '../../../resource/colors.gen.dart';
import '../../../resource/string.gen.dart';
import '../../../router/app_pages.dart';
import '../../../widget/common_view.dart';
import 'news_report_controller.dart';
import 'news_repost_text_view.dart';
import 'news_tap_to_dismiss_key_board.dart';

class NewsReportPage extends BasePage<NewsReportController> {
  const NewsReportPage({super.key});

  static void start() {
    Get.toNamed(RoutePath.newsReport);
  }

  @override
  bool immersive() {
    return false;
  }

  @override
  Widget buildBody(BuildContext context) {
    // TODO: implement buildBody
    return NewsTapToDismissKeyBoard(child: Column(
      children: [
        buildHeadView(onTap: controller.back),
        SizedBox(height: 28.w,),
        Container(
          padding: EdgeInsets.symmetric(horizontal: 16.w),
          child: Column(
            children: [
              Row(
                children: [
                  Text("*",
                      style: TextStyle(
                          fontSize: 14.sp,
                          color: '#FF3C3C'.color,
                          fontWeight: FontWeight.w500)),
                  Text("举报内容",
                      style: TextStyle(
                          fontSize: 14.sp,
                          color: "#333333".color,
                          fontWeight: FontWeight.w500))
                ],
              ),
              SizedBox(height: 10.w,),
              Container(
                color: ColorName.white,
                child: NewsRepostTextView(
                  controller: controller.reportContetnController,
                  onChanged: (text) {
                    // 实时监听文本变化
                    print('当前内容: $text');
                    controller.inputContentText(text);
                  },
                ),
              ),
              SizedBox(height: 30.w,),
              Container(
                child: Obx(() {
                  return GestureDetector(
                    onTap: controller.submitBuEnble.value  ? controller.onSubmti : null,
                    child: Container(
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        color: controller.submitBuEnble.value  ? "#7B7DFF".color : ColorName.black30,
                        borderRadius: BorderRadius.all(Radius.circular(41.w / 2)),
                      ),
                      width: 114.w,
                      height: 41.w,
                      child: Text(
                          "提 交",
                          style: TextStyle(
                              fontSize: 16.sp, color: ColorName.white, fontWeight: FontWeight.w400)
                      ),

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


Widget buildHeadView({GestureTapCallback? onTap}) {
  return Container(
    margin: EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
    child: Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        GestureDetector(
            onTap: onTap, child: CommonView.getBackBtnView()),
        Text("举报投诉",
            style: TextStyle(
                fontSize: 18.sp,
                color: '#202020'.color,
                fontWeight: FontWeight.bold)),
        SizedBox(width: 24.w, height: 24.w)
      ],
    ),
  );
}
