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

import '../constants/global_variables.dart';
import '../themes/app_theme.dart';

class CustomButton extends StatelessWidget {
  const CustomButton({
    Key? key,
    required this.name,
    required this.onTap,
    required this.backgroundColor,
    required this.isMain,
  }) : super(key: key);
  final String name;
  final Color backgroundColor;
  final bool isMain;
  final void Function() onTap;

  @override
  Widget build(BuildContext context) {
    return Container(
      height: GlobalVariables.deviceHeight(context) / 15,
      width: double.infinity,
      decoration: BoxDecoration(
        border: Border.all(
          color: Colors.transparent,
          width: 0,
        ),
      ),
      margin: EdgeInsets.symmetric(
        vertical: 5.adaptedPx(),
      ),
      child: TextButton(
        onPressed: onTap,
        style: TextButton.styleFrom(
          backgroundColor: backgroundColor,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(10.adaptedPx()),
          ),
        ),
        child: Text(
          name,
          style: Theme.of(context).primaryTextTheme.bodyMedium?.copyWith(
                color: isMain ? AppTheme.whiteColor : AppTheme.blackColor,
                fontSize: 14.adaptedPx(),
              ),
        ),
      ),
    );
  }
}
