Skip to content

Commit

Permalink
fix(track_collection_view): hide search bar when sliver is collapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
KRTirtho committed Jan 7, 2023
1 parent dc96cb3 commit 3d6d244
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/components/shared/track_table/track_collection_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
final collapsed = useState(false);

final searchText = useState("");
final searchController = useTextEditingController();

final filteredTracks = useMemoized(() {
if (searchText.value.isEmpty) {
Expand Down Expand Up @@ -131,9 +132,9 @@ class TrackCollectionView<T> extends HookConsumerWidget {

useEffect(() {
listener() {
if (controller.position.pixels >= 400 && !collapsed.value) {
if (controller.position.pixels >= 390 && !collapsed.value) {
collapsed.value = true;
} else if (controller.position.pixels < 400 && collapsed.value) {
} else if (controller.position.pixels < 390 && collapsed.value) {
collapsed.value = false;
}
}
Expand All @@ -149,6 +150,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
maxHeight: 50,
),
child: PlatformTextField(
controller: searchController,
onChanged: (value) => searchText.value = value,
placeholder: "Search tracks...",
backgroundColor: Colors.transparent,
Expand All @@ -172,7 +174,9 @@ class TrackCollectionView<T> extends HookConsumerWidget {
useEffect(() {
OverlayEntry? entry;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (platform == TargetPlatform.windows && kIsDesktop) {
if (platform == TargetPlatform.windows &&
kIsDesktop &&
!collapsed.value) {
entry = OverlayEntry(builder: (context) {
return Positioned(
left: 40,
Expand All @@ -184,7 +188,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
}
});
return () => entry?.remove();
}, [color?.titleTextColor]);
}, [color?.titleTextColor, collapsed.value]);

return SafeArea(
child: PlatformScaffold(
Expand Down Expand Up @@ -234,6 +238,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
),
)
: null,
centerTitle: true,
flexibleSpace: FlexibleSpaceBar(
background: DecoratedBox(
decoration: BoxDecoration(
Expand Down

0 comments on commit 3d6d244

Please sign in to comment.