Skip to content

Commit 12441f1

Browse files
authored
fix: auto size filter menu (#1552)
Co-authored-by: nathan <[email protected]>
1 parent 53b7595 commit 12441f1

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

frontend/app_flowy/lib/plugins/grid/application/filter/filter_create_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class GridCreateFilterBloc
6262
final List<FieldInfo> allFields = List.from(fields);
6363
final keyword = filterText.toLowerCase();
6464
allFields.retainWhere((field) {
65-
if (field.canCreateFilter) {
65+
if (!field.canCreateFilter) {
6666
return false;
6767
}
6868

frontend/app_flowy/lib/plugins/grid/presentation/widgets/filter/menu.dart

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,26 @@ class GridFilterMenu extends StatelessWidget {
5454
}
5555

5656
Widget buildFilterItems(String viewId, GridFilterMenuState state) {
57-
final List<Widget> children = state.filters
58-
.map((filterInfo) => FilterMenuItem(filterInfo: filterInfo))
59-
.toList();
57+
final List<Widget> children = [];
58+
children.addAll(
59+
state.filters
60+
.map((filterInfo) => FilterMenuItem(filterInfo: filterInfo))
61+
.toList(),
62+
);
63+
64+
if (state.creatableFields.isNotEmpty) {
65+
children.add(AddFilterButton(viewId: viewId));
66+
}
67+
6068
return Row(
6169
children: [
62-
SingleChildScrollView(
63-
controller: ScrollController(),
64-
scrollDirection: Axis.horizontal,
70+
Expanded(
6571
child: Wrap(
66-
spacing: 4,
72+
spacing: 6,
73+
runSpacing: 4,
6774
children: children,
6875
),
6976
),
70-
const HSpace(4),
71-
if (state.creatableFields.isNotEmpty) AddFilterButton(viewId: viewId),
7277
],
7378
);
7479
}

frontend/app_flowy/packages/flowy_infra_ui/lib/style_widget/button.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FlowyButton extends StatelessWidget {
2424
required this.text,
2525
this.onTap,
2626
this.onHover,
27-
this.margin = const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
27+
this.margin = const EdgeInsets.symmetric(horizontal: 10, vertical: 2),
2828
this.leftIcon,
2929
this.rightIcon,
3030
this.hoverColor,
@@ -63,9 +63,9 @@ class FlowyButton extends StatelessWidget {
6363
children.add(Expanded(child: text));
6464

6565
if (rightIcon != null) {
66-
children.add(const HSpace(6));
67-
children.add(
68-
SizedBox.fromSize(size: const Size.square(16), child: rightIcon!));
66+
children.add(const HSpace(10));
67+
// No need to define the size of rightIcon. Just use its intrinsic width
68+
children.add(rightIcon!);
6969
}
7070

7171
Widget child = Row(

0 commit comments

Comments
 (0)