import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:worker_client/widgets/MyButton/entities/Gradient.dart';

import '../GradientButton.dart';

class MyButton extends StatelessWidget {
  final String text;
  //type 1 绿色 2 黄色
  final int type;
  //true 有结束动画 false 无变化
  final bool disable;
  //点击事件
  final GestureTapCallback onClick;

  MyButton(
      {Key? key,
      required this.text,
      required this.type,
      required this.disable,
      required this.onClick})
      : super(key: key);

  List<GradientModel> Glist=[
    GradientModel(Color(0xFFA0E067), Color(0xFF00AE39)),
    GradientModel(Color(0xFFFFAB8C), Color(0xFFFF703B)),
  ];
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.fromLTRB(0, 12.5.h, 0, 9.h),
      width: 315.w,
      height: 49.h,
      child: GradientButton(
          colors: [Glist[type].beginColor,Glist[type].endColor],
          borderRadius: BorderRadius.all(Radius.circular(24.5.w)),
          onPressed: disable ? null : onClick,
          child: Text(
            text,
            style: TextStyle(
              fontSize: 17.sp,
              fontWeight: FontWeight.bold,
              letterSpacing: 2
            ),
          )),
    );
  }
}
