import 'package:flutter/material.dart';

/// 录制页内容切换时的统一过渡动画。
class RecordContentTransition {
  RecordContentTransition._();

  static const duration = Duration(milliseconds: 600);

  static Widget builder(Widget child, Animation<double> animation) {
    final curved = CurvedAnimation(
      parent: animation,
      curve: Curves.easeOutCubic,
      reverseCurve: Curves.easeInCubic,
    );

    return FadeTransition(
      opacity: curved,
      child: SlideTransition(
        position: Tween<Offset>(
          begin: const Offset(0, 0.12),
          end: Offset.zero,
        ).animate(curved),
        child: child,
      ),
    );
  }

  static Widget stackLayoutBuilder(
    Widget? currentChild,
    List<Widget> previousChildren,
  ) {
    return Stack(
      alignment: Alignment.center,
      clipBehavior: Clip.none,
      children: [...previousChildren, ?currentChild],
    );
  }

  static Widget bottomStackLayoutBuilder(
    Widget? currentChild,
    List<Widget> previousChildren,
  ) {
    return Stack(
      alignment: Alignment.bottomLeft,
      clipBehavior: Clip.none,
      children: [...previousChildren, ?currentChild],
    );
  }
}
