123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- import 'package:flutter/material.dart';
- import 'package:fis_theme/theme.dart';
- import 'package:flyinsono/lab/color/lab_colors.dart';
- class MoreOperateButton extends StatefulWidget {
- MoreOperateButton({
- super.key,
- this.onClick,
- this.name = '更多',
- this.icon = Icons.more_horiz,
- });
- final VoidCallback? onClick;
- final String name;
- final IconData icon;
- final ValueNotifier<bool> clicked = ValueNotifier<bool>(false);
- @override
- State<MoreOperateButton> createState() => _MoreOperateButtonState();
- }
- class _MoreOperateButtonState extends State<MoreOperateButton> {
- bool _isHover = false;
- @override
- Widget build(BuildContext context) {
- Color bgColor = _isHover ? LabColors.base400 : Colors.transparent;
- return MouseRegion(
- cursor: SystemMouseCursors.click,
- onEnter: _handleMouseEnter,
- onExit: _handleMouseExit,
- child: GestureDetector(
- onTap: () {
- widget.clicked.value = !widget.clicked.value;
- widget.onClick?.call();
- },
- child: Container(
- padding: EdgeInsets.all(5),
- decoration: BoxDecoration(
- color: bgColor,
- borderRadius: BorderRadius.circular(5),
- ),
- child: Row(
- children: [
- Icon(
- widget.icon,
- size: 20,
- color: LabColors.base800,
- ),
- SizedBox(width: 10),
- Center(
- child: DefaultTextStyle(
- style: TextStyle(
- decoration: TextDecoration.none,
- color: LabColors.text700,
- fontFamily: FTheme.ins.localeSetting.fontFamily,
- ),
- child: Text(
- widget.name,
- ),
- ),
- ),
- ],
- ),
- ),
- ),
- );
- }
- void _handleMouseEnter(PointerEvent details) {
- setState(() {
- _isHover = true;
- });
- }
- void _handleMouseExit(PointerEvent details) {
- setState(() {
- _isHover = false;
- });
- }
- }
|