import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:vnoteapp/components/button.dart';
import 'package:vnoteapp/components/side_nav/defines.dart';
import 'package:vnoteapp/components/side_nav/side_nav.dart';
import 'package:vnoteapp/pages/patient/create/controller.dart';
import 'package:vnoteapp/pages/patient/create/widgets/area.dart';
import 'package:vnoteapp/pages/patient/create/widgets/crowd_label.dart';
import 'package:vnoteapp/pages/patient/create/widgets/patient_info.dart';

class CreatePatientPage extends GetView<CreatePatientController> {
  const CreatePatientPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        VSideNavView(
          // navId: NavIds.CREATE,
          items: _buildItems(),
        ),
        Positioned(
          bottom: 8,
          left: 200,
          right: 200,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceAround,
            children: [
              VButton(
                label: "下一步",
                onTap: () {
                  controller.gotoSignContract();
                },
              ),
              VButton(
                label: "存为档案",
                onTap: () {
                  controller.gotoPatientDetail();
                },
              ),
            ],
          ),
        ),
      ],
    );
  }

  List<VSideNavMenuItem> _buildItems() {
    final items = <VSideNavMenuItem>[];
    items.add(_buildSignatureItem());
    items.add(_buildAboutItem());
    items.add(_buildLogOutItem());
    return items;
  }

  VSideNavMenuItem _buildSignatureItem() {
    return VSideNavMenuItem(
      title: "签约信息",
      icon: Icon(Icons.edit_document, color: Colors.grey.shade700),
      // onTap: () {}
      pageBuilder: (_) => const Area(),
      // route: VRouteSetting(
      //   "/area_panel",
      //   () => const Area(),
      //   binding: BindingsBuilder(
      //     () {
      //       Get.lazyPut(() => CreatePatientController());
      //     },
      //   ),
      // ),
    );
  }

  VSideNavMenuItem _buildAboutItem() {
    return VSideNavMenuItem(
      title: "人群分类",
      isRequired: true,
      icon: Icon(Icons.info_outline, color: Colors.grey.shade700),
      pageBuilder: (_) => const CrowdLabelView(),
      // route: VRouteSetting(
      //   "/crowd_label_panel",
      //   () => const CrowdLabelView(),
      //   binding: BindingsBuilder(
      //     () {
      //       Get.lazyPut(() => CrowdLabelsController());
      //       Get.lazyPut(() => CreatePatientController());
      //     },
      //   ),
      // ),
      // route: VRouteSetting("/about", () => const AboutPage()),
    );
  }

  VSideNavMenuItem _buildLogOutItem() {
    return VSideNavMenuItem(
      title: "个人信息",
      icon: Icon(Icons.exit_to_app, color: Colors.grey.shade700),
      pageBuilder: (_) => const PatientInfo(),
      // route: VRouteSetting(
      //   "/patient_info_panel",
      //   () => const PatientInfo(),
      //   binding: BindingsBuilder(
      //     () {
      //       Get.lazyPut(() => CreatePatientController());
      //     },
      //   ),
      // ),
      // shouldRearrage: true, // TODO: 调整样式后启用
    );
  }
}
