|
@@ -3,15 +3,10 @@ import 'package:photos/ui/components/blur_menu_item_widget.dart';
|
|
import 'package:photos/ui/components/divider_widget.dart';
|
|
import 'package:photos/ui/components/divider_widget.dart';
|
|
|
|
|
|
class ExpandedMenuWidget extends StatelessWidget {
|
|
class ExpandedMenuWidget extends StatelessWidget {
|
|
- final List<BlurMenuItemWidget> items;
|
|
|
|
- final List<int> groupingOrder;
|
|
|
|
|
|
+ final List<List<BlurMenuItemWidget>> items;
|
|
|
|
+ // final List<int> groupingOrder;
|
|
const ExpandedMenuWidget({
|
|
const ExpandedMenuWidget({
|
|
required this.items,
|
|
required this.items,
|
|
-
|
|
|
|
- /// To specify the grouping of items. Eg: [2,2] for 2 sections with 2 items
|
|
|
|
- /// each, [4,1,2] for 3 sections with 4, 1 and 2 items respectively.
|
|
|
|
- /// Make sure sum of ints in this.groupingOrder is equal to length of this.items
|
|
|
|
- required this.groupingOrder,
|
|
|
|
super.key,
|
|
super.key,
|
|
});
|
|
});
|
|
|
|
|
|
@@ -20,21 +15,23 @@ class ExpandedMenuWidget extends StatelessWidget {
|
|
const double itemHeight = 48;
|
|
const double itemHeight = 48;
|
|
const double whiteSpaceBetweenSections = 16;
|
|
const double whiteSpaceBetweenSections = 16;
|
|
const double dividerHeightBetweenItems = 1;
|
|
const double dividerHeightBetweenItems = 1;
|
|
- int totalItemIndex = 0;
|
|
|
|
int numberOfDividers = 0;
|
|
int numberOfDividers = 0;
|
|
|
|
+ double combinedHeightOfItems = 0;
|
|
|
|
|
|
- for (int group in groupingOrder) {
|
|
|
|
|
|
+ for (List<BlurMenuItemWidget> group in items) {
|
|
//no divider if there is only one item in the section/group
|
|
//no divider if there is only one item in the section/group
|
|
- if (group != 1) {
|
|
|
|
- numberOfDividers += (group - 1);
|
|
|
|
|
|
+ if (group.length != 1) {
|
|
|
|
+ numberOfDividers += (group.length - 1);
|
|
}
|
|
}
|
|
|
|
+ combinedHeightOfItems += group.length * itemHeight;
|
|
}
|
|
}
|
|
|
|
+
|
|
return Padding(
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
|
child: SizedBox(
|
|
child: SizedBox(
|
|
- height: (itemHeight * items.length) +
|
|
|
|
|
|
+ height: combinedHeightOfItems +
|
|
(dividerHeightBetweenItems * numberOfDividers) +
|
|
(dividerHeightBetweenItems * numberOfDividers) +
|
|
- (whiteSpaceBetweenSections * (groupingOrder.length - 1)),
|
|
|
|
|
|
+ (whiteSpaceBetweenSections * (items.length - 1)),
|
|
child: ListView.separated(
|
|
child: ListView.separated(
|
|
padding: const EdgeInsets.all(0),
|
|
padding: const EdgeInsets.all(0),
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
@@ -42,21 +39,21 @@ class ExpandedMenuWidget extends StatelessWidget {
|
|
return ClipRRect(
|
|
return ClipRRect(
|
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
borderRadius: const BorderRadius.all(Radius.circular(8)),
|
|
child: SizedBox(
|
|
child: SizedBox(
|
|
- height: itemHeight * groupingOrder[sectionIndex] +
|
|
|
|
|
|
+ height: itemHeight * items[sectionIndex].length +
|
|
(dividerHeightBetweenItems *
|
|
(dividerHeightBetweenItems *
|
|
- (groupingOrder[sectionIndex] - 1)),
|
|
|
|
|
|
+ (items[sectionIndex].length - 1)),
|
|
child: ListView.separated(
|
|
child: ListView.separated(
|
|
padding: const EdgeInsets.all(0),
|
|
padding: const EdgeInsets.all(0),
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
- itemBuilder: (context, _) {
|
|
|
|
- return items[totalItemIndex++];
|
|
|
|
|
|
+ itemBuilder: (context, itemIndex) {
|
|
|
|
+ return items[sectionIndex][itemIndex];
|
|
},
|
|
},
|
|
separatorBuilder: (context, index) {
|
|
separatorBuilder: (context, index) {
|
|
return const DividerWidget(
|
|
return const DividerWidget(
|
|
dividerType: DividerType.bottomBar,
|
|
dividerType: DividerType.bottomBar,
|
|
);
|
|
);
|
|
},
|
|
},
|
|
- itemCount: groupingOrder[sectionIndex],
|
|
|
|
|
|
+ itemCount: items[sectionIndex].length,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
);
|
|
@@ -64,7 +61,7 @@ class ExpandedMenuWidget extends StatelessWidget {
|
|
separatorBuilder: (context, index) {
|
|
separatorBuilder: (context, index) {
|
|
return const SizedBox(height: whiteSpaceBetweenSections);
|
|
return const SizedBox(height: whiteSpaceBetweenSections);
|
|
},
|
|
},
|
|
- itemCount: groupingOrder.length,
|
|
|
|
|
|
+ itemCount: items.length,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
);
|