mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 16:05:18 +00:00
fix(track_collection_view): hide search bar when sliver is collapsed
This commit is contained in:
parent
dc96cb38ce
commit
3d6d2444be
@ -102,6 +102,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
final collapsed = useState(false);
|
final collapsed = useState(false);
|
||||||
|
|
||||||
final searchText = useState("");
|
final searchText = useState("");
|
||||||
|
final searchController = useTextEditingController();
|
||||||
|
|
||||||
final filteredTracks = useMemoized(() {
|
final filteredTracks = useMemoized(() {
|
||||||
if (searchText.value.isEmpty) {
|
if (searchText.value.isEmpty) {
|
||||||
@ -131,9 +132,9 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
|
|
||||||
useEffect(() {
|
useEffect(() {
|
||||||
listener() {
|
listener() {
|
||||||
if (controller.position.pixels >= 400 && !collapsed.value) {
|
if (controller.position.pixels >= 390 && !collapsed.value) {
|
||||||
collapsed.value = true;
|
collapsed.value = true;
|
||||||
} else if (controller.position.pixels < 400 && collapsed.value) {
|
} else if (controller.position.pixels < 390 && collapsed.value) {
|
||||||
collapsed.value = false;
|
collapsed.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -149,6 +150,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
maxHeight: 50,
|
maxHeight: 50,
|
||||||
),
|
),
|
||||||
child: PlatformTextField(
|
child: PlatformTextField(
|
||||||
|
controller: searchController,
|
||||||
onChanged: (value) => searchText.value = value,
|
onChanged: (value) => searchText.value = value,
|
||||||
placeholder: "Search tracks...",
|
placeholder: "Search tracks...",
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
@ -172,7 +174,9 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
useEffect(() {
|
useEffect(() {
|
||||||
OverlayEntry? entry;
|
OverlayEntry? entry;
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
if (platform == TargetPlatform.windows && kIsDesktop) {
|
if (platform == TargetPlatform.windows &&
|
||||||
|
kIsDesktop &&
|
||||||
|
!collapsed.value) {
|
||||||
entry = OverlayEntry(builder: (context) {
|
entry = OverlayEntry(builder: (context) {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
left: 40,
|
left: 40,
|
||||||
@ -184,7 +188,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return () => entry?.remove();
|
return () => entry?.remove();
|
||||||
}, [color?.titleTextColor]);
|
}, [color?.titleTextColor, collapsed.value]);
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: PlatformScaffold(
|
child: PlatformScaffold(
|
||||||
@ -234,6 +238,7 @@ class TrackCollectionView<T> extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
|
centerTitle: true,
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
background: DecoratedBox(
|
background: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
Loading…
Reference in New Issue
Block a user