import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../index.dart';

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

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Align(
          alignment: Alignment.center,
          child: OverflowBox(
            maxHeight: 2000,
            maxWidth: 2000,
            child: Container(
              decoration: BoxDecoration(
                border: Border.all(
                  color: const Color.fromARGB(90, 0, 0, 0),
                  width: 400,
                  strokeAlign: BorderSide.strokeAlignOutside,
                ),
                borderRadius: BorderRadius.circular(50),
              ),
              padding: const EdgeInsets.all(20),
              child: const Image(
                image: AssetImage('assets/images/id_card.png'),
                width: 600,
              ),
            ),
          ),
        ),
        Align(
          alignment: Alignment.centerRight,
          child: _captureButton(),
        ),
        Align(
          alignment: Alignment.bottomCenter,
          child: Container(
            padding: const EdgeInsets.only(bottom: 70),
            child: const Text(
              '请将身份证（人像面）置于虚线框内，并确保图像清晰可见，然后按下拍摄键',
              style: TextStyle(color: Colors.white, fontSize: 22),
            ),
          ),
        ),
      ],
    );
  }

  Widget _captureButton() {
    return Container(
      margin: const EdgeInsets.only(right: 60),
      width: 100,
      height: 100,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(50),
      ),
      child: IconButton(
        icon: const Icon(Icons.camera_alt, size: 40),
        color: Colors.blue,
        onPressed: controller.onCaptureIdCardButtonPressed,
      ),
    );
  }
}
