/*
 * @Author: XianKaiQun
 * @Date: 2020-09-11 09:48:19
 * @LastEditors  : WuWei
 * @LastEditTime : 2023-08-08 11:13:14
 * @Description: 
 */
part of '../index.dart';

///裁剪组件
class _PhotoComponent extends StatefulWidget {
  _PhotoComponent({Key? key}) : super(key: key);

  @override
  __PhotoComponentState createState() => __PhotoComponentState();
}

class __PhotoComponentState extends State<_PhotoComponent> {
  @override
  Widget build(BuildContext context) {
    final store = Provider.of<PrivateEditStore>(context);

    return GestureDetector(
      child: Wisdom.stack(
        height: 345.pt,
        width: 345.pt,
        borderRadius: BorderRadius.circular(4.pt),
        margin: EdgeInsets.all(15.pt),
        children: [
          ExtendedImage.file(
            store.file,
            fit: BoxFit.contain,
            width: 345.pt,
            mode: ExtendedImageMode.editor,
            extendedImageEditorKey: store.editorKey,
            cacheRawData: true,
            initEditorConfigHandler: (state) {
              return EditorConfig(
                maxScale: 8.0,
                cropRectPadding: EdgeInsets.zero,
                cornerColor: Colors.transparent,
                hitTestSize: 0.001,
                lineHeight: 0.001,
                cropAspectRatio: 1,
                initCropRectType: InitCropRectType.layoutRect,
              );
            },
          ),
          Positioned(
            top: 0,
            left: 0,
            right: 0,
            child: Wisdom(
              color: Colors.black38,
              padding: EdgeInsets.symmetric(vertical: 10.pt),
              child: Text(
                '请把人脸对准在人脸轮廓内',
                textAlign: TextAlign.center,
                style: TextStyle(
                  color: Colors.white,
                ),
              ),
            ),
          ),
          IgnorePointer(
            ignoring: true,
            child: Wisdom(
              alignment: Alignment.bottomCenter,
              child: Image(
                image: AssetList.$outline_png_image,
              ),
            ),
          ),
        ],
      ),
    );
  }
}
