import 'dart:io'; import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/main.dart'; import 'package:flutter/material.dart'; import 'package:SEFER/constant/style.dart'; import 'package:flutter/services.dart'; import 'package:vibration/vibration.dart'; import '../../constant/colors.dart'; class MyElevatedButton extends StatelessWidget { final String title; final VoidCallback onPressed; final Color kolor; final int vibrateDuration; const MyElevatedButton({ Key? key, required this.title, required this.onPressed, this.kolor = AppColor.primaryColor, this.vibrateDuration = 100, }) : super(key: key); @override Widget build(BuildContext context) { bool vibrate = box.read(BoxName.isvibrate) ?? true; return ElevatedButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.all(kolor), shape: MaterialStateProperty.all(RoundedRectangleBorder( borderRadius: BorderRadius.circular(12.0), )), // padding: // MaterialStateProperty.all(const EdgeInsets.symmetric(vertical: 15)), ), onPressed: () async { // Handle haptic feedback for both iOS and Android if (vibrate) { if (Platform.isIOS) { HapticFeedback.selectionClick(); } else { Vibration.vibrate(duration: 100); // Vibrate.vibrateWithPauses(pauses); } } // Ensure the onPressed callback is called after haptic feedback onPressed(); }, child: Text( title, textAlign: TextAlign.center, style: AppStyle.title.copyWith(color: AppColor.secondaryColor), ), ); } }