Skip to content

Commit ced99e6

Browse files
committed
feat: refactor UI components using SectionTitle and SectionContent, simplify layouts with ResponsiveControlPanel and Grid2Cols, and improve code readability
1 parent 36274a5 commit ced99e6

20 files changed

+2965
-2891
lines changed

packages/demo/lib/examples/alignment.dart

Lines changed: 86 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -223,99 +223,108 @@ class _AlignmentExampleState extends State<AlignmentExample> {
223223
children: [
224224
// Add Node section
225225
const SectionTitle('Add Node'),
226-
const SizedBox(height: 8),
227-
ControlButton(
228-
label: 'Add Random Node',
229-
icon: Icons.add_circle_outline,
230-
onPressed: _addRandomNode,
226+
SectionContent(
227+
child: ControlButton(
228+
label: 'Add Random Node',
229+
icon: Icons.add_circle_outline,
230+
onPressed: _addRandomNode,
231+
),
231232
),
232-
const SizedBox(height: 24),
233233

234234
// Alignment section
235235
const SectionTitle('Align'),
236-
const SizedBox(height: 8),
237-
ControlButton(
238-
label: 'Align Left',
239-
icon: Icons.align_horizontal_left,
240-
onPressed: _alignLeft,
241-
),
242-
const SizedBox(height: 8),
243-
ControlButton(
244-
label: 'Align Right',
245-
icon: Icons.align_horizontal_right,
246-
onPressed: _alignRight,
247-
),
248-
const SizedBox(height: 8),
249-
ControlButton(
250-
label: 'Align Top',
251-
icon: Icons.align_vertical_top,
252-
onPressed: _alignTop,
253-
),
254-
const SizedBox(height: 8),
255-
ControlButton(
256-
label: 'Align Bottom',
257-
icon: Icons.align_vertical_bottom,
258-
onPressed: _alignBottom,
259-
),
260-
const SizedBox(height: 8),
261-
ControlButton(
262-
label: 'Center Horizontal',
263-
icon: Icons.align_horizontal_center,
264-
onPressed: _alignCenterHorizontal,
265-
),
266-
const SizedBox(height: 8),
267-
ControlButton(
268-
label: 'Center Vertical',
269-
icon: Icons.align_vertical_center,
270-
onPressed: _alignMiddleVertical,
236+
SectionContent(
237+
child: Grid2Cols(
238+
buttons: [
239+
GridButton(
240+
label: 'Left',
241+
icon: Icons.align_horizontal_left,
242+
onPressed: _alignLeft,
243+
),
244+
GridButton(
245+
label: 'Right',
246+
icon: Icons.align_horizontal_right,
247+
onPressed: _alignRight,
248+
),
249+
GridButton(
250+
label: 'Top',
251+
icon: Icons.align_vertical_top,
252+
onPressed: _alignTop,
253+
),
254+
GridButton(
255+
label: 'Bottom',
256+
icon: Icons.align_vertical_bottom,
257+
onPressed: _alignBottom,
258+
),
259+
GridButton(
260+
label: 'Center H',
261+
icon: Icons.align_horizontal_center,
262+
onPressed: _alignCenterHorizontal,
263+
),
264+
GridButton(
265+
label: 'Center V',
266+
icon: Icons.align_vertical_center,
267+
onPressed: _alignMiddleVertical,
268+
),
269+
],
270+
),
271271
),
272-
const SizedBox(height: 24),
273272

274273
// Distribution section
275274
const SectionTitle('Distribute'),
276-
const SizedBox(height: 8),
277-
ControlButton(
278-
label: 'Distribute Horizontal',
279-
icon: Icons.horizontal_distribute,
280-
onPressed: _distributeHorizontally,
281-
),
282-
const SizedBox(height: 8),
283-
ControlButton(
284-
label: 'Distribute Vertical',
285-
icon: Icons.vertical_distribute,
286-
onPressed: _distributeVertically,
275+
SectionContent(
276+
child: Grid2Cols(
277+
buttons: [
278+
GridButton(
279+
label: 'Horizontal',
280+
icon: Icons.horizontal_distribute,
281+
onPressed: _distributeHorizontally,
282+
),
283+
GridButton(
284+
label: 'Vertical',
285+
icon: Icons.vertical_distribute,
286+
onPressed: _distributeVertically,
287+
),
288+
],
289+
),
287290
),
288-
const SizedBox(height: 24),
289291

290292
// Layout section
291293
const SectionTitle('Layout'),
292-
const SizedBox(height: 8),
293-
ControlButton(
294-
label: 'Grid Layout',
295-
icon: Icons.grid_4x4,
296-
onPressed: _gridLayout,
297-
),
298-
const SizedBox(height: 8),
299-
ControlButton(
300-
label: 'Hierarchical',
301-
icon: Icons.account_tree,
302-
onPressed: _hierarchicalLayout,
294+
SectionContent(
295+
child: Grid2Cols(
296+
buttons: [
297+
GridButton(
298+
label: 'Grid',
299+
icon: Icons.grid_4x4,
300+
onPressed: _gridLayout,
301+
),
302+
GridButton(
303+
label: 'Hierarchy',
304+
icon: Icons.account_tree,
305+
onPressed: _hierarchicalLayout,
306+
),
307+
],
308+
),
303309
),
304-
const SizedBox(height: 24),
305310

306311
// Layering section
307312
const SectionTitle('Layering'),
308-
const SizedBox(height: 8),
309-
ControlButton(
310-
label: 'Bring to Front',
311-
icon: Icons.flip_to_front,
312-
onPressed: _bringToFront,
313-
),
314-
const SizedBox(height: 8),
315-
ControlButton(
316-
label: 'Send to Back',
317-
icon: Icons.flip_to_back,
318-
onPressed: _sendToBack,
313+
SectionContent(
314+
child: Grid2Cols(
315+
buttons: [
316+
GridButton(
317+
label: 'To Front',
318+
icon: Icons.flip_to_front,
319+
onPressed: _bringToFront,
320+
),
321+
GridButton(
322+
label: 'To Back',
323+
icon: Icons.flip_to_back,
324+
onPressed: _sendToBack,
325+
),
326+
],
327+
),
319328
),
320329
],
321330
);

0 commit comments

Comments
 (0)