Sfoglia il codice sorgente

added option to align captionedText when leading icon is not present and the menu item is nested

ashilkn 2 anni fa
parent
commit
38a5256d88

+ 1 - 1
lib/ui/components/captioned_text_widget.dart

@@ -21,7 +21,7 @@ class CaptionedTextWidget extends StatelessWidget {
 
 
     return Flexible(
     return Flexible(
       child: Padding(
       child: Padding(
-        padding: const EdgeInsets.symmetric(vertical: 12),
+        padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 2),
         child: Row(
         child: Row(
           children: [
           children: [
             Flexible(
             Flexible(

+ 20 - 12
lib/ui/components/menu_item_widget.dart

@@ -11,6 +11,7 @@ class MenuItemWidget extends StatelessWidget {
   final bool trailingIconIsMuted;
   final bool trailingIconIsMuted;
   final Function? onTap;
   final Function? onTap;
   final Color? menuItemColor;
   final Color? menuItemColor;
+  final bool alignCaptionedTextToLeft;
   const MenuItemWidget({
   const MenuItemWidget({
     required this.captionedTextWidget,
     required this.captionedTextWidget,
     required this.isHeaderOfExpansion,
     required this.isHeaderOfExpansion,
@@ -21,6 +22,7 @@ class MenuItemWidget extends StatelessWidget {
     this.trailingIconIsMuted = false,
     this.trailingIconIsMuted = false,
     this.onTap,
     this.onTap,
     this.menuItemColor,
     this.menuItemColor,
+    this.alignCaptionedTextToLeft = false,
     Key? key,
     Key? key,
   }) : super(key: key);
   }) : super(key: key);
 
 
@@ -44,18 +46,24 @@ class MenuItemWidget extends StatelessWidget {
       child: Row(
       child: Row(
         mainAxisAlignment: MainAxisAlignment.spaceBetween,
         mainAxisAlignment: MainAxisAlignment.spaceBetween,
         children: [
         children: [
-          SizedBox(
-            height: 20,
-            width: 20,
-            child: FittedBox(
-              fit: BoxFit.contain,
-              child: Icon(
-                leadingIcon,
-                color: leadingIconColor,
-              ),
-            ),
-          ),
-          const SizedBox(width: 12),
+          alignCaptionedTextToLeft && leadingIcon == null
+              ? const SizedBox.shrink()
+              : Padding(
+                  padding: const EdgeInsets.only(right: 10),
+                  child: SizedBox(
+                    height: 20,
+                    width: 20,
+                    child: leadingIcon == null
+                        ? const SizedBox.shrink()
+                        : FittedBox(
+                            fit: BoxFit.contain,
+                            child: Icon(
+                              leadingIcon,
+                              color: leadingIconColor,
+                            ),
+                          ),
+                  ),
+                ),
           captionedTextWidget,
           captionedTextWidget,
           trailingIcon != null
           trailingIcon != null
               ? Icon(trailingIcon)
               ? Icon(trailingIcon)