fix: auto size filter menu (#1552)

Co-authored-by: nathan <nathan@appflowy.io>
This commit is contained in:
Nathan.fooo
2022-12-09 10:12:45 +08:00
committed by GitHub
parent 53b7595de8
commit 12441f1183
3 changed files with 19 additions and 14 deletions

View File

@ -62,7 +62,7 @@ class GridCreateFilterBloc
final List<FieldInfo> allFields = List.from(fields);
final keyword = filterText.toLowerCase();
allFields.retainWhere((field) {
if (field.canCreateFilter) {
if (!field.canCreateFilter) {
return false;
}

View File

@ -54,21 +54,26 @@ class GridFilterMenu extends StatelessWidget {
}
Widget buildFilterItems(String viewId, GridFilterMenuState state) {
final List<Widget> children = state.filters
.map((filterInfo) => FilterMenuItem(filterInfo: filterInfo))
.toList();
final List<Widget> children = [];
children.addAll(
state.filters
.map((filterInfo) => FilterMenuItem(filterInfo: filterInfo))
.toList(),
);
if (state.creatableFields.isNotEmpty) {
children.add(AddFilterButton(viewId: viewId));
}
return Row(
children: [
SingleChildScrollView(
controller: ScrollController(),
scrollDirection: Axis.horizontal,
Expanded(
child: Wrap(
spacing: 4,
spacing: 6,
runSpacing: 4,
children: children,
),
),
const HSpace(4),
if (state.creatableFields.isNotEmpty) AddFilterButton(viewId: viewId),
],
);
}