import 'package:flyinsono/lab/pages/lab_image/widgets/urm_result_overlay/widgets/urm_canvas_layer.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'index.dart';

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

  @override
  String? get tag => tabHashCode;

  final String tabHashCode;

  final URMResultOverlayController? initController;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<URMResultOverlayController>(
      tag: tabHashCode,
      init: initController ?? URMResultOverlayController(),
      id: URMResultOverlayController.urmResultOverlayId,
      builder: (_) {
        if (!controller.isActive) {
          return SizedBox.shrink();
        }
        return SizedBox.expand(
          child: IgnorePointer(
            ignoring: true,
            child: Center(
              child: AspectRatio(
                aspectRatio: controller.aspectRatio,
                child: Container(
                  key: controller.urmResultLayerKey,
                  child: Stack(
                    children: [
                      URMCanvasLayer(
                        tabHashCode: tabHashCode,
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ),
        );
      },
    );
  }
}
