Tooltip Buttons Updated

This commit is contained in:
Ankit Mahato
2023-04-26 02:53:35 +05:30
parent 1d884cd910
commit 1cbdf2dccc
2 changed files with 67 additions and 46 deletions

@ -61,6 +61,7 @@ const kTabAnimationDuration = Duration(milliseconds: 200);
const kTabHeight = 45.0;
const kHeaderHeight = 32.0;
const kSegmentHeight = 24.0;
const kTextButtonMinWidth = 36.0;
const kRandMax = 100000;

@ -5,9 +5,15 @@ import 'package:apidash/consts.dart';
import "snackbars.dart";
class CopyButton extends StatefulWidget {
const CopyButton({super.key, required this.toCopy});
const CopyButton({
super.key,
required this.toCopy,
this.showLabel = true,
});
final String toCopy;
final bool showLabel;
@override
State<CopyButton> createState() => _CopyButtonState();
}
@ -16,7 +22,11 @@ class _CopyButtonState extends State<CopyButton> {
@override
Widget build(BuildContext context) {
var sm = ScaffoldMessenger.of(context);
return TextButton(
return Tooltip(
message: widget.showLabel ? '' : kLabelCopy,
child: SizedBox(
width: widget.showLabel ? null : kTextButtonMinWidth,
child: TextButton(
onPressed: () async {
await Clipboard.setData(ClipboardData(text: widget.toCopy));
sm.hideCurrentSnackBar();
@ -24,14 +34,16 @@ class _CopyButtonState extends State<CopyButton> {
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: const [
Icon(
children: [
const Icon(
Icons.content_copy,
size: 20,
),
Text(kLabelCopy)
if (widget.showLabel) const Text(kLabelCopy)
],
),
),
),
);
}
}
@ -92,11 +104,13 @@ class SaveInDownloadsButton extends StatefulWidget {
this.content,
this.mimeType,
this.name,
this.showLabel = true,
});
final Uint8List? content;
final String? mimeType;
final String? name;
final bool showLabel;
@override
State<SaveInDownloadsButton> createState() => _SaveInDownloadsButtonState();
@ -106,7 +120,11 @@ class _SaveInDownloadsButtonState extends State<SaveInDownloadsButton> {
@override
Widget build(BuildContext context) {
var sm = ScaffoldMessenger.of(context);
return TextButton(
return Tooltip(
message: widget.showLabel ? '' : kLabelDownload,
child: SizedBox(
width: widget.showLabel ? null : kTextButtonMinWidth,
child: TextButton(
onPressed: (widget.content != null)
? () async {
var message = "";
@ -132,14 +150,16 @@ class _SaveInDownloadsButtonState extends State<SaveInDownloadsButton> {
: null,
child: Row(
mainAxisSize: MainAxisSize.min,
children: const [
Icon(
children: [
const Icon(
Icons.download,
size: 20,
),
Text(kLabelDownload)
if (widget.showLabel) const Text(kLabelDownload)
],
),
),
),
);
}
}