import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/architecture/define.dart';
import 'package:flyinsono/architecture/router/mobile/names.dart';
import 'package:flyinsono/architecture/states/states.dart';
import 'package:get/get.dart';

import '../index.dart';

/// hello
class DebugMenuButtons extends FisView<WxDebugController> {
  const DebugMenuButtons({Key? key}) : super(key: key);

  @override
  FWidget build(BuildContext context) {
    return FGridView.count(
      physics: NeverScrollableScrollPhysics(),
      childAspectRatio: 1,
      crossAxisCount: 4,
      crossAxisSpacing: 10,
      mainAxisSpacing: 10,
      shrinkWrap: true,
      children: [
        _buildButton(
          "回到首页",
          Icons.home,
          () => Get.offNamed(MobileRouteNames.Wechat.MiniProgramHome),
        ),
        _buildButton(
          "账号绑定",
          Icons.wechat,
          () => Get.toNamed(MobileRouteNames.Wechat.MiniProgramBind),
        ),
        _buildButton(
          "WS 测试",
          Icons.link,
          () => controller.startWebSocket(),
        ),
        _buildButton(
          "预约会诊",
          FIcons.live_consultation,
          () => Get.toNamed(MobileRouteNames.Wechat.MiniProgramConsultation),
        ),
        _buildButton(
          "会诊详情",
          FIcons.live_consultation,
          () => Get.toNamed(
              MobileRouteNames.Wechat.MiniProgramConsultationDetail),
        ),
        _buildButton(
          "会诊房间",
          FIcons.live_consultation,
          () =>
              Get.toNamed(MobileRouteNames.Wechat.MiniProgramConsultationRoom),
        ),
        _buildButton(
          "报告列表",
          FIcons.report_a4,
          () => Get.toNamed(MobileRouteNames.Wechat.MiniProgramReports),
        ),
        _buildButton(
          "报告预览",
          FIcons.report_a4,
          () => Get.toNamed(MobileRouteNames.Wechat.MiniProgramReportDetail),
        ),
        _buildButton(
          "分时诊断",
          FIcons.diagnostics,
          () => Get.toNamed(MobileRouteNames.Wechat.MiniProgramDiagnosis),
        ),
        _buildButton(
          "诊断详情",
          FIcons.diagnostics,
          () => Get.toNamed(MobileRouteNames.Wechat.MiniProgramDiagnosisDetail),
        ),
        _buildButton(
          "图像列表",
          FIcons.scan_image,
          () => Get.toNamed(MobileRouteNames.Wechat.MiniProgramImages),
        ),
        _buildButton(
          "图像预览",
          FIcons.scan_image,
          () => Get.toNamed(MobileRouteNames.Wechat.MiniProgramImageDetail),
        ),
        _buildButton(
          "Token",
          Icons.delete,
          () => Store.user.setToken(""),
        ),
        _buildButton(
          "OpenId",
          Icons.delete,
          () => Store.user.setOpenid(""),
        ),
      ],
    );
  }

  FWidget _buildButton(String text, IconData icon, void Function()? onTap) {
    return FContainer(
      margin: EdgeInsets.all(5),
      decoration: BoxDecoration(
        color: Color.fromARGB(255, 84, 144, 249),
        // border: Border.all(color: Color.fromARGB(255, 170, 170, 170), width: 1),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.2),
            spreadRadius: 0,
            blurRadius: 20,
            offset: Offset(3, 3), // changes position of shadow
          ),
        ],
        borderRadius: BorderRadius.circular(10),
      ),
      clipBehavior: Clip.antiAlias,
      child: FMaterial(
        color: Color.fromARGB(255, 84, 144, 249),
        child: FInkWell(
          highlightColor: Color.fromARGB(255, 49, 125, 255),
          onTap: onTap,
          child: FColumn(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              FIcon(
                icon,
                size: 30,
                color: Color.fromARGB(255, 241, 241, 241),
              ),
              FCenter(
                child: FText(
                  text,
                  style: TextStyle(
                    color: Color.fromARGB(255, 241, 241, 241),
                    fontSize: 14,
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
