mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Add ADIconButton
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
|
||||
@ -11,13 +12,10 @@ class ClearResponseButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
tooltip: kTooltipClearResponse,
|
||||
return ADIconButton(
|
||||
icon: Icons.delete,
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(
|
||||
Icons.delete,
|
||||
size: 16,
|
||||
),
|
||||
tooltip: kTooltipClearResponse,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import 'package:apidash_design_system/apidash_design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:apidash/consts.dart';
|
||||
@ -20,7 +21,6 @@ class CopyButton extends StatelessWidget {
|
||||
Icons.content_copy,
|
||||
size: 18,
|
||||
);
|
||||
const label = kLabelCopy;
|
||||
onPressed() async {
|
||||
await Clipboard.setData(ClipboardData(text: toCopy));
|
||||
sm.hideCurrentSnackBar();
|
||||
@ -31,14 +31,15 @@ class CopyButton extends StatelessWidget {
|
||||
? TextButton.icon(
|
||||
onPressed: onPressed,
|
||||
icon: icon,
|
||||
label: const Text(label),
|
||||
label: const Text(kLabelCopy),
|
||||
)
|
||||
: IconButton(
|
||||
tooltip: label,
|
||||
: ADIconButton(
|
||||
icon: Icons.content_copy,
|
||||
iconSize: 18,
|
||||
tooltip: kLabelCopy,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: onPressed,
|
||||
icon: icon,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
34
packages/apidash_design_system/lib/widgets/button_icon.dart
Normal file
34
packages/apidash_design_system/lib/widgets/button_icon.dart
Normal file
@ -0,0 +1,34 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ADIconButton extends StatelessWidget {
|
||||
const ADIconButton({
|
||||
super.key,
|
||||
required this.icon,
|
||||
this.iconSize,
|
||||
this.onPressed,
|
||||
this.color,
|
||||
this.visualDensity,
|
||||
this.tooltip,
|
||||
});
|
||||
|
||||
final IconData icon;
|
||||
final double? iconSize;
|
||||
final VoidCallback? onPressed;
|
||||
final Color? color;
|
||||
final VisualDensity? visualDensity;
|
||||
final String? tooltip;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return IconButton(
|
||||
tooltip: tooltip,
|
||||
icon: Icon(
|
||||
icon,
|
||||
size: iconSize ?? 16,
|
||||
),
|
||||
color: color,
|
||||
visualDensity: visualDensity,
|
||||
onPressed: onPressed,
|
||||
);
|
||||
}
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
export 'button_icon.dart';
|
||||
export 'dropdown.dart';
|
||||
export 'textfield_outlined.dart';
|
||||
|
Reference in New Issue
Block a user