-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: search overlay on tab press (#11165)
chore: dimsis overlay on tab press
- Loading branch information
1 parent
7549399
commit d914193
Showing
8 changed files
with
72 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/app/Components/GlobalSearchInput/utils/useDismissSearchOverlayOnTabBarPress.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useIsFocused, useNavigation } from "@react-navigation/native" | ||
import { GlobalStore } from "app/store/GlobalStore" | ||
import { useEffect } from "react" | ||
|
||
/** | ||
* Dismisses the GlobalSearchInputOverlay when the tab bar is pressed | ||
*/ | ||
export const useDismissSearchOverlayOnTabBarPress = ({ | ||
isVisible, | ||
ownerType, | ||
setIsVisible, | ||
}: { | ||
isVisible: boolean | ||
ownerType: string | ||
setIsVisible: React.Dispatch<React.SetStateAction<boolean>> | ||
}) => { | ||
const isFocused = useIsFocused() | ||
const selectedTab = GlobalStore.useAppState((state) => state.bottomTabs.sessionState.selectedTab) | ||
|
||
const navigation = useNavigation() | ||
|
||
useEffect(() => { | ||
const tabsNavigation = navigation?.getParent() | ||
const unsubscribe = tabsNavigation?.addListener("tabPress" as any, () => { | ||
if (!isFocused || !isVisible) { | ||
return | ||
} | ||
|
||
if (ownerType === selectedTab.toLowerCase()) { | ||
setIsVisible(false) | ||
} | ||
}) | ||
return unsubscribe | ||
}, [isVisible, selectedTab, navigation, isFocused]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters