fix: Label list not updated

This commit is contained in:
Anton Stubenbord
2023-05-29 18:12:22 +02:00
parent 5e9843f27f
commit 217de49fd4

View File

@@ -108,14 +108,16 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
), ),
), ),
], ],
body: NotificationListener<ScrollNotification>( body: BlocBuilder<LabelCubit, LabelState>(
builder: (context, state) {
return NotificationListener<ScrollNotification>(
onNotification: (notification) { onNotification: (notification) {
final metrics = notification.metrics; final metrics = notification.metrics;
if (metrics.maxScrollExtent == 0) { if (metrics.maxScrollExtent == 0) {
return true; return true;
} }
final desiredTab = final desiredTab = ((metrics.pixels / metrics.maxScrollExtent) *
((metrics.pixels / metrics.maxScrollExtent) * (_tabController.length - 1)) (_tabController.length - 1))
.round(); .round();
if (metrics.axis == Axis.horizontal && _currentIndex != desiredTab) { if (metrics.axis == Axis.horizontal && _currentIndex != desiredTab) {
@@ -143,16 +145,18 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
SliverOverlapInjector(handle: searchBarHandle), SliverOverlapInjector(handle: searchBarHandle),
SliverOverlapInjector(handle: tabBarHandle), SliverOverlapInjector(handle: tabBarHandle),
LabelTabView<Correspondent>( LabelTabView<Correspondent>(
labels: context.watch<LabelCubit>().state.correspondents, labels: state.correspondents,
filterBuilder: (label) => DocumentFilter( filterBuilder: (label) => DocumentFilter(
correspondent: IdQueryParameter.fromId(label.id!), correspondent: IdQueryParameter.fromId(label.id!),
), ),
canEdit: LocalUserAccount.current.paperlessUser.hasPermission( canEdit: LocalUserAccount.current.paperlessUser.hasPermission(
PermissionAction.change, PermissionTarget.correspondent), PermissionAction.change, PermissionTarget.correspondent),
canAddNew: LocalUserAccount.current.paperlessUser.hasPermission( canAddNew: LocalUserAccount.current.paperlessUser
.hasPermission(
PermissionAction.add, PermissionTarget.correspondent), PermissionAction.add, PermissionTarget.correspondent),
onEdit: _openEditCorrespondentPage, onEdit: _openEditCorrespondentPage,
emptyStateActionButtonLabel: S.of(context)!.addNewCorrespondent, emptyStateActionButtonLabel:
S.of(context)!.addNewCorrespondent,
emptyStateDescription: S.of(context)!.noCorrespondentsSetUp, emptyStateDescription: S.of(context)!.noCorrespondentsSetUp,
onAddNew: _openAddCorrespondentPage, onAddNew: _openAddCorrespondentPage,
), ),
@@ -167,16 +171,18 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
SliverOverlapInjector(handle: searchBarHandle), SliverOverlapInjector(handle: searchBarHandle),
SliverOverlapInjector(handle: tabBarHandle), SliverOverlapInjector(handle: tabBarHandle),
LabelTabView<DocumentType>( LabelTabView<DocumentType>(
labels: context.watch<LabelCubit>().state.documentTypes, labels: state.documentTypes,
filterBuilder: (label) => DocumentFilter( filterBuilder: (label) => DocumentFilter(
documentType: IdQueryParameter.fromId(label.id!), documentType: IdQueryParameter.fromId(label.id!),
), ),
canEdit: LocalUserAccount.current.paperlessUser.hasPermission( canEdit: LocalUserAccount.current.paperlessUser.hasPermission(
PermissionAction.change, PermissionTarget.documentType), PermissionAction.change, PermissionTarget.documentType),
canAddNew: LocalUserAccount.current.paperlessUser.hasPermission( canAddNew: LocalUserAccount.current.paperlessUser
.hasPermission(
PermissionAction.add, PermissionTarget.documentType), PermissionAction.add, PermissionTarget.documentType),
onEdit: _openEditDocumentTypePage, onEdit: _openEditDocumentTypePage,
emptyStateActionButtonLabel: S.of(context)!.addNewDocumentType, emptyStateActionButtonLabel:
S.of(context)!.addNewDocumentType,
emptyStateDescription: S.of(context)!.noDocumentTypesSetUp, emptyStateDescription: S.of(context)!.noDocumentTypesSetUp,
onAddNew: _openAddDocumentTypePage, onAddNew: _openAddDocumentTypePage,
), ),
@@ -191,14 +197,15 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
SliverOverlapInjector(handle: searchBarHandle), SliverOverlapInjector(handle: searchBarHandle),
SliverOverlapInjector(handle: tabBarHandle), SliverOverlapInjector(handle: tabBarHandle),
LabelTabView<Tag>( LabelTabView<Tag>(
labels: context.watch<LabelCubit>().state.tags, labels: state.tags,
filterBuilder: (label) => DocumentFilter( filterBuilder: (label) => DocumentFilter(
tags: TagsQuery.ids(include: [label.id!]), tags: TagsQuery.ids(include: [label.id!]),
), ),
canEdit: LocalUserAccount.current.paperlessUser canEdit: LocalUserAccount.current.paperlessUser.hasPermission(
.hasPermission(PermissionAction.change, PermissionTarget.tag), PermissionAction.change, PermissionTarget.tag),
canAddNew: LocalUserAccount.current.paperlessUser canAddNew: LocalUserAccount.current.paperlessUser
.hasPermission(PermissionAction.add, PermissionTarget.tag), .hasPermission(
PermissionAction.add, PermissionTarget.tag),
onEdit: _openEditTagPage, onEdit: _openEditTagPage,
leadingBuilder: (t) => CircleAvatar( leadingBuilder: (t) => CircleAvatar(
backgroundColor: t.color, backgroundColor: t.color,
@@ -224,14 +231,15 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
SliverOverlapInjector(handle: searchBarHandle), SliverOverlapInjector(handle: searchBarHandle),
SliverOverlapInjector(handle: tabBarHandle), SliverOverlapInjector(handle: tabBarHandle),
LabelTabView<StoragePath>( LabelTabView<StoragePath>(
labels: context.watch<LabelCubit>().state.storagePaths, labels: state.storagePaths,
onEdit: _openEditStoragePathPage, onEdit: _openEditStoragePathPage,
filterBuilder: (label) => DocumentFilter( filterBuilder: (label) => DocumentFilter(
storagePath: IdQueryParameter.fromId(label.id!), storagePath: IdQueryParameter.fromId(label.id!),
), ),
canEdit: LocalUserAccount.current.paperlessUser.hasPermission( canEdit: LocalUserAccount.current.paperlessUser.hasPermission(
PermissionAction.change, PermissionTarget.storagePath), PermissionAction.change, PermissionTarget.storagePath),
canAddNew: LocalUserAccount.current.paperlessUser.hasPermission( canAddNew: LocalUserAccount.current.paperlessUser
.hasPermission(
PermissionAction.add, PermissionTarget.storagePath), PermissionAction.add, PermissionTarget.storagePath),
contentBuilder: (path) => Text(path.path), contentBuilder: (path) => Text(path.path),
emptyStateActionButtonLabel: S.of(context)!.addNewStoragePath, emptyStateActionButtonLabel: S.of(context)!.addNewStoragePath,
@@ -245,6 +253,8 @@ class _LabelsPageState extends State<LabelsPage> with SingleTickerProviderStateM
], ],
), ),
), ),
);
},
), ),
), ),
), ),