import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:get/get.dart';

import 'controller.dart';

class MarkOverLay extends GetView<MarkOverlayController> {
  const MarkOverLay({
    Key? key,
    required this.initController,
    required this.tabHashCode,
  }) : super(key: key);

  @override
  String? get tag => tabHashCode;

  final String tabHashCode;

  final MarkOverlayController? initController;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<MarkOverlayController>(
      tag: tabHashCode,
      init: initController ?? MarkOverlayController(),
      id: MarkOverlayController.markOverlayId,
      builder: (_) {
        if (!controller.isActive || controller.bodyMark == null) {
          return SizedBox.shrink();
        }
        return SizedBox.expand(
          child: Center(
            child: AspectRatio(
              aspectRatio: controller.aspectRatio,
              child: Container(
                key: controller.markOverlayKey,
                child: Container(
                  alignment: Alignment.bottomRight,
                  margin: EdgeInsets.only(right: controller.rightMargin),
                  child: Image.memory(
                    controller.bodyMark!,
                    width: 100,
                    height: 100,
                  ),
                ),
              ),
            ),
          ),
        );
      },
    );
  }
}
