import 'package:flutter/material.dart';

class WCadre extends StatelessWidget {
  const WCadre(
      {required this.child,
      this.title = "",
      this.titleleft,
      this.titleright,
      this.bottom,
      this.bottomright,
      this.bottomleft,
      this.color = Colors.grey,
      this.background = Colors.black,
      this.height,
      super.key});
  final dynamic title;
  final Widget? titleright;
  final Widget? titleleft;
  final Widget child;
  final dynamic bottom;
  final Widget? bottomright;
  final Widget? bottomleft;
  final Color color;
  final Color background;
  final double? height;

  @override
  Widget build(BuildContext context) {
    return Container(
      // width: 300,
      height: height,
      decoration: BoxDecoration(
        color: Colors.black,
        border: Border.all(
          width: 3,
          color: Colors.grey,
        ),
      ),
      child: Column(
        children: [
          if (titleleft != null || title != "" || titleright != null) ...[
            Row(
              mainAxisSize: MainAxisSize.max,
              children: [
                if (titleleft != null) titleleft!,
                Expanded(
                    child: Container(
                        alignment: Alignment.center,
                        child: (title is Widget)
                            ? title
                            : Text(
                                "$title",
                                style: const TextStyle(
                                    fontSize: 22,
                                    fontWeight: FontWeight.w600,
                                    color: Colors.blue),
                              ))),
                if (titleright != null) titleright!,
              ],
            ),
            Divider(
              height: 3,
              thickness: 2,
              color: color,
            )
          ],
          if (height == null)
            child
          else
            Expanded(
              child: SingleChildScrollView(
                child: child,
              ),
            ),
          if (bottomleft != null || bottom != null || bottomright != null) ...[
            Divider(
              height: 2,
              thickness: 1,
              color: color,
            ),
            Row(
              children: [
                if (bottomleft != null) bottomleft!,
                Expanded(
                  child: Container(
                      alignment: Alignment.center,
                      child: (bottom is Widget)
                          ? bottom
                          : Text(
                              "${bottom ?? ''}",
                              style: const TextStyle(
                                  fontSize: 12, color: Colors.grey),
                            )),
                ),
                if (bottomright != null) bottomright!,
              ],
            )
          ],
        ],
      ),
    );
  }
}
