Browse Source

Merge pull request #1007 from nextcloud/fix/neon_dashboard/scrolling

fix(neon_dashboard): Fix widgets reloading scrolling back up
pull/1011/head
Kate 1 year ago committed by GitHub
parent
commit
fe29bb8bc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      packages/neon/neon/lib/src/widgets/list_view.dart
  2. 1
      packages/neon/neon/lib/src/widgets/unified_search_results.dart
  3. 1
      packages/neon/neon_dashboard/lib/src/pages/main.dart
  4. 1
      packages/neon/neon_dashboard/lib/src/widgets/widget.dart

8
packages/neon/neon/lib/src/widgets/list_view.dart

@ -8,8 +8,8 @@ class NeonListView extends StatelessWidget {
required this.error, required this.error,
required this.onRefresh, required this.onRefresh,
required final NullableIndexedWidgetBuilder itemBuilder, required final NullableIndexedWidgetBuilder itemBuilder,
required this.scrollKey,
final int? itemCount, final int? itemCount,
this.scrollKey,
this.topFixedChildren, this.topFixedChildren,
this.topScrollingChildren, this.topScrollingChildren,
super.key, super.key,
@ -23,7 +23,7 @@ class NeonListView extends StatelessWidget {
required this.error, required this.error,
required this.onRefresh, required this.onRefresh,
required this.sliver, required this.sliver,
this.scrollKey, required this.scrollKey,
this.topFixedChildren, this.topFixedChildren,
this.topScrollingChildren, this.topScrollingChildren,
super.key, super.key,
@ -32,7 +32,7 @@ class NeonListView extends StatelessWidget {
final bool isLoading; final bool isLoading;
final Object? error; final Object? error;
final RefreshCallback onRefresh; final RefreshCallback onRefresh;
final String? scrollKey; final String scrollKey;
final List<Widget>? topFixedChildren; final List<Widget>? topFixedChildren;
final List<Widget>? topScrollingChildren; final List<Widget>? topScrollingChildren;
final Widget sliver; final Widget sliver;
@ -46,7 +46,7 @@ class NeonListView extends StatelessWidget {
key: refreshIndicatorKey, key: refreshIndicatorKey,
onRefresh: onRefresh, onRefresh: onRefresh,
child: CustomScrollView( child: CustomScrollView(
key: scrollKey != null ? PageStorageKey<String>(scrollKey!) : null, key: PageStorageKey<String>(scrollKey),
primary: true, primary: true,
slivers: [ slivers: [
if (topFixedChildren != null) if (topFixedChildren != null)

1
packages/neon/neon/lib/src/widgets/unified_search_results.dart

@ -32,6 +32,7 @@ class NeonUnifiedSearchResults extends StatelessWidget {
final values = results.data?.entries.toList(); final values = results.data?.entries.toList();
return NeonListView( return NeonListView(
scrollKey: 'unified-search',
isLoading: results.isLoading, isLoading: results.isLoading,
error: results.error, error: results.error,
onRefresh: bloc.refresh, onRefresh: bloc.refresh,

1
packages/neon/neon_dashboard/lib/src/pages/main.dart

@ -38,6 +38,7 @@ class DashboardMainPage extends StatelessWidget {
return Center( return Center(
child: NeonListView.custom( child: NeonListView.custom(
scrollKey: 'dashboard',
isLoading: snapshot.isLoading, isLoading: snapshot.isLoading,
error: snapshot.error, error: snapshot.error,
onRefresh: bloc.refresh, onRefresh: bloc.refresh,

1
packages/neon/neon_dashboard/lib/src/widgets/widget.dart

@ -36,6 +36,7 @@ class DashboardWidget extends StatelessWidget {
borderRadius: const BorderRadius.all(Radius.circular(12)), borderRadius: const BorderRadius.all(Radius.circular(12)),
child: ListView( child: ListView(
padding: const EdgeInsets.all(8), padding: const EdgeInsets.all(8),
key: PageStorageKey<String>('dashboard-${widget.id}'),
children: [ children: [
ListTile( ListTile(
title: Text( title: Text(

Loading…
Cancel
Save