/*
 * @Descripttion: 
 * @version: 
 * @Author: guanxiaoxin
 * @Date: 2023-10-16 13:36:49
 * @LastEditors: guanxiaoxin
 * @LastEditTime: 2023-10-18 17:36:22
 * @FilePath: \VNoteApp\lib\pages\patient\detail\widgets\functions_panel.dart
 */
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vnoteapp/consts/styles.dart';
import 'package:vnoteapp/pages/widgets/function_button.dart';

import '../controller.dart';

/// 功能入口面板
class FunctionsPanel extends GetView<PatientDetailController> {
  const FunctionsPanel({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.topLeft,
      margin: const EdgeInsets.all(8).copyWith(left: 0, right: 12),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: GlobalStyles.borderRadius,
      ),
      padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 12)
          .copyWith(right: 0),
      child: GridView(
        padding: const EdgeInsets.symmetric(horizontal: 32).copyWith(top: 12),
        // shrinkWrap: true,
        // controller: scrollController,
        gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 3,
          mainAxisSpacing: 24,
          crossAxisSpacing: 24,
          childAspectRatio: 16 / 14,
        ),
        children: [
          FunctionButton(
            label: "健康档案",
            icon: _buildImgIcon("档案.png"),
            onTap: controller.gotoInfo,
          ),
          FunctionButton(
            label: "健康体检",
            icon: _buildImgIcon("体检.png"),
            onTap: controller.gotoHealthCheck,
          ),
          FunctionButton(
            label: "体检记录",
            icon: _buildImgIcon("体检记录.png"),
            onTap: controller.gotoHealthCheckRecord,
          ),
          FunctionButton(
            label: "人群随访",
            icon: _buildImgIcon("随访.png"),
            onTap: controller.gotoFollowUp,
          ),
          FunctionButton(
            label: "随访记录",
            icon: _buildImgIcon("随访报告.png"),
            onTap: controller.gotoFollowUpRecord,
          ),
          FunctionButton(
            label: "医生签约",
            icon: _buildImgIcon("签约.png"),
            onTap: controller.gotoContract,
          ),
          // FunctionButton(
          //   label: "诊疗展示",
          //   icon: _buildImgIcon("诊疗.png"),
          //   onTap: controller.gotoExam,
          // ),
          // FunctionButton(
          //   label: "双向转诊",
          //   icon: _buildImgIcon("转诊.png"),
          //   onTap: controller.gotoReferral,
          // ),
          FunctionButton(
            label: "签约记录",
            icon: _buildImgIcon("签约记录.png"),
            onTap: controller.gotoContractRecords,
          ),
          FunctionButton(
            label: "诊疗展示",
            icon: _buildImgIcon("诊疗.png"),
            onTap: controller.gotoExam,
          ),
        ],
      ),
    );
  }

  Widget _buildImgIcon(String assetName) {
    return Image.asset(
      "assets/images/patient/$assetName",
      width: 120,
      height: 120,
      fit: BoxFit.contain,
    );
  }
}
