| 1 | import 'package:cake_wallet/new-ui/widgets/dropdown_row.dart'; |
| 2 | import 'package:flutter/material.dart'; |
| 3 | |
| 4 | class AnimatedDropdown extends StatefulWidget { |
| 5 | const AnimatedDropdown({super.key, required this.content, required this.dropdownText}); |
| 6 | |
| 7 | final Widget content; |
| 8 | final String dropdownText; |
| 9 | |
| 10 | @override |
| 11 | State<AnimatedDropdown> createState() => _AnimatedDropdownState(); |
| 12 | } |
| 13 | |
| 14 | class _AnimatedDropdownState extends State<AnimatedDropdown> { |
| 15 | bool _expanded = false; |
| 16 | |
| 17 | @override |
| 18 | Widget build(BuildContext context) { |
| 19 | return ClipRSuperellipse( |
| 20 | borderRadius: BorderRadius.circular(20), |
| 21 | child: Container( |
| 22 | decoration: ShapeDecoration( |
| 23 | shape: RoundedSuperellipseBorder( |
| 24 | borderRadius: BorderRadius.circular(20), |
| 25 | ), |
| 26 | color: Theme.of(context).colorScheme.surfaceContainer, |
| 27 | ), |
| 28 | child: Column( |
| 29 | children: [ |
| 30 | DropdownRow( |
| 31 | expanded: _expanded, |
| 32 | text: widget.dropdownText, |
| 33 | onTap: () { |
| 34 | setState(() { |
| 35 | _expanded = !_expanded; |
| 36 | }); |
| 37 | }, |
| 38 | ), |
| 39 | AnimatedOpacity( |
| 40 | duration: Duration(milliseconds: 150), |
| 41 | opacity: _expanded ? 1 : 0, |
| 42 | child: Divider( |
| 43 | height: 1, |
| 44 | thickness: 1, |
| 45 | )), |
| 46 | AnimatedCrossFade( |
| 47 | firstChild: Container(height: 0), |
| 48 | secondChild: widget.content, |
| 49 | crossFadeState: _expanded ? CrossFadeState.showSecond : CrossFadeState.showFirst, |
| 50 | duration: const Duration(milliseconds: 300), |
| 51 | sizeCurve: Curves.easeOutCubic, |
| 52 | ) |
| 53 | ], |
| 54 | ), |
| 55 | ), |
| 56 | ); |
| 57 | } |
| 58 | } |