import 'dart:io';

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

import '../../constant/colors.dart';
import '../../constant/style.dart';

class MyElevatedButton extends StatelessWidget {
  final String title;
  final VoidCallback onPressed;
  final Color? kolor;
  final IconData? icon;
  
  const MyElevatedButton({
    Key? key,
    required this.title,
    required this.onPressed,
    this.kolor,
    this.icon,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: 56,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(16),
        boxShadow: [
          BoxShadow(
            color: (kolor ?? AppColor.accent).withOpacity(0.3),
            blurRadius: 12,
            offset: const Offset(0, 4),
          ),
        ],
      ),
      child: ElevatedButton(
        style: ElevatedButton.styleFrom(
          backgroundColor: kolor ?? AppColor.accent,
          foregroundColor: Colors.white,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(16),
          ),
          elevation: 0,
        ),
        onPressed: () {
          HapticFeedback.lightImpact();
          onPressed();
        },
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            if (icon != null) ...[
              Icon(icon, size: 20),
              const SizedBox(width: 8),
            ],
            Text(
              title,
              style: AppStyle.title.copyWith(color: Colors.white),
            ),
          ],
        ),
      ),
    );
  }
}

