/*
 * @Descripttion: 
 * @version: 
 * @Author: guanxiaoxin
 * @Date: 2023-10-16 15:02:26
 * @LastEditors: guanxiaoxin
 * @LastEditTime: 2023-10-25 14:28:40
 * @FilePath: \VNoteApp\lib\pages\check\follow_up\view.dart
 */
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vnoteapp/pages/check/follow_up/widgets/follow_up_from.dart';
import 'package:vnoteapp/pages/check/widgets/check_category_widget.dart';
import 'package:vnoteapp/pages/check/widgets/configurable_card.dart';

import 'index.dart';

class FollowUpPage extends GetView<FollowUpController> {
  const FollowUpPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<FollowUpController>(
      init: FollowUpController(),
      id: "examination",
      builder: (_) => buildFollowUpPage(),
    );
  }

  Widget buildFollowUpPage() {
    return Scaffold(
      backgroundColor: Colors.white,
      // appBar: VAppBar(
      //   titleWidget: const Text('人群随访'),
      // ),
      body: Scrollbar(
        thumbVisibility: true,
        child: SingleChildScrollView(
          child: Container(
            padding: const EdgeInsets.symmetric(
              horizontal: 50,
              vertical: 20,
            ),
            child: buildFollowUpList(),
          ),
        ),
      ),
    );
  }

  Widget buildFollowUpList() {
    return Wrap(
      spacing: 40,
      runSpacing: 40,
      children: controller.menuList
          .map((e) => CheckCategoryWidget(
                label: e.label,
                assetName: "${e.label}.png",
                onTap: () {
                  changePage(e.value);
                },
              ))
          .toList(),
    );
  }

  void changePage(String key) {
    Get.to(
      ConfigurableCard(
        cardKey: key,
        callBack: (key, templateCode, data) async {
          await controller.createFollowUp(key, templateCode, data);
          Get.back();
        },
        followUpWidget: const FollowUpFrom(),
      ),
    );
  }
}
