mirrored_repositories/Awesome_Login_App/lib/src/common_wigets
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:login_app/src/common_wigets/fade_in_animation/fade_in_animation_model.dart';
import 'package:login_app/src/features/authentication/controllers/fade_in_animation_controller.dart';

class TFadeInAnimation extends StatelessWidget {
  TFadeInAnimation({
    super.key,
    required this.durationInMs,
    required this.animate,
    required this.child,
  });

  final controller = Get.put(FadeInAnimationController());
  final int durationInMs;
  final TAnimatePosition? animate;
  final Widget child;

  @override
  Widget build(BuildContext context) {
    return Obx(
      () => AnimatedPositioned(
        duration: Duration(milliseconds: durationInMs),
        top: controller.animate.value
            ? animate!.topAfter
            : animate!.topBefore,
        left: controller.animate.value
            ? animate!.leftAfter
            : animate!.leftBefore,
        right: controller.animate.value
            ? animate!.rightAfter
            : animate!.rightBefore,
        bottom: controller.animate.value
            ? animate!.bottomAfter
            : animate!.bottomBefore,
        child: AnimatedOpacity(
          duration: Duration(milliseconds: durationInMs),
          opacity: controller.animate.value ? 1 : 0,
          child: child,
        ),
      ),
    );
  }
}
