block global audio from screens
This commit is contained in:
@@ -56,6 +56,26 @@ const App = () => {
|
||||
|
||||
const [isInitializing, setInitializing] = useState(true);
|
||||
|
||||
const routeNameRef = React.useRef(null);
|
||||
|
||||
const syncActiveRoute = useCallback(() => {
|
||||
const currentRoute = navigationRef.current?.getCurrentRoute();
|
||||
const currentName = currentRoute?.name ?? null;
|
||||
|
||||
if (routeNameRef.current !== currentName) {
|
||||
routeNameRef.current = currentName;
|
||||
setGlobal({ activeRouteName: currentName });
|
||||
}
|
||||
}, [setGlobal]);
|
||||
|
||||
const handleNavigationReady = useCallback(() => {
|
||||
syncActiveRoute();
|
||||
}, [syncActiveRoute]);
|
||||
|
||||
const handleNavigationStateChange = useCallback(() => {
|
||||
syncActiveRoute();
|
||||
}, [syncActiveRoute]);
|
||||
|
||||
const [loaded] = useFonts({
|
||||
NewYorkSemibold: require("./src/assets/fonts/NewYork-Semibold.ttf"),
|
||||
OpenSansRegular: require("./src/assets/fonts/OpenSans-Regular.ttf"),
|
||||
@@ -164,6 +184,8 @@ const App = () => {
|
||||
},
|
||||
}}
|
||||
ref={navigationRef}
|
||||
onReady={handleNavigationReady}
|
||||
onStateChange={handleNavigationStateChange}
|
||||
documentTitle={{
|
||||
formatter: (options) =>
|
||||
options?.title
|
||||
|
||||
Reference in New Issue
Block a user