12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- import 'package:expandable/expandable.dart';
- import 'package:flutter/material.dart';
- import 'package:photos/ui/components/bottom_action_bar/action_bar_widget.dart';
- import 'package:photos/ui/components/icon_button_widget.dart';
- import 'package:photos/ui/settings/common_settings.dart';
- class BottomActionBarWidget extends StatefulWidget {
- final Widget? textWidget;
- final List<Widget>? iconButtons;
- final Widget expandedMenu;
- const BottomActionBarWidget({
- required this.expandedMenu,
- this.textWidget,
- this.iconButtons,
- super.key,
- });
- @override
- State<BottomActionBarWidget> createState() => _BottomActionBarWidgetState();
- }
- class _BottomActionBarWidgetState extends State<BottomActionBarWidget> {
- final ExpandableController _expandableController =
- ExpandableController(initialExpanded: false);
- @override
- Widget build(BuildContext context) {
- //todo : restric width of column
- return Container(
- padding: const EdgeInsets.only(top: 4, bottom: 36),
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- ExpandableNotifier(
- controller: _expandableController,
- child: ExpandablePanel(
- theme: getExpandableTheme(context),
- header: Padding(
- padding: EdgeInsets.symmetric(
- horizontal: widget.textWidget == null ? 12 : 0,
- ),
- child: ActionBarWidget(
- textWidget: widget.textWidget,
- iconButtons: _iconButtons(),
- ),
- ),
- expanded: widget.expandedMenu,
- collapsed: const SizedBox.shrink(),
- controller: _expandableController,
- ),
- ),
- ],
- ),
- );
- }
- List<Widget> _iconButtons() {
- final isExpanded = _expandableController.expanded;
- final iconButtons = <Widget?>[
- ...?widget.iconButtons,
- AnimatedSwitcher(
- duration: const Duration(milliseconds: 200),
- switchInCurve: Curves.easeInOutExpo,
- child: isExpanded
- ? IconButtonWidget(
- key: ValueKey<bool>(isExpanded),
- onTap: () {
- _expandableController.value = false;
- setState(() {});
- },
- icon: Icons.expand_more_outlined,
- iconButtonType: IconButtonType.primary,
- )
- : IconButtonWidget(
- key: ValueKey<bool>(isExpanded),
- onTap: () {
- _expandableController.value = true;
- setState(() {});
- },
- icon: Icons.more_horiz_outlined,
- iconButtonType: IconButtonType.primary,
- ),
- ),
- ];
- iconButtons.removeWhere((element) => element == null);
- return iconButtons as List<Widget>;
- }
- }
|