Skip to content

Commit 31baebf

Browse files
handle sorting view
1 parent 1758dd3 commit 31baebf

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

lib/features/sorting/base/view/sorting_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class ShowUpSortingList extends ConsumerWidget {
105105
return Padding(
106106
padding: const EdgeInsets.only(top: 5),
107107
child: RSizedBox(
108-
height: selectedAlgorithmLength == 1 ? maxHeight*1.01 : null,
108+
height: selectedAlgorithmLength == 1 ? maxHeight * 1.01 : null,
109109
width: double.infinity,
110110
child: Stack(
111111
alignment: AlignmentDirectional.bottomCenter,
@@ -161,7 +161,7 @@ class _BuildItem extends ConsumerWidget {
161161
padding: EdgeInsets.symmetric(horizontal: SortingNotifier.itemsPadding / 2),
162162
child: AnimatedContainer(
163163
duration: speedDuration,
164-
height: SortingNotifier.calculateItemHeight(context, item.value, size) / selectedAlgorithmLength,
164+
height: SortingNotifier.calculateItemHeight(context, item.value, size, selectedAlgorithmLength),
165165
width: itemWidth,
166166
decoration: BoxDecoration(
167167
color: context.getColor(currentItem?.getColor ?? SortingNotifier.itemColor),

lib/features/sorting/base/view_model/sorting_notifier.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,23 @@ abstract class SortingNotifier extends StateNotifier<SortingNotifierState> {
5151
return screenHeight > 0 ? screenHeight : 1.0;
5252
}
5353

54-
static double calculateItemHeight(BuildContext context, int itemIndex, int size) {
54+
static double calculateItemHeight(
55+
BuildContext context,
56+
int itemIndex,
57+
int size,
58+
int selectedAlgorithmsLength,
59+
) {
5560
final value = (calculateMaxListItemHeight(context) / size) * (itemIndex + 1);
56-
return value.h;
61+
final perc = selectedAlgorithmsLength == 1
62+
? 1
63+
: selectedAlgorithmsLength <= 3
64+
? 0.9
65+
: selectedAlgorithmsLength <= 6
66+
? 0.8
67+
: selectedAlgorithmsLength <= 9
68+
? 0.7
69+
: 0.6;
70+
return value.h / selectedAlgorithmsLength * perc;
5771
}
5872

5973
Duration get speedDuration => state.swipeDuration;

0 commit comments

Comments
 (0)