fix: Fix scrolling bug on inbox page

This commit is contained in:
Anton Stubenbord
2023-06-03 15:20:20 +02:00
parent d2b428c05b
commit 880695e04f
12 changed files with 427 additions and 331 deletions

View File

@@ -108,8 +108,9 @@ class _DocumentSearchPageState extends State<DocumentSearchPage> {
}
Widget _buildSuggestionsView(DocumentSearchState state) {
final suggestions =
state.suggestions.whereNot((element) => state.searchHistory.contains(element)).toList();
final suggestions = state.suggestions
.whereNot((element) => state.searchHistory.contains(element))
.toList();
final historyMatches = state.searchHistory
.where(
(element) => element.startsWith(query),
@@ -140,7 +141,7 @@ class _DocumentSearchPageState extends State<DocumentSearchPage> {
childCount: suggestions.length,
),
),
if (suggestions.isEmpty && historyMatches.isEmpty)
if (suggestions.isEmpty && historyMatches.isEmpty && state.hasLoaded)
SliverPadding(
padding: const EdgeInsets.all(16),
sliver: SliverToBoxAdapter(
@@ -191,7 +192,8 @@ class _DocumentSearchPageState extends State<DocumentSearchPage> {
builder: (context, state) {
return ViewTypeSelectionWidget(
viewType: state.viewType,
onChanged: (type) => context.read<DocumentSearchCubit>().updateViewType(type),
onChanged: (type) =>
context.read<DocumentSearchCubit>().updateViewType(type),
);
},
)

View File

@@ -16,18 +16,22 @@ class SliverSearchBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final currentUser =
Hive.box<GlobalSettings>(HiveBoxes.globalSettings).getValue()!.currentLoggedInUser;
final currentUser = Hive.box<GlobalSettings>(HiveBoxes.globalSettings)
.getValue()!
.currentLoggedInUser;
return SliverPersistentHeader(
floating: floating,
pinned: pinned,
delegate: CustomizableSliverPersistentHeaderDelegate(
minExtent: kToolbarHeight,
maxExtent: kToolbarHeight,
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 16.0),
child: const DocumentSearchBar(),
return SliverPadding(
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
sliver: SliverPersistentHeader(
floating: floating,
pinned: pinned,
delegate: CustomizableSliverPersistentHeaderDelegate(
minExtent: kToolbarHeight,
maxExtent: kToolbarHeight,
child: Container(
margin: const EdgeInsets.symmetric(horizontal: 16.0),
child: const DocumentSearchBar(),
),
),
),
);