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 '../index.dart';

/// 功能按钮组
class MenuButtons extends FisView<WxHomeController> {
  const MenuButtons({Key? key}) : super(key: key);

  @override
  FWidget build(BuildContext context) {
    return FGridView.count(
      physics: NeverScrollableScrollPhysics(),
      childAspectRatio: 1,
      crossAxisCount: 2,
      crossAxisSpacing: 20,
      mainAxisSpacing: 20,
      shrinkWrap: true,
      children: [
        _buildButton(
          "预约会诊",
          FIcons.live_consultation,
          MobileRouteNames.Wechat.MiniProgramConsultation,
        ),
        _buildButton(
          "分时诊断",
          FIcons.diagnostics,
          MobileRouteNames.Wechat.MiniProgramDiagnosis,
        ),
        _buildButton(
          "账号绑定",
          Icons.wechat,
          MobileRouteNames.Wechat.MiniProgramBind,
        ),
        _buildButton(
          "调试工具",
          Icons.build,
          MobileRouteNames.Wechat.MiniProgramDebug,
        ),
      ],
    );
  }

  FWidget _buildButton(
    String text,
    IconData icon,
    String routeName,
  ) {
    return FContainer(
      margin: EdgeInsets.all(10),
      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: 30,
            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: () => controller.routerTo(routeName),
          child: FColumn(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              FIcon(
                icon,
                size: 80,
                color: Color.fromARGB(255, 241, 241, 241),
              ),
              FCenter(
                child: FText(
                  text,
                  style: TextStyle(
                    fontWeight: FontWeight.bold,
                    color: Color.fromARGB(255, 241, 241, 241),
                    fontSize: 20,
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
