/*
 * @Author: XianKaiQun
 * @Date: 2020-08-28 14:58:44
 * @LastEditors  : WuWei
 * @LastEditTime : 2021-07-13 17:40:04
 * @Description:
 */
import 'package:flutter/widgets.dart';
import 'package:wisdom_cli/wisdom_cli.dart';

class WHandleView extends StatelessWidget {
  const WHandleView({
    Key? key,
    this.width,
    this.height,
    this.onTap,
    this.onDelete,
    this.borderRadius,
    this.border,
    this.child,
    this.color,
  }) : super(key: key);

  final double? width;
  final double? height;
  final Function()? onTap;
  final Function()? onDelete;
  final BorderRadius? borderRadius;
  final BoxBorder? border;
  final Widget? child;
  final Color? color;

  @override
  Widget build(BuildContext context) {
    Widget current = Wisdom(
      onTap: onTap,
      width: width,
      height: height,
      border: border,
      borderRadius: borderRadius,
      alignment: Alignment.center,
      color: color,
      child: child,
    );
    if (onDelete != null) {
      current = Stack(
        clipBehavior: Clip.none,
        children: [
          Padding(
            padding: EdgeInsets.fromLTRB(0, 7.pt, 7.pt, 7.pt),
            child: current,
          ),
          Positioned(
            right: 0.pt,
            top: 0.pt,
            child: WDot.delete(
              padding: EdgeInsets.all(1.pt),
              onTap: onDelete,
            ),
          ),
        ],
      );
    }

    return current;
  }
}
