|
@@ -17,6 +17,7 @@ class MenuItemWidget extends StatefulWidget {
|
|
final Color? menuItemColor;
|
|
final Color? menuItemColor;
|
|
final bool alignCaptionedTextToLeft;
|
|
final bool alignCaptionedTextToLeft;
|
|
final double borderRadius;
|
|
final double borderRadius;
|
|
|
|
+ final Color? pressedColor;
|
|
final ExpandableController? expandableController;
|
|
final ExpandableController? expandableController;
|
|
const MenuItemWidget({
|
|
const MenuItemWidget({
|
|
required this.captionedTextWidget,
|
|
required this.captionedTextWidget,
|
|
@@ -31,6 +32,7 @@ class MenuItemWidget extends StatefulWidget {
|
|
this.menuItemColor,
|
|
this.menuItemColor,
|
|
this.alignCaptionedTextToLeft = false,
|
|
this.alignCaptionedTextToLeft = false,
|
|
this.borderRadius = 4.0,
|
|
this.borderRadius = 4.0,
|
|
|
|
+ this.pressedColor,
|
|
this.expandableController,
|
|
this.expandableController,
|
|
Key? key,
|
|
Key? key,
|
|
}) : super(key: key);
|
|
}) : super(key: key);
|
|
@@ -40,8 +42,10 @@ class MenuItemWidget extends StatefulWidget {
|
|
}
|
|
}
|
|
|
|
|
|
class _MenuItemWidgetState extends State<MenuItemWidget> {
|
|
class _MenuItemWidgetState extends State<MenuItemWidget> {
|
|
|
|
+ Color? menuItemColor;
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
|
|
+ menuItemColor = widget.menuItemColor;
|
|
if (widget.expandableController != null) {
|
|
if (widget.expandableController != null) {
|
|
widget.expandableController!.addListener(() {
|
|
widget.expandableController!.addListener(() {
|
|
setState(() {});
|
|
setState(() {});
|
|
@@ -65,6 +69,8 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
|
|
: GestureDetector(
|
|
: GestureDetector(
|
|
onTap: widget.onTap,
|
|
onTap: widget.onTap,
|
|
onDoubleTap: widget.onDoubleTap,
|
|
onDoubleTap: widget.onDoubleTap,
|
|
|
|
+ onTapDown: _onTapDown,
|
|
|
|
+ onTapUp: _onTapUp,
|
|
child: menuItemWidget(context),
|
|
child: menuItemWidget(context),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
@@ -77,7 +83,7 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
|
|
? const Radius.circular(0)
|
|
? const Radius.circular(0)
|
|
: borderRadius;
|
|
: borderRadius;
|
|
return AnimatedContainer(
|
|
return AnimatedContainer(
|
|
- duration: const Duration(milliseconds: 200),
|
|
|
|
|
|
+ duration: const Duration(milliseconds: 20),
|
|
width: double.infinity,
|
|
width: double.infinity,
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
decoration: BoxDecoration(
|
|
decoration: BoxDecoration(
|
|
@@ -87,7 +93,7 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
|
|
bottomLeft: bottomBorderRadius,
|
|
bottomLeft: bottomBorderRadius,
|
|
bottomRight: bottomBorderRadius,
|
|
bottomRight: bottomBorderRadius,
|
|
),
|
|
),
|
|
- color: widget.menuItemColor,
|
|
|
|
|
|
+ color: menuItemColor,
|
|
),
|
|
),
|
|
child: Row(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
@@ -139,4 +145,19 @@ class _MenuItemWidgetState extends State<MenuItemWidget> {
|
|
),
|
|
),
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ void _onTapDown(details) {
|
|
|
|
+ setState(() {
|
|
|
|
+ menuItemColor = widget.pressedColor;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void _onTapUp(details) {
|
|
|
|
+ Future.delayed(
|
|
|
|
+ const Duration(milliseconds: 100),
|
|
|
|
+ () => setState(() {
|
|
|
|
+ menuItemColor = widget.menuItemColor;
|
|
|
|
+ }),
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|