2021-08-16 12:42:41 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class CustomButton extends StatefulWidget {
|
2021-08-18 15:46:01 +02:00
|
|
|
const CustomButton({Key? key, required this.name, required this.size, required this.navigator}) : super(key: key);
|
2021-08-16 12:42:41 +02:00
|
|
|
|
|
|
|
final String name;
|
|
|
|
final double size;
|
2021-08-18 15:46:01 +02:00
|
|
|
final Function() navigator;
|
2021-08-16 12:42:41 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
_CustomButtonState createState() => _CustomButtonState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _CustomButtonState extends State<CustomButton> {
|
|
|
|
bool isTap = false;
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return InkWell(
|
|
|
|
onTap: () {
|
|
|
|
setState(() {
|
|
|
|
isTap = true;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
onTapDown: (x) {
|
|
|
|
setState(() {
|
|
|
|
isTap = false;
|
|
|
|
});
|
2021-08-18 15:46:01 +02:00
|
|
|
widget.navigator();
|
2021-08-16 12:42:41 +02:00
|
|
|
},
|
|
|
|
child: AnimatedContainer(
|
|
|
|
duration: const Duration(milliseconds: 150),
|
|
|
|
width: isTap ? widget.size - 10 : widget.size,
|
|
|
|
height: isTap ? widget.size - 10 : widget.size,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
image: DecorationImage(
|
|
|
|
image: AssetImage('assets/images/buttons/${widget.name}.png'),
|
|
|
|
)
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|