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.
71 lines
2.1 KiB
Dart
71 lines
2.1 KiB
Dart
4 years ago
|
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(
|
||
|
onLongPressStart: (_) =>
|
||
|
setState(() => _buttonLongPress = !_buttonLongPress),
|
||
|
onLongPressEnd: (_) =>
|
||
|
setState(() => _buttonLongPress = !_buttonLongPress),
|
||
|
child: Wrap(
|
||
|
children: [
|
||
|
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: Expanded(
|
||
|
child: Row(
|
||
|
mainAxisSize: MainAxisSize.min,
|
||
|
children: [
|
||
|
Padding(
|
||
|
padding: const EdgeInsets.only(right: 8.0),
|
||
|
child: widget.icon,
|
||
|
),
|
||
|
Texts(
|
||
|
widget.label,
|
||
|
color: _buttonLongPress ? Colors.white : Colors.black,
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|