test
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -35,3 +35,4 @@ yarn-error.*
 | 
			
		||||
# typescript
 | 
			
		||||
*.tsbuildinfo
 | 
			
		||||
yarn.lock
 | 
			
		||||
package-lock.json
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								app.json
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								app.json
									
									
									
									
									
								
							@@ -34,7 +34,10 @@
 | 
			
		||||
      },
 | 
			
		||||
      "package": "com.anonymous.Assemblr",
 | 
			
		||||
      "permissions": [
 | 
			
		||||
        "INTERNET"
 | 
			
		||||
        "INTERNET",
 | 
			
		||||
        "REQUEST_INSTALL_PACKAGES",
 | 
			
		||||
        "READ_EXTERNAL_STORAGE",
 | 
			
		||||
        "WRITE_EXTERNAL_STORAGE"
 | 
			
		||||
      ]
 | 
			
		||||
    },
 | 
			
		||||
    "web": {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								build.py
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								build.py
									
									
									
									
									
								
							@@ -26,7 +26,7 @@ class ApplicationApi:
 | 
			
		||||
 | 
			
		||||
    def upload(self, version: str, file_path: str):
 | 
			
		||||
        data = {'version': version}
 | 
			
		||||
        files = {'file': file_path}
 | 
			
		||||
        files = {'file': open(file_path, 'rb')}
 | 
			
		||||
        return self.method('POST', 'upload', data=data, files=files)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,9 @@
 | 
			
		||||
    "axios": "^1.5.0",
 | 
			
		||||
    "babel-plugin-module-resolver": "^5.0.0",
 | 
			
		||||
    "expo": "~49.0.8",
 | 
			
		||||
    "expo-application": "~5.3.0",
 | 
			
		||||
    "expo-build-properties": "~0.8.3",
 | 
			
		||||
    "expo-constants": "~14.4.2",
 | 
			
		||||
    "expo-secure-store": "~12.3.1",
 | 
			
		||||
    "expo-splash-screen": "~0.20.5",
 | 
			
		||||
    "expo-status-bar": "~1.6.0",
 | 
			
		||||
@@ -38,6 +40,8 @@
 | 
			
		||||
    "react-native-keyevent-expo-config-plugin": "^1.0.49",
 | 
			
		||||
    "react-native-modal": "^13.0.1",
 | 
			
		||||
    "react-native-paper": "^5.10.6",
 | 
			
		||||
    "react-native-progress": "^5.0.1",
 | 
			
		||||
    "react-native-progress-circle-updated": "^2.2.1",
 | 
			
		||||
    "react-native-radio-buttons-group": "^3.0.5",
 | 
			
		||||
    "react-native-reanimated": "3.3.0",
 | 
			
		||||
    "react-native-responsive-dimensions": "^3.1.1",
 | 
			
		||||
@@ -51,7 +55,9 @@
 | 
			
		||||
    "react-native-webview": "13.2.2",
 | 
			
		||||
    "react-redux": "^8.1.2",
 | 
			
		||||
    "redux": "^4.2.1",
 | 
			
		||||
    "rn-openapp": "^2.1.2"
 | 
			
		||||
    "rn-openapp": "^2.1.2",
 | 
			
		||||
    "expo-file-system": "~15.4.4",
 | 
			
		||||
    "expo-intent-launcher": "~10.7.0"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@babel/core": "^7.20.0",
 | 
			
		||||
 
 | 
			
		||||
@@ -8,12 +8,13 @@ import CommonPage from "./screens/CommonPage/CommonPage";
 | 
			
		||||
import {BottomSheetModalProvider} from "@gorhom/bottom-sheet";
 | 
			
		||||
import {GestureHandlerRootView} from "react-native-gesture-handler";
 | 
			
		||||
import Toast from "react-native-toast-message";
 | 
			
		||||
 | 
			
		||||
import Constants from "expo-constants";
 | 
			
		||||
 | 
			
		||||
export default function App() {
 | 
			
		||||
    let [fontsLoading] = useFonts({
 | 
			
		||||
        // 'SF Pro Text': require('./assets/fonts/SF-Pro-Text-Regular.otf')
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    if (!fontsLoading)
 | 
			
		||||
        return <View><Text>Loading...</Text></View>
 | 
			
		||||
    return (
 | 
			
		||||
 
 | 
			
		||||
@@ -5,8 +5,8 @@ import {logout} from "../features/auth/authSlice";
 | 
			
		||||
import {store} from "../redux/store";
 | 
			
		||||
 | 
			
		||||
const apiClient = axios.create({
 | 
			
		||||
    baseURL: 'https://assemblr.denco.store',
 | 
			
		||||
    // baseURL: 'http://192.168.1.101:5000',
 | 
			
		||||
    // baseURL: 'https://assemblr.denco.store',
 | 
			
		||||
    baseURL: 'http://192.168.1.101:5000',
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
apiClient.interceptors.request.use(async (config) => {
 | 
			
		||||
@@ -27,12 +27,6 @@ apiClient.interceptors.request.use(async (config) => {
 | 
			
		||||
 | 
			
		||||
    return config;
 | 
			
		||||
}, function (error) {
 | 
			
		||||
    console.log("очко")
 | 
			
		||||
 | 
			
		||||
    if (error.response && error.response.status === 401) {
 | 
			
		||||
        console.log("очко")
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										19
									
								
								src/api/applicationApi.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/api/applicationApi.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
import apiClient from "./apiClient";
 | 
			
		||||
 | 
			
		||||
const router = '/application';
 | 
			
		||||
const api_key = 'AF9A20DD9264C134CDA0ADACED834368';
 | 
			
		||||
const applicationApi = {
 | 
			
		||||
    getVersion: async (name: string): Promise<{ 'latest_version': string }> => {
 | 
			
		||||
        let response = await apiClient.get(`${router}/${name}/version`, {headers: {Authorization: api_key}});
 | 
			
		||||
        return response.data;
 | 
			
		||||
    },
 | 
			
		||||
    download: async (name: string, version: string): Promise<ArrayBuffer> => {
 | 
			
		||||
        let response = await apiClient.get(`${router}/${name}/download/${version}`, {
 | 
			
		||||
            headers: {Authorization: api_key},
 | 
			
		||||
            responseType: "arraybuffer"
 | 
			
		||||
        });
 | 
			
		||||
        return response.data;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default applicationApi;
 | 
			
		||||
@@ -5,5 +5,6 @@ const userApi = {
 | 
			
		||||
        let response = await apiClient.post('/auth/login', {login, password});
 | 
			
		||||
        return response.data;
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
export default userApi;
 | 
			
		||||
@@ -3,19 +3,27 @@ import {StyleSheet, View} from "react-native";
 | 
			
		||||
import {useSelector} from "react-redux";
 | 
			
		||||
import {RootState} from "../../../redux/store";
 | 
			
		||||
import Modal from "react-native-modal";
 | 
			
		||||
import {background} from "../../../css/colors";
 | 
			
		||||
import {background, blue} from "../../../css/colors";
 | 
			
		||||
import {responsiveHeight, responsiveWidth} from "react-native-responsive-dimensions";
 | 
			
		||||
import DTitle from "../../DTitle/DTitle";
 | 
			
		||||
import * as Progress from 'react-native-progress';
 | 
			
		||||
import {RFPercentage} from "react-native-responsive-fontsize";
 | 
			
		||||
 | 
			
		||||
const LoadingModal: FC = () => {
 | 
			
		||||
    const isVisible = useSelector((state: RootState) => state.loadingModal.isVisible);
 | 
			
		||||
    const loadingText = useSelector((state: RootState) => state.loadingModal.loadingText);
 | 
			
		||||
    const [ch, sCh] = useState(false);
 | 
			
		||||
    return (
 | 
			
		||||
        <Modal isVisible={isVisible}>
 | 
			
		||||
        <Modal isVisible={true}>
 | 
			
		||||
            <View style={styles.container}>
 | 
			
		||||
                <DTitle style={{textAlign: "center"}}>{loadingText}</DTitle>
 | 
			
		||||
                <View style={styles.progressBarWrapper}>
 | 
			
		||||
                    <Progress.Circle size={RFPercentage(20)}
 | 
			
		||||
                                     color={blue}
 | 
			
		||||
                                     indeterminate={true}
 | 
			
		||||
                                     style={styles.progressBar}
 | 
			
		||||
                                     borderWidth={responsiveWidth(1)}
 | 
			
		||||
                    />
 | 
			
		||||
                </View>
 | 
			
		||||
 | 
			
		||||
            </View>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										0
									
								
								src/components/Modals/UpdaterModal/UpdaterModal.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/components/Modals/UpdaterModal/UpdaterModal.tsx
									
									
									
									
									
										Normal file
									
								
							@@ -1,7 +1,6 @@
 | 
			
		||||
import {SafeAreaView, StyleSheet, View} from "react-native";
 | 
			
		||||
import {Linking, StyleSheet, View} from "react-native";
 | 
			
		||||
import LoginScreen from "../LoginScreen/LoginScreen";
 | 
			
		||||
import MainScreen from "../MainScreen/MainScreen";
 | 
			
		||||
import SearchBar from "../../components/SearchBar/SearchBar";
 | 
			
		||||
import React, {useEffect} from "react";
 | 
			
		||||
import {background} from "../../css/colors";
 | 
			
		||||
import {useDispatch, useSelector} from "react-redux";
 | 
			
		||||
@@ -11,16 +10,19 @@ import * as SecureStore from 'expo-secure-store';
 | 
			
		||||
import Toast from "react-native-toast-message";
 | 
			
		||||
import toastConfig from "../../components/Toast/Toast";
 | 
			
		||||
import ScanModal from "../../components/SearchBar/ScanModal";
 | 
			
		||||
import {closeScanModal, setScannedData} from "../../features/scanModal/scanModalSlice";
 | 
			
		||||
import LoadingModal from "../../components/Modals/LoadingModal/LoadingModal";
 | 
			
		||||
import ReprintModal from "../../components/Modals/ReprintModal/ReprintModal";
 | 
			
		||||
import assemblyApi from "../../api/assemblyApi";
 | 
			
		||||
import {assembly, setAssembly, setLocalState, setOrder} from "../../features/assembly/assemblySlice";
 | 
			
		||||
import {setAssembly, setLocalState, setOrder} from "../../features/assembly/assemblySlice";
 | 
			
		||||
import ordersApi from "../../api/ordersApi";
 | 
			
		||||
import ImageZoomModal from "../../components/Modals/ImageZoomModal/ImageZoomModal";
 | 
			
		||||
import SortingModal from "../../components/Modals/SortingModal/SortingModal";
 | 
			
		||||
import {setLoadingText} from "../../features/loadingModal/loadingModalSlice";
 | 
			
		||||
import {ASSEMBLY_STATE} from "../../types/assembly";
 | 
			
		||||
import Constants from "expo-constants";
 | 
			
		||||
import * as FileSystem from 'expo-file-system';
 | 
			
		||||
import applicationApi from "../../api/applicationApi";
 | 
			
		||||
import {ActivityAction, startActivityAsync} from "expo-intent-launcher";
 | 
			
		||||
import {RenderTargetOptions} from "@shopify/flash-list";
 | 
			
		||||
 | 
			
		||||
function CommonPage() {
 | 
			
		||||
    const dim = useSelector((state: RootState) => state.interface.dim);
 | 
			
		||||
@@ -33,7 +35,6 @@ function CommonPage() {
 | 
			
		||||
        dispatch(login({accessToken: token}));
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const loadAssembly = async () => {
 | 
			
		||||
        assemblyApi.hasActive().then(({has}) => {
 | 
			
		||||
            if (!has) return;
 | 
			
		||||
@@ -54,13 +55,53 @@ function CommonPage() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    const checkUpdates = async () => {
 | 
			
		||||
        //
 | 
			
		||||
        // let packageName = Constants.manifest2?.extra?.expoClient?.android?.package; // Замените на имя пакета вашего приложения
 | 
			
		||||
        // const uri = `package:${packageName}`;
 | 
			
		||||
        // startActivityAsync('android.settings.MANAGE_UNKNOWN_APP_SOURCES', {
 | 
			
		||||
        //     data: uri
 | 
			
		||||
        // }).then(result => {
 | 
			
		||||
        //     console.log(result);
 | 
			
		||||
        // }).catch(error => {
 | 
			
		||||
        //     console.log(error);
 | 
			
		||||
        // });
 | 
			
		||||
        // return
 | 
			
		||||
        const currentVersion = Constants.manifest2?.extra?.expoClient?.version;
 | 
			
		||||
        applicationApi.getVersion('assemblr').then(({latest_version}) => {
 | 
			
		||||
            const apkPath = FileSystem.documentDirectory + "test.apk";
 | 
			
		||||
            FileSystem.downloadAsync('http://192.168.1.101:5000/application/assemblr/download/1.1.8', apkPath).then(downloadResult => {
 | 
			
		||||
                FileSystem.getContentUriAsync(apkPath).then(localUri => {
 | 
			
		||||
                    try {
 | 
			
		||||
                        startActivityAsync('android.intent.action.INSTALL_PACKAGE', {
 | 
			
		||||
                            data: localUri,
 | 
			
		||||
                            flags: 1
 | 
			
		||||
                        }).then(result => {
 | 
			
		||||
                            console.log(result);
 | 
			
		||||
                        }).catch(error => {
 | 
			
		||||
                            console.log(error);
 | 
			
		||||
                        });
 | 
			
		||||
                    } catch (ex) {
 | 
			
		||||
                        console.log(ex);
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                })
 | 
			
		||||
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
    useEffect(() => {
 | 
			
		||||
        initialize();
 | 
			
		||||
        checkUpdates();
 | 
			
		||||
        //initialize();
 | 
			
		||||
    }, []);
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
 | 
			
		||||
        <View style={styles.main}>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            {isAuthorized ? <MainScreen/> : <LoginScreen/>}
 | 
			
		||||
            <View style={[styles.overlay, {display: dim ? 'flex' : 'none'}]}/>
 | 
			
		||||
            <LoadingModal/>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user