import 'package:aman_kassa_flutter/shared/app_colors.dart';
import 'package:aman_kassa_flutter/widgets/fields/busy_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class ActionView extends StatelessWidget {
  final String? acceptText;
  final String? declineText;
  final void Function()? acceptCallback;
  final void Function()? declineCallback;
  final bool show;

  const ActionView(
      {Key? key,
      this.acceptText,
      this.declineText,
      this.acceptCallback,
      this.declineCallback,
      this.show = false})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Positioned(
        bottom: ScreenUtil().setSp(100),
        left: ScreenUtil().setSp(25),
        right: ScreenUtil().setSp(25),
        child: AnimatedOpacity(
          duration: const Duration(milliseconds: 300),
          opacity: show ? 1.0 : 0.0,
          child: AnimatedContainer(
              duration: const Duration(milliseconds: 300),
              child: buildContainer()),
        ));
  }

  Row buildContainer() {
    return Row(
      children: <Widget>[
        if (acceptCallback !=null && acceptText !=null)
          Expanded(child: BusyButton(title: acceptText!, onPressed: acceptCallback!)),
        SizedBox(width: 5.0,),
        if (declineCallback !=null && declineText !=null)
          BusyButton(title: declineText!, onPressed: declineCallback!, mainColor: redColor,)
      ],
    );
  }
}
