-
-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathaccordion.dart
More file actions
102 lines (97 loc) · 3.06 KB
/
accordion.dart
File metadata and controls
102 lines (97 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import 'package:example/common/base_scaffold.dart';
import 'package:example/common/properties/bool_property.dart';
import 'package:example/common/properties/enum_property.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
final details = [
(
title: 'Is it acceptable?',
content: 'Yes. It adheres to the WAI-ARIA design pattern.',
),
(
title: 'Is it styled?',
content:
"Yes. It comes with default styles that matches the other components' aesthetic.",
),
(
title: 'Is it animated?',
content:
"Yes. It's animated by default, but you can disable it if you prefer.",
),
(
title: 'Focus ring test (Issue #582)',
content: 'input_field', // Special marker to render input field
),
];
class AccordionPage extends StatefulWidget {
const AccordionPage({super.key});
@override
State<AccordionPage> createState() => _AccordionPageState();
}
class _AccordionPageState extends State<AccordionPage> {
var type = ShadAccordionVariant.single;
var underlineTitle = true;
var clipContent = false; // false = Clip.none (fixed), true = Clip.hardEdge (old bug)
@override
Widget build(BuildContext context) {
final children = details.map(
(detail) {
return ShadAccordionItem(
value: detail,
title: Text(detail.title),
underlineTitleOnHover: underlineTitle,
clipBehavior: clipContent ? Clip.hardEdge : Clip.none,
child: detail.content == 'input_field'
? const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Focus the input below to test that the focus ring '
'is not clipped:'),
SizedBox(height: 8),
ShadInput(placeholder: Text('Focus me')),
],
)
: Text(detail.content),
);
},
);
return BaseScaffold(
appBarTitle: 'Accordion',
editable: [
MyEnumProperty(
label: 'Type',
value: type,
values: ShadAccordionVariant.values,
onChanged: (value) {
if (value != null) {
setState(() => type = value);
}
},
),
MyBoolProperty(
label: 'Underline title',
value: underlineTitle,
onChanged: (v) => setState(() => underlineTitle = v),
),
MyBoolProperty(
label: 'Clip content (old bug)',
value: clipContent,
onChanged: (v) => setState(() => clipContent = v),
),
],
children: [
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 600),
child: type == ShadAccordionVariant.single
? ShadAccordion<({String content, String title})>(
children: children,
)
: ShadAccordion<({String content, String title})>.multiple(
children: children,
),
),
],
);
}
}