import 'package:flutter/material.dart';
import 'package:flyinsono/architecture/define.dart';
import 'package:fis_ui/index.dart';
import 'package:flyinsono/managers/interfaces/entities/image_report_list_params.dart';
import 'package:flyinsono/pages/remedical/image_report_inner_view/view.dart';
import 'package:flyinsono/pages/user/group_chat/widgets/message_input_area.dart';
import 'package:get/get.dart';
import 'widgets/widgets.dart';
import 'index.dart';

class GroupChatPage extends FisView<GroupChatController> {
  const GroupChatPage({Key? key, this.args}) : super(key: key);

  /// 页面入参，如果通过路由跳转，不需要传此参数
  final ChatPageArgs? args;

  @override
  FWidget build(BuildContext context) {
    return FisBuilder<GroupChatController>(
      init: GroupChatController(initArgs: args),
      builder: (_) {
        Widget bodyContent = Scaffold(
          key: controller.scaffoldKey,
          appBar: AppBar(
            backgroundColor: kIsMobile ? null : Colors.white,
            foregroundColor: kIsMobile ? null : Colors.black87,
            leading: kIsMobile ? null : Container(),
            centerTitle: true,
            title: Obx(
              () => Text(
                controller.state.groupName,
              ),
            ),
            actions: [
              IconButton(
                onPressed: () {
                  controller.openDrawer();
                },
                icon: const Icon(Icons.more_horiz),
              ),
            ],
          ),
          endDrawer: Drawer(
            backgroundColor: Colors.grey[100],
            child: InfoDrawer(),
          ),
          body: SafeArea(
            child: Column(
              children: [
                Expanded(
                  child: FInkWell(
                    mouseCursor: SystemMouseCursors.basic,
                    // 将highlightColor和splashColor设置为透明色
                    highlightColor: Colors.transparent,
                    splashColor: Colors.transparent,
                    hoverColor: Colors.transparent,
                    focusColor: Colors.transparent,
                    onTap: () {
                      controller.closeImageAndReportsDrawer();
                    },
                    child: MessagesView(),
                  ),
                ),
                //   MessagesInputArea(),
              ],
            ),
          ),
        );
        return Stack(
          children: [
            bodyContent,
            Positioned(
              right: 0,
              top: 0,
              bottom: 0,
              width: 320,
              child: FObx(() {
                if (controller.state.showImageAndReportsDrawer) {
                  return FContainer(
                    decoration: BoxDecoration(
                      boxShadow: [
                        BoxShadow(
                          color: Colors.grey.withOpacity(0.5),
                          spreadRadius: 2,
                          blurRadius: 5,
                          offset: Offset(0, 3), // 阴影偏移量
                        ),
                      ],
                      border: Border(
                        left: BorderSide(
                          color: Colors.grey[300]!,
                          width: 1,
                        ),
                      ),
                      color: Colors.white,
                    ),
                    child: ImageReportInnerView(
                      args: ImageReportListParams(
                        recordCode: controller.recordCode,
                        index: controller.cacheIndex,
                        isShowWriteReportButton: controller.canCreateReport,
                      ),
                    ),
                  );
                }
                return FSizedBox();
              }),
            ),
          ],
        );
      },
    );
  }
}
