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

@ -177,54 +177,26 @@ class _JsonPreviewerState extends State<JsonPreviewer> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
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,
TextButton( showLabel: constraints.minWidth > kMinWindowSize.width,
onPressed: state.areAllCollapsed() label: 'Collapse All',
? null labelTextStyle: kTextStyleButtonSmall,
: state.collapseAll, onPressed:
child: const Text( state.areAllCollapsed() ? null : state.collapseAll,
'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,