49 lines
1.3 KiB
Dart
49 lines
1.3 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:sefer_driver/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) {
|
|
return ElevatedButton(
|
|
style: ButtonStyle(
|
|
backgroundColor: MaterialStateProperty.all(kolor),
|
|
),
|
|
onPressed: () async {
|
|
// Handle haptic feedback for both iOS and Android
|
|
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),
|
|
),
|
|
);
|
|
}
|
|
}
|