message loader
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
import { View } from "react-native";
|
||||||
|
|
||||||
|
import { LoaderIndicator } from "../providers/LoadingProvider";
|
||||||
|
|
||||||
|
export default ({
|
||||||
|
message,
|
||||||
|
defaultMessage = "Chargement...",
|
||||||
|
containerStyle = {},
|
||||||
|
indicatorProps = {},
|
||||||
|
messageStyle = {},
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
{
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
|
containerStyle,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<LoaderIndicator
|
||||||
|
message={message}
|
||||||
|
defaultMessage={defaultMessage}
|
||||||
|
messageStyle={messageStyle}
|
||||||
|
indicatorProps={indicatorProps}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -9,8 +9,6 @@ export default ({ children }) => {
|
|||||||
const [loadingMessage] = useGlobal("_loadingMessage");
|
const [loadingMessage] = useGlobal("_loadingMessage");
|
||||||
|
|
||||||
const { isDesktopWeb = false, isMobileWeb = false } = useLayoutType();
|
const { isDesktopWeb = false, isMobileWeb = false } = useLayoutType();
|
||||||
const isWeb = isDesktopWeb || isMobileWeb;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{children}
|
{children}
|
||||||
@@ -36,29 +34,47 @@ export default ({ children }) => {
|
|||||||
: { position: "absolute" },
|
: { position: "absolute" },
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<LoaderIndicator
|
<LoaderIndicator message={loadingMessage ?? undefined} />
|
||||||
isWeb={isWeb}
|
|
||||||
message={isWeb ? loadingMessage : null}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const LoaderIndicator = ({ isWeb = false, message = null }) => {
|
export const LoaderIndicator = ({
|
||||||
|
message,
|
||||||
|
defaultMessage = "Chargement...",
|
||||||
|
messageStyle = null,
|
||||||
|
indicatorProps = {},
|
||||||
|
}) => {
|
||||||
|
const {
|
||||||
|
size = "large",
|
||||||
|
color = Palette.primary,
|
||||||
|
...restIndicatorProps
|
||||||
|
} = indicatorProps;
|
||||||
|
|
||||||
|
const resolvedMessage =
|
||||||
|
message === undefined ? defaultMessage : message;
|
||||||
|
const shouldShowMessage =
|
||||||
|
resolvedMessage !== null &&
|
||||||
|
resolvedMessage !== undefined &&
|
||||||
|
String(resolvedMessage).length > 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ alignItems: "center", gap: 10 }}>
|
<View style={{ alignItems: "center", gap: 10 }}>
|
||||||
<ActivityIndicator size={"large"} color={Palette.primary} />
|
<ActivityIndicator size={size} color={color} {...restIndicatorProps} />
|
||||||
{isWeb && message ? (
|
{shouldShowMessage ? (
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={[
|
||||||
|
{
|
||||||
color: Palette.white,
|
color: Palette.white,
|
||||||
fontFamily: FONT_FAMILY.InterRegular,
|
fontFamily: FONT_FAMILY.InterRegular,
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
}}
|
},
|
||||||
|
messageStyle,
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
{message}
|
{resolvedMessage}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
) : null}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ const Home = () => {
|
|||||||
const [menuAnchor, setMenuAnchor] = useState(null);
|
const [menuAnchor, setMenuAnchor] = useState(null);
|
||||||
const [menuProject, setMenuProject] = useState(null);
|
const [menuProject, setMenuProject] = useState(null);
|
||||||
const menuAnchorRef = useRef(null);
|
const menuAnchorRef = useRef(null);
|
||||||
|
const testLoaderTimeoutRef = useRef(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setActiveStageIndex((prev) => {
|
setActiveStageIndex((prev) => {
|
||||||
@@ -218,6 +219,15 @@ const Home = () => {
|
|||||||
stageRoute,
|
stageRoute,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (testLoaderTimeoutRef.current) {
|
||||||
|
clearTimeout(testLoaderTimeoutRef.current);
|
||||||
|
testLoaderTimeoutRef.current = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const songwriterAction = useMemo(
|
const songwriterAction = useMemo(
|
||||||
() => getStageAction("songwriter", null),
|
() => getStageAction("songwriter", null),
|
||||||
[]
|
[]
|
||||||
@@ -304,6 +314,7 @@ const Home = () => {
|
|||||||
onPress={handleStageAction}
|
onPress={handleStageAction}
|
||||||
disabled={continueDisabled}
|
disabled={continueDisabled}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* <BorderGradientButton
|
{/* <BorderGradientButton
|
||||||
containerStyle={{ width: Platform.OS === "web" ? 250 : "100%" }}
|
containerStyle={{ width: Platform.OS === "web" ? 250 : "100%" }}
|
||||||
title={"Test Alert"}
|
title={"Test Alert"}
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ const MusicDetails = ({ route }) => {
|
|||||||
condition: !!projectId,
|
condition: !!projectId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log("project is : ", project);
|
||||||
|
|
||||||
const { data: owner } = useDataFromRef({
|
const { data: owner } = useDataFromRef({
|
||||||
ref: project?.userId ? usersRef.doc(project.userId) : null,
|
ref: project?.userId ? usersRef.doc(project.userId) : null,
|
||||||
simpleRef: true,
|
simpleRef: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user