Refactor JSON Previewer buttons

This commit is contained in:
Ankit Mahato
2025-04-06 03:08:35 +05:30
parent 78fe2462bd
commit fe6bdc9693

View File

@ -178,53 +178,25 @@ class _JsonPreviewerState extends State<JsonPreviewer> {
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: constraints.minWidth > kMinWindowSize.width children: [
? [ ADTextButton(
TextButton( icon: Icons.unfold_more,
onPressed: state.areAllExpanded() showLabel: constraints.minWidth > kMinWindowSize.width,
? null label: 'Expand All',
: state.expandAll, labelTextStyle: kTextStyleButtonSmall,
child: const Text( onPressed:
'Expand All', state.areAllExpanded() ? null : state.expandAll,
style: kTextStyleButtonSmall,
), ),
ADTextButton(
icon: Icons.unfold_less,
showLabel: constraints.minWidth > kMinWindowSize.width,
label: 'Collapse All',
labelTextStyle: kTextStyleButtonSmall,
onPressed:
state.areAllCollapsed() ? null : state.collapseAll,
), ),
TextButton( ],
onPressed: state.areAllCollapsed()
? null
: state.collapseAll,
child: const Text(
'Collapse All',
style: kTextStyleButtonSmall,
), ),
),
]
: [
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( Expanded(
child: JsonExplorer( child: JsonExplorer(
nodes: state.displayNodes, nodes: state.displayNodes,