mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
42 lines
898 B
Dart
42 lines
898 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ComBtn extends StatelessWidget {
|
|
final Widget icon;
|
|
final VoidCallback? onTap;
|
|
final VoidCallback? onLongPress;
|
|
final VoidCallback? onSecondaryTap;
|
|
final double width;
|
|
final double height;
|
|
final String? tooltip;
|
|
|
|
const ComBtn({
|
|
super.key,
|
|
required this.icon,
|
|
this.onTap,
|
|
this.onLongPress,
|
|
this.onSecondaryTap,
|
|
this.width = 34,
|
|
this.height = 34,
|
|
this.tooltip,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final child = SizedBox(
|
|
width: width,
|
|
height: height,
|
|
child: GestureDetector(
|
|
onTap: onTap,
|
|
onLongPress: onLongPress,
|
|
onSecondaryTap: onSecondaryTap,
|
|
behavior: HitTestBehavior.opaque,
|
|
child: icon,
|
|
),
|
|
);
|
|
if (tooltip != null) {
|
|
return Tooltip(message: tooltip, child: child);
|
|
}
|
|
return child;
|
|
}
|
|
}
|