import 'package:common_pub/model/control_point.dart';
import 'package:common_pub/ui/control_point_history_view.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'data_detail_controller.dart';

class DataDetailCP extends GetView<DataDetailController> {
  final List<ControlPoint> cpList;

  const DataDetailCP({super.key, required this.cpList});
  @override
  Widget build(BuildContext context) {
    return Container(
        width: double.infinity,
        padding: const EdgeInsets.all(2.9),
        decoration: BoxDecoration(
            color: const Color(0xffe0e0e0),
            borderRadius: BorderRadius.circular(3.56)),
        child: Column(children: [
          GestureDetector(
            onTap: () {
              controller.isCPExpand.value = !controller.isCPExpand.value;
            },
            child: Obx(() => Container(
                  padding: const EdgeInsets.fromLTRB(12, 4, 12, 4),
                  margin: EdgeInsets.only(
                      bottom: controller.isCPExpand.value ? 4 : 0),
                  decoration: BoxDecoration(
                      color: Colors.white,
                      borderRadius: BorderRadius.circular(3.56)),
                  child: Row(
                    children: [
                      const Text('控制点'),
                      const Spacer(),
                      Icon(controller.isCPExpand.value
                          ? Icons.arrow_drop_up
                          : Icons.arrow_drop_down)
                    ],
                  ),
                )),
          ),
          Obx(() => controller.isCPExpand.value
              ? ControlPointHistoryView(cpList: cpList)
              : const SizedBox())
        ]));
  }
}
