You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PatientApp-KKUMC/lib/widgets/buttons/GestureIconButton.dart

74 lines
2.0 KiB
Dart

import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:flutter/material.dart';
class GestureIconButton extends StatefulWidget {
GestureIconButton(
this.label,
this.icon, {
Key? key,
this.onTap,
this.backgroundColor,
}) : super(key: key);
final String label;
final Widget icon;
final VoidCallback? onTap;
final Color? backgroundColor;
@override
_GestureIconButtonState createState() => _GestureIconButtonState();
}
class _GestureIconButtonState extends State<GestureIconButton> {
bool _buttonLongPress = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: (){
setState(() {
_buttonLongPress = !_buttonLongPress;
});
widget.onTap!();
},
// onLongPressStart: (_) =>
// setState(() => _buttonLongPress = !_buttonLongPress),
// onLongPressEnd: (_) =>
// setState(() => _buttonLongPress = !_buttonLongPress),
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: widget.backgroundColor! != null
? widget.backgroundColor!
: Colors.grey[200]!,
),
color: widget.backgroundColor != null
? widget.backgroundColor
: Colors.grey.shade200,
borderRadius: BorderRadius.all(Radius.circular(8))),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: widget.icon,
),
Texts(
widget.label,
fontWeight: FontWeight.bold,
fontSize: 13.6,
color: _buttonLongPress ? Colors.white : Colors.black,
),
],
),
),
),
),
);
}
}