Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Reduce dependency on MenuItemWidget

AmanRajSinghMourya9783b5d7f9c1
diff --git a/mobile/apps/locker/lib/ui/components/expandable_menu_item_widget.dart b/mobile/apps/locker/lib/ui/components/expandable_menu_item_widget.dart
index 8314c560c9..45c06f17e1 100644
--- a/mobile/apps/locker/lib/ui/components/expandable_menu_item_widget.dart
+++ b/mobile/apps/locker/lib/ui/components/expandable_menu_item_widget.dart
@@ -1,14 +1,69 @@
-import "package:ente_ui/components/captioned_text_widget.dart";
-import "package:ente_ui/components/menu_item_widget.dart";
-import "package:ente_ui/theme/ente_theme_data.dart";
+import "package:ente_ui/theme/ente_theme.dart";
import "package:expandable/expandable.dart";
-import 'package:flutter/material.dart';
+import "package:flutter/material.dart";
+import "package:hugeicons/hugeicons.dart";
import "package:locker/ui/drawer/common_settings.dart";
+class ExpandableChildItem extends StatelessWidget {
+ final String title;
+ final Color? textColor;
+ final IconData? trailingIcon;
+ final Color? trailingIconColor;
+ final VoidCallback? onTap;
+ final VoidCallback? onLongPress;
+
+ const ExpandableChildItem({
+ required this.title,
+ this.textColor,
+ this.trailingIcon,
+ this.trailingIconColor,
+ this.onTap,
+ this.onLongPress,
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+
+ return GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: onTap,
+ onLongPress: onLongPress,
+ child: SizedBox(
+ height: 60,
+ child: Row(
+ children: [
+ const SizedBox(width: 60),
+ const SizedBox(width: 4),
+ Expanded(
+ child: Text(
+ title,
+ style: textTheme.body.copyWith(
+ color: textColor,
+ ),
+ ),
+ ),
+ if (trailingIcon != null)
+ Padding(
+ padding: const EdgeInsets.only(right: 12.0),
+ child: Icon(
+ trailingIcon,
+ color: trailingIconColor ?? colorScheme.textMuted,
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
+
class ExpandableMenuItemWidget extends StatefulWidget {
final String title;
final Widget selectionOptionsWidget;
- final IconData leadingIcon;
+ final dynamic leadingIcon;
const ExpandableMenuItemWidget({
required this.title,
required this.selectionOptionsWidget,
@@ -39,28 +94,64 @@ class _ExpandableMenuItemWidgetState extends State<ExpandableMenuItemWidget> {
@override
Widget build(BuildContext context) {
- final enteColorScheme = Theme.of(context).colorScheme.enteTheme.colorScheme;
+ final colorScheme = getEnteColorScheme(context);
+ final textTheme = getEnteTextTheme(context);
+ final isExpanded = expandableController.expanded;
return AnimatedContainer(
curve: Curves.ease,
duration: const Duration(milliseconds: 200),
decoration: BoxDecoration(
- color: enteColorScheme.backdropBase,
- borderRadius: BorderRadius.circular(12),
+ color: colorScheme.backdropBase,
+ borderRadius: BorderRadius.circular(20),
),
child: ExpandableNotifier(
controller: expandableController,
child: ScrollOnExpand(
child: ExpandablePanel(
- header: MenuItemWidget(
- captionedTextWidget: CaptionedTextWidget(
- title: widget.title,
+ header: GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () => expandableController.toggle(),
+ child: Row(
+ children: [
+ SizedBox(
+ height: 60,
+ width: 60,
+ child: Padding(
+ padding: const EdgeInsets.all(10.0),
+ child: Container(
+ decoration: BoxDecoration(
+ color: colorScheme.fillFaint,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ padding: const EdgeInsets.all(8.0),
+ child: HugeIcon(
+ icon: widget.leadingIcon,
+ color: colorScheme.strokeBase,
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(width: 4),
+ Expanded(
+ child: Text(
+ widget.title,
+ style: textTheme.body,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(right: 12.0),
+ child: AnimatedRotation(
+ turns: isExpanded ? -0.25 : 0,
+ duration: const Duration(milliseconds: 200),
+ child: Icon(
+ Icons.chevron_right,
+ color: colorScheme.textMuted,
+ ),
+ ),
+ ),
+ ],
),
- isExpandable: true,
- leadingIcon: widget.leadingIcon,
- menuItemColor: enteColorScheme.backdropBase,
- expandableController: expandableController,
- singleBorderRadius: 12,
),
collapsed: const SizedBox.shrink(),
expanded: widget.selectionOptionsWidget,