Changed image viewer and added mobile feature check.
This commit is contained in:
@@ -20,14 +20,20 @@ export default function JobDocumentsComponent({ job, loading, refetch }) {
|
||||
|
||||
const fullphotos = useMemo(
|
||||
() =>
|
||||
job.documents.map((doc) => {
|
||||
job.documents.map((doc, idx) => {
|
||||
return {
|
||||
id: idx,
|
||||
videoUrl:
|
||||
DetermineFileType(doc.type) === "video" && GenerateSrcUrl(doc),
|
||||
source:
|
||||
DetermineFileType(doc.type) === "video"
|
||||
? { uri: GenerateThumbUrl(doc) }
|
||||
: { uri: GenerateSrcUrl(doc) },
|
||||
url:
|
||||
DetermineFileType(doc.type) === "video"
|
||||
? GenerateThumbUrl(doc)
|
||||
: GenerateSrcUrl(doc),
|
||||
thumbUrl: GenerateThumbUrl(doc),
|
||||
};
|
||||
}),
|
||||
[job.documents]
|
||||
|
||||
@@ -74,7 +74,11 @@ export function JobListComponent({ bodyshop }) {
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<Searchbar onChangeText={onChangeSearch} value={searchQuery} />
|
||||
<Searchbar
|
||||
onChangeText={onChangeSearch}
|
||||
value={searchQuery}
|
||||
placeholder={t("joblist.labels.search")}
|
||||
/>
|
||||
<FlatList
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={loading} onRefresh={onRefresh} />
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { Video } from "expo-av";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
Dimensions,
|
||||
Modal,
|
||||
SafeAreaView,
|
||||
TouchableOpacity,
|
||||
} from "react-native";
|
||||
import Gallery from "react-native-image-gallery";
|
||||
import { SafeAreaView } from "react-native";
|
||||
import React from "react";
|
||||
import { ImageGallery } from "@georstat/react-native-image-gallery";
|
||||
|
||||
export default function MediaCacheOverlay({
|
||||
photos,
|
||||
previewVisible,
|
||||
setPreviewVisible,
|
||||
imgIndex,
|
||||
setImgIndex,
|
||||
}) {
|
||||
const [currentIndex, setcurrentIndex] = useState(0);
|
||||
const [dragging, setDragging] = useState(false);
|
||||
|
||||
const videoRef = React.useRef(null);
|
||||
|
||||
//const videoRef = React.useRef(null);
|
||||
return (
|
||||
<Modal
|
||||
onDismiss={() => setPreviewVisible(false)}
|
||||
onRequestClose={() => setPreviewVisible(false)}
|
||||
visible={previewVisible}
|
||||
transparent={false}
|
||||
>
|
||||
<SafeAreaView style={{ flex: 1, backgroundColor: "black" }}>
|
||||
<Gallery
|
||||
initialPage={imgIndex}
|
||||
images={photos}
|
||||
onPageScroll={({ position }) => setcurrentIndex(position)}
|
||||
onPageScrollStateChanged={(state) =>
|
||||
state === "idle" ? setDragging(false) : setDragging(true)
|
||||
}
|
||||
/>
|
||||
<TouchableOpacity
|
||||
style={{ position: "absolute" }}
|
||||
onPress={() => setPreviewVisible(false)}
|
||||
>
|
||||
<Ionicons
|
||||
name="ios-close"
|
||||
size={64}
|
||||
color="dodgerblue"
|
||||
style={{ margin: 20 }}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
{!dragging && photos[currentIndex] && photos[currentIndex].videoUrl && (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
position: "absolute",
|
||||
left: Dimensions.get("window").width / 2 - 32,
|
||||
top: Dimensions.get("window").height / 2 - 32,
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={async () => {
|
||||
await videoRef.current.loadAsync(
|
||||
{ uri: photos[currentIndex].videoUrl },
|
||||
{},
|
||||
false
|
||||
);
|
||||
videoRef.current.presentFullscreenPlayer();
|
||||
}}
|
||||
>
|
||||
<Ionicons name="play" size={64} color="white" />
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</SafeAreaView>
|
||||
<Video ref={videoRef} useNativeControls />
|
||||
</Modal>
|
||||
<SafeAreaView>
|
||||
<ImageGallery
|
||||
close={() => setPreviewVisible(false)}
|
||||
isOpen={previewVisible}
|
||||
images={photos}
|
||||
initialIndex={imgIndex}
|
||||
/>
|
||||
</SafeAreaView>
|
||||
);
|
||||
|
||||
// return (
|
||||
// <Modal
|
||||
// onDismiss={() => setPreviewVisible(false)}
|
||||
// onRequestClose={() => setPreviewVisible(false)}
|
||||
// visible={previewVisible}
|
||||
// transparent={false}
|
||||
// >
|
||||
// <SafeAreaView style={{ flex: 1, backgroundColor: "black" }}>
|
||||
// <Gallery
|
||||
// initialPage={imgIndex}
|
||||
|
||||
// images={photos}
|
||||
// onPageScroll={({ position }) => setcurrentIndex(position)}
|
||||
// onPageScrollStateChanged={(state) =>
|
||||
// state === "idle" ? setDragging(false) : setDragging(true)
|
||||
// }
|
||||
// />
|
||||
// <TouchableOpacity
|
||||
// style={{ position: "absolute" }}
|
||||
// onPress={() => setPreviewVisible(false)}
|
||||
// >
|
||||
// <Ionicons
|
||||
// name="ios-close"
|
||||
// size={64}
|
||||
// color="dodgerblue"
|
||||
// style={{ margin: 20 }}
|
||||
// />
|
||||
// </TouchableOpacity>
|
||||
// {!dragging && photos[currentIndex] && photos[currentIndex].videoUrl && (
|
||||
// <TouchableOpacity
|
||||
// style={{
|
||||
// position: "absolute",
|
||||
// left: Dimensions.get("window").width / 2 - 32,
|
||||
// top: Dimensions.get("window").height / 2 - 32,
|
||||
// justifyContent: "center",
|
||||
// alignItems: "center",
|
||||
// }}
|
||||
// onPress={async () => {
|
||||
// await videoRef.current.loadAsync(
|
||||
// { uri: photos[currentIndex].videoUrl },
|
||||
// {},
|
||||
// false
|
||||
// );
|
||||
// videoRef.current.presentFullscreenPlayer();
|
||||
// }}
|
||||
// >
|
||||
// <Ionicons name="play" size={64} color="white" />
|
||||
// </TouchableOpacity>
|
||||
// )}
|
||||
// </SafeAreaView>
|
||||
// <Video ref={videoRef} useNativeControls />
|
||||
// </Modal>
|
||||
// );
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
|
||||
import { NavigationContainer } from "@react-navigation/native";
|
||||
import { createStackNavigator } from "@react-navigation/stack";
|
||||
import i18n from "i18next";
|
||||
import moment from "moment";
|
||||
import React, { useEffect } from "react";
|
||||
import { Button } from "react-native-paper";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
@@ -174,7 +175,11 @@ export function ScreenMainComponent({
|
||||
<ScreenSplash />
|
||||
) : currentUser.authorized ? (
|
||||
bodyshop ? (
|
||||
<BottomTabsNavigator />
|
||||
HasAccess(bodyshop) ? (
|
||||
<BottomTabsNavigator />
|
||||
) : (
|
||||
<ScreenSplash noAccess />
|
||||
)
|
||||
) : (
|
||||
<ScreenSplash />
|
||||
)
|
||||
@@ -189,3 +194,10 @@ export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(ScreenMainComponent);
|
||||
|
||||
function HasAccess({ features }) {
|
||||
if (features.mobile === undefined) return true;
|
||||
if (features.mobile === false) return false;
|
||||
const d = moment(moment(features.mobile));
|
||||
if (d.isValid()) return d.isAfter(moment());
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ const localStyles = StyleSheet.create({
|
||||
logoContainer: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
|
||||
margin: 10,
|
||||
alignItems: "center",
|
||||
},
|
||||
logo: { width: 175, height: 175, margin: 20 },
|
||||
|
||||
Reference in New Issue
Block a user