mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-08-26 02:04:25 +08:00
reworked
This commit is contained in:
63
flutter/lib/desktop/widgets/menu_button.dart
Normal file
63
flutter/lib/desktop/widgets/menu_button.dart
Normal file
@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MenuButton extends StatefulWidget {
|
||||
final GestureTapCallback? onPressed;
|
||||
final Color color;
|
||||
final Color hoverColor;
|
||||
final Color? splashColor;
|
||||
final Widget icon;
|
||||
final double iconSize;
|
||||
final String tooltip;
|
||||
final EdgeInsetsGeometry padding;
|
||||
final bool enableFeedback;
|
||||
const MenuButton({
|
||||
super.key,
|
||||
required this.onPressed,
|
||||
required this.color,
|
||||
required this.hoverColor,
|
||||
required this.icon,
|
||||
required this.iconSize,
|
||||
required this.tooltip,
|
||||
this.splashColor,
|
||||
this.padding = const EdgeInsets.all(5),
|
||||
this.enableFeedback = true,
|
||||
});
|
||||
|
||||
@override
|
||||
State<MenuButton> createState() => _MenuButtonState();
|
||||
}
|
||||
|
||||
class _MenuButtonState extends State<MenuButton> {
|
||||
bool _isHover = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: widget.padding,
|
||||
child: Tooltip(
|
||||
message: widget.tooltip,
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: _isHover ? widget.hoverColor : widget.color,
|
||||
),
|
||||
child: InkWell(
|
||||
onHover: (val) {
|
||||
setState(() {
|
||||
_isHover = val;
|
||||
});
|
||||
},
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
splashColor: widget.splashColor,
|
||||
enableFeedback: widget.enableFeedback,
|
||||
onTap: widget.onPressed,
|
||||
child: widget.icon,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user