feat: fixes and formatter
This commit is contained in:
@@ -1,45 +1,41 @@
|
||||
import React, { useRef, useEffect, useMemo, createContext } from "reactn";
|
||||
import React, { useRef, useEffect, useMemo, createContext } from 'reactn'
|
||||
|
||||
import BottomSheetContainer from "../components/BottomSheetContainer";
|
||||
import { WebView } from "../components/WebView";
|
||||
import BottomSheetContainer from '../components/BottomSheetContainer'
|
||||
import { WebView } from '../components/WebView'
|
||||
|
||||
import { Palette } from "../styles";
|
||||
import { useContext } from "react";
|
||||
import { Platform } from "react-native";
|
||||
import { Palette } from '../styles'
|
||||
import { useContext } from 'react'
|
||||
import { Platform } from 'react-native'
|
||||
|
||||
export const WebViewContext = createContext();
|
||||
export const WebViewContext = createContext()
|
||||
|
||||
export default ({ children }) => {
|
||||
const [webViewUrl, setWebViewUrl] = React.useState(Platform.OS == "ios" ? null : undefined);
|
||||
const [webViewUrl, setWebViewUrl] = React.useState(Platform.OS == 'ios' ? null : undefined)
|
||||
|
||||
const snapPoints = useMemo(() => ["70%", "90%"], []);
|
||||
const bottomSheetRef = useRef(null);
|
||||
const snapPoints = useMemo(() => ['70%', '90%'], [])
|
||||
const bottomSheetRef = useRef(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (webViewUrl) {
|
||||
bottomSheetRef.current?.expand();
|
||||
bottomSheetRef.current?.expand()
|
||||
} else {
|
||||
bottomSheetRef.current?.close();
|
||||
bottomSheetRef.current?.close()
|
||||
}
|
||||
}, [webViewUrl]);
|
||||
}, [webViewUrl])
|
||||
|
||||
const handleCloseWebView = (url) => {
|
||||
if (url?.includes("minuit.starter")) {
|
||||
setWebViewUrl(Platform.OS == "ios" ? null : undefined); // Réinitialiser l'URL
|
||||
bottomSheetRef.current?.close(); // Fermer la BottomSheet
|
||||
if (url?.includes('minuit.starter')) {
|
||||
setWebViewUrl(Platform.OS == 'ios' ? null : undefined) // Réinitialiser l'URL
|
||||
bottomSheetRef.current?.close() // Fermer la BottomSheet
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const docExtensionList = [".docx", ".doc", ".xlsx", ".xls", ".pptx", ".ppt"];
|
||||
const isOfficeDoc = docExtensionList.some((ext) =>
|
||||
webViewUrl?.toLowerCase()?.includes(ext)
|
||||
);
|
||||
const docExtensionList = ['.docx', '.doc', '.xlsx', '.xls', '.pptx', '.ppt']
|
||||
const isOfficeDoc = docExtensionList.some((ext) => webViewUrl?.toLowerCase()?.includes(ext))
|
||||
|
||||
const dynamicWebViewUrl = isOfficeDoc
|
||||
? `https://docs.google.com/gview?embedded=true&url=${encodeURIComponent(
|
||||
webViewUrl
|
||||
)}`
|
||||
: webViewUrl;
|
||||
? `https://docs.google.com/gview?embedded=true&url=${encodeURIComponent(webViewUrl)}`
|
||||
: webViewUrl
|
||||
|
||||
return (
|
||||
<WebViewContext.Provider value={{ webViewUrl, setWebViewUrl }}>
|
||||
@@ -50,7 +46,7 @@ export default ({ children }) => {
|
||||
snapPoints={snapPoints}
|
||||
onChange={(index) => {
|
||||
if (index === -1) {
|
||||
setWebViewUrl(Platform.OS == "ios" ? null : undefined);
|
||||
setWebViewUrl(Platform.OS == 'ios' ? null : undefined)
|
||||
}
|
||||
}}
|
||||
index={-1}
|
||||
@@ -67,7 +63,7 @@ export default ({ children }) => {
|
||||
/>
|
||||
</BottomSheetContainer>
|
||||
</WebViewContext.Provider>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export const useWebView = () => useContext(WebViewContext);
|
||||
export const useWebView = () => useContext(WebViewContext)
|
||||
|
||||
Reference in New Issue
Block a user