import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'index.dart';
import 'widgets/vid_ui_repaint_layer.dart';

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

  @override
  String? get tag => tabHashCode;

  final String tabHashCode;

  final VidUIRepaintOverlayController? initController;

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