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

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

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

  @override
  String? get tag => tabHashCode;

  final String tabHashCode;

  final VidRepaintOverlayController? initController;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<VidRepaintOverlayController>(
      tag: tabHashCode,
      init: initController ?? VidRepaintOverlayController(),
      id: VidRepaintOverlayController.vidRepaintOverlayId,
      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: [
                      VidRepaintLayer(
                        tabHashCode: tabHashCode,
                      ),
                    ],
                  ),
                ),
              ),
            ),
          ),
        );
      },
    );
  }
}
