fix: render overflow errors

This commit is contained in:
DenserMeerkat
2024-07-04 16:10:51 +05:30
parent 063638b8ef
commit 8ee7bc843b
4 changed files with 136 additions and 91 deletions

View File

@ -16,28 +16,29 @@ class CopyButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
var sm = ScaffoldMessenger.of(context);
return Tooltip(
message: showLabel ? '' : kLabelCopy,
child: SizedBox(
width: showLabel ? null : kTextButtonMinWidth,
child: TextButton(
onPressed: () async {
const icon = Icon(
Icons.content_copy,
size: 18,
);
const label = kLabelCopy;
onPressed() async {
await Clipboard.setData(ClipboardData(text: toCopy));
sm.hideCurrentSnackBar();
sm.showSnackBar(getSnackBar("Copied"));
},
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.content_copy,
size: 20,
),
if (showLabel) const Text(kLabelCopy)
],
),
),
),
}
return showLabel
? TextButton.icon(
onPressed: onPressed,
icon: icon,
label: const Text(label),
)
: IconButton(
tooltip: label,
color: Theme.of(context).colorScheme.primary,
visualDensity: VisualDensity.compact,
onPressed: onPressed,
icon: icon,
);
}
}

View File

@ -23,12 +23,12 @@ class SaveInDownloadsButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
var sm = ScaffoldMessenger.of(context);
return Tooltip(
message: showLabel ? '' : kLabelDownload,
child: SizedBox(
width: showLabel ? null : kTextButtonMinWidth,
child: TextButton(
onPressed: (content != null)
const icon = Icon(
Icons.download,
size: 18,
);
const label = kLabelDownload;
final onPressed = (content != null)
? () async {
var message = "";
var path = await getFileDownloadpath(
@ -49,19 +49,20 @@ class SaveInDownloadsButton extends StatelessWidget {
sm.hideCurrentSnackBar();
sm.showSnackBar(getSnackBar(message, small: false));
}
: null,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(
Icons.download,
size: 20,
),
if (showLabel) const Text(kLabelDownload)
],
),
),
),
: null;
return showLabel
? TextButton.icon(
onPressed: onPressed,
icon: icon,
label: const Text(label),
)
: IconButton(
tooltip: label,
color: Theme.of(context).colorScheme.primary,
visualDensity: VisualDensity.compact,
onPressed: onPressed,
icon: icon,
);
}
}

View File

@ -177,10 +177,12 @@ class _JsonPreviewerState extends State<JsonPreviewer> {
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
children: constraints.minWidth > kMinWindowSize.width
? [
TextButton(
onPressed: () async {
await _copy(kEncoder.convert(widget.code), sm);
await _copy(
kEncoder.convert(widget.code), sm);
},
child: const Text(
'Copy',
@ -188,23 +190,63 @@ class _JsonPreviewerState extends State<JsonPreviewer> {
),
),
TextButton(
onPressed:
state.areAllExpanded() ? null : state.expandAll,
onPressed: state.areAllExpanded()
? null
: state.expandAll,
child: const Text(
'Expand All',
style: kTextStyleButtonSmall,
),
),
TextButton(
onPressed:
state.areAllCollapsed() ? null : state.collapseAll,
onPressed: state.areAllCollapsed()
? null
: state.collapseAll,
child: const Text(
'Collapse All',
style: kTextStyleButtonSmall,
),
),
],
]
: [
IconButton(
tooltip: "Copy",
color: Theme.of(context).colorScheme.primary,
visualDensity: VisualDensity.compact,
onPressed: () async {
await _copy(
kEncoder.convert(widget.code), sm);
},
icon: const Icon(
Icons.copy,
size: 16,
),
),
IconButton(
tooltip: "Expand All",
color: Theme.of(context).colorScheme.primary,
visualDensity: VisualDensity.compact,
onPressed: state.areAllExpanded()
? null
: state.expandAll,
icon: const Icon(
Icons.unfold_more,
size: 16,
),
),
IconButton(
tooltip: "Collapse All",
color: Theme.of(context).colorScheme.primary,
visualDensity: VisualDensity.compact,
onPressed: state.areAllCollapsed()
? null
: state.collapseAll,
icon: const Icon(
Icons.unfold_less,
size: 16,
),
),
]),
Expanded(
child: JsonDataExplorer(
nodes: state.displayNodes,

View File

@ -425,6 +425,7 @@ class _BodySuccessState extends State<BodySuccess> {
(widget.options == kRawBodyViewOptions)
? const SizedBox()
: SegmentedButton<ResponseBodyView>(
showSelectedIcon: showLabel,
style: const ButtonStyle(
padding: WidgetStatePropertyAll(
EdgeInsets.symmetric(
@ -438,7 +439,7 @@ class _BodySuccessState extends State<BodySuccess> {
(e) => ButtonSegment<ResponseBodyView>(
value: e,
label: Text(e.label),
icon: Icon(e.icon),
icon: showLabel ? Icon(e.icon) : null,
),
)
.toList(),