Merge pull request #983 from AppFlowy-IO/feat/disable_unsupport_group_field

chore: disable group field that does not support grouping
This commit is contained in:
Nathan.fooo 2022-09-05 20:26:46 +08:00 committed by GitHub
commit c97cb7c194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 2 deletions

View File

@ -290,5 +290,26 @@ class GridFieldContext {
bool get isGroupField => _isGroupField; bool get isGroupField => _isGroupField;
bool get canGroup {
switch (_field.fieldType) {
case FieldType.Checkbox:
return true;
case FieldType.DateTime:
return false;
case FieldType.MultiSelect:
return true;
case FieldType.Number:
return false;
case FieldType.RichText:
return false;
case FieldType.SingleSelect:
return true;
case FieldType.URL:
return false;
}
return false;
}
GridFieldContext({required FieldPB field}) : _field = field; GridFieldContext({required FieldPB field}) : _field = field;
} }

View File

@ -31,10 +31,15 @@ class GridGroupList extends StatelessWidget {
child: BlocBuilder<GridGroupBloc, GridGroupState>( child: BlocBuilder<GridGroupBloc, GridGroupState>(
builder: (context, state) { builder: (context, state) {
final cells = state.fieldContexts.map((fieldContext) { final cells = state.fieldContexts.map((fieldContext) {
return _GridGroupCell( Widget cell = _GridGroupCell(
fieldContext: fieldContext, fieldContext: fieldContext,
key: ValueKey(fieldContext.id), key: ValueKey(fieldContext.id),
); );
if (!fieldContext.canGroup) {
cell = IgnorePointer(child: Opacity(opacity: 0.3, child: cell));
}
return cell;
}).toList(); }).toList();
return ListView.separated( return ListView.separated(

View File

@ -35,7 +35,7 @@ packages:
path: "packages/appflowy_editor" path: "packages/appflowy_editor"
relative: true relative: true
source: path source: path
version: "0.0.3" version: "0.0.4"
args: args:
dependency: transitive dependency: transitive
description: description: