From b93c1a351d16137ce82c70a1fff3dd5517740349 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Thu, 26 May 2022 17:17:20 +0430 Subject: [PATCH] update 8 files --- package.json | 2 +- src/assets/icons/marker.png | Bin 0 -> 3288 bytes src/components/Avatar.js | 2 +- src/components/MapSelector.js | 59 +++++++++++++++------ src/redux/reducers/file.js | 6 +-- src/screens/Address/index.js | 70 ++++++++++++++----------- src/screens/Home/index.js | 7 ++- src/screens/Profile/components/User.js | 13 ++++- yarn.lock | 17 ++++-- 9 files changed, 112 insertions(+), 64 deletions(-) create mode 100644 src/assets/icons/marker.png diff --git a/package.json b/package.json index f44374e..90a5ffa 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "eject": "expo eject" }, "dependencies": { - "@expo-google-fonts/noto-sans": "^0.2.0", "@react-native-async-storage/async-storage": "~1.15.0", "@react-native-community/netinfo": "7.1.3", "@react-native-community/slider": "4.1.12", @@ -44,6 +43,7 @@ "react-native-awesome-alerts": "^1.5.2", "react-native-copilot": "^2.5.1", "react-native-htmlview": "^0.16.0", + "react-native-maps": "0.29.4", "react-native-openanything": "^0.0.6", "react-native-qrcode-scanner": "^1.5.4", "react-native-ratings": "^8.1.0", diff --git a/src/assets/icons/marker.png b/src/assets/icons/marker.png new file mode 100644 index 0000000000000000000000000000000000000000..c4ac791abca7a46efc4f5581b060924aa21ca15d GIT binary patch literal 3288 zcmV;}3@7u6P)qX~Zx@jj6)*{V;uh4GoY6;roIV&zb0))S7w@;K1|J*z%)RmXIixe=-rQj@?M^y zvQJB3K<~h_Hvru{)*d^LnqPq&hOe#t81&S8VE8`FTIo|8gZ>)4^Y=KVQ1f55$Xush zf{F)ayyBPQrx+R5k0vygS{`KsI~+b67i};UAE#9OBttOur$$=UPg2XLq%oQ>R=`j{ zNUiK?jNmvfJndNQ1JtrADWE`|;odafqgL{nO$++gOk4ER)N(5c46lyP!|fQgQfEx2 zaWvB!HL2xS)PNoz1{xz*=B!5oV;l_O2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Zm&^D#%Zz3(^}B~!Vfg29qA8HT1Do#YntqPQ zt(~INrvA`yt2SfL+VHCSCGh))c^0ldVruzX29_e<#zWSD1sK2+ZsCO^oU3o-j9~!l z_QM>0Jt`N2N&W58IY{`~Q8;`DBhmx#cQ^m`7&fMn<&=MHeK>p}wN8A6bK+K!PM`pG zFp3fu6CHN<{aJdDS|22UE#c#CbuNs9Q!B+!a!)p49fJY!W?;O<;|7Qx8W&e_fu;576q`Fb9SHXSD=U=Z854{r_UJHA*PmX zQNW5U{FGatmu2AvzX{9762I3|4r-#jsy~ zrC0++xQlUnf2SHUspVOe@K)n2ra)2JTL+;oj#qB zsxY-2iyD?9-{Ot}&lf?U2v0vdRZO#OevDdvMGvgN1yezPu>^{|P9MrLwk3sRL|VoB zsumV>Ag+2ZulO;w+)4_#mu_0Bc(`n?sYAE&l1dz_BKTdyhfJNEsyaGkr z@v=%acVTsO(Ph;93Y-F90Bd*zikyp_w0x$|oz#2^OaZ)1+ATM;gW+Ai`HEhuG%TDx z0Y|>vjK=0fk=N;yQly)y`4cz|yya%*8Yn`i&*q%d2Uh;il}#<*Vu!cf%z-(aC_=|l z-sM}WSGkoUyya$QI|^X$ck}$9_di9=lfVq&EjP1o7Pph+UA~HRqC>BgsreC@1>ABo zU3!&0lbg#A#Fc!e4=gGlrshLnmhhIFK_fVm6UJDm(o@6#m{lvy`O*miLVzOI7Gn3f zCRk$QHTK?{O7JsI6NUZ0$n+^0xR+E-A}t#|bV|2slfOr|GG-uCw_kt(@HWm<8o_iF zk?){xw*Vt-(iWbN**h~ZfPaZhpAtilB3b_RPU z&-wDMlp=kBx{U%pp+l3eN@|s@NL@zNXQ setOpenModal(false)} /> diff --git a/src/components/MapSelector.js b/src/components/MapSelector.js index a89b85d..88cc77c 100644 --- a/src/components/MapSelector.js +++ b/src/components/MapSelector.js @@ -1,22 +1,49 @@ import React from "react"; -// import Mapir from "mapir-react-native-sdk"; +import MapView, { Marker } from "react-native-maps"; -// const X_API_KEY = - // "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIn0.eyJhdWQiOiIxNjk2MSIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIiwiaWF0IjoxNjQ0MzE3MDA5LCJuYmYiOjE2NDQzMTcwMDksImV4cCI6MTY0NjgyMjYwOSwic3ViIjoiIiwic2NvcGVzIjpbImJhc2ljIl19.Gckmd77Vw-wmsaztsmVmjYmfp4zXRSy2f0tXS-1p7IY8VJmvCCrk64y7WvCLbH0YfGZI9rG9ZUi5hRJDDGXu70l1ZafCYq2-EkMzcbx-PGTTq2bHGNZujF4ur1xtGoXd2kwGuldiR_6SJdqYLHcupbscFI7hHaQnkN1xWJ-L8476ZOKzUgiBvwH9uElGZXwD6SwfXoGW_R38_isrnfTXKfW9PPixyLaN3404tcjOU1r02HIurrplXlIKRKG9CVXxKsESfJJ8trwtZw6O4erxrnisxfL0VwAR7l69P6KcFb57vvM4j4hKFqxUDr4YvSq1qOTt3urYbAKehhvoiLhZxw"; +//assets +import markerIcon from "../assets/icons/marker.png"; + +export default function MapSelector({ setAddress }) { + const [markerCoordinates, setMarkerCoordinates] = React.useState({ + latitude: 35.7219, + longitude: 51.3347, + }); + const getLocation = (location) => { + setMarkerCoordinates(location); + try { + fetch( + `https://map.ir/reverse/no?lat=${location.latitude}&lon=${location.longitude}`, + { + headers: { + "Content-Type": "application/json", + "x-api-key": + "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIn0.eyJhdWQiOiIxNjk2MSIsImp0aSI6IjkyODE4ODI0N2FhMjdlYTMyMzVlYzRiOWUxZDI3NTQyZTNjYmI3ZjQzY2Q2NGQzYjdkYjU1NmY3NDM5YzU2NzUyNzMxMjAzYzMwOTliYTFiIiwiaWF0IjoxNjQ0MzE3MDA5LCJuYmYiOjE2NDQzMTcwMDksImV4cCI6MTY0NjgyMjYwOSwic3ViIjoiIiwic2NvcGVzIjpbImJhc2ljIl19.Gckmd77Vw-wmsaztsmVmjYmfp4zXRSy2f0tXS-1p7IY8VJmvCCrk64y7WvCLbH0YfGZI9rG9ZUi5hRJDDGXu70l1ZafCYq2-EkMzcbx-PGTTq2bHGNZujF4ur1xtGoXd2kwGuldiR_6SJdqYLHcupbscFI7hHaQnkN1xWJ-L8476ZOKzUgiBvwH9uElGZXwD6SwfXoGW_R38_isrnfTXKfW9PPixyLaN3404tcjOU1r02HIurrplXlIKRKG9CVXxKsESfJJ8trwtZw6O4erxrnisxfL0VwAR7l69P6KcFb57vvM4j4hKFqxUDr4YvSq1qOTt3urYbAKehhvoiLhZxw", + }, + } + ) + .then((response) => response.json()) + .then((data) => setAddress(data.address)); + } catch (err) { + console.log(err); + } + }; -export default function MapSelector() { - onRegionDidChange = (e) => {}; return ( - <> - // onRegionDidChange(e)} - // style={{ - // width : '100%', - // height : 250 - // }} - // > - // - // + getLocation(e.nativeEvent.coordinate)} + > + + ); } diff --git a/src/redux/reducers/file.js b/src/redux/reducers/file.js index 164494c..47c9dde 100644 --- a/src/redux/reducers/file.js +++ b/src/redux/reducers/file.js @@ -1,24 +1,22 @@ const initialState = { loading: false, error: null, - uploads: {}, - lastUpload: null, }; export default function file(state = initialState, action) { let { type, data, params } = action; switch (type) { case "file/upload": + console.log(data, params); return { ...state, loading: false, error: null, - uploads: { ...state.uploads, [params?.target || "last"]: data.id }, - lastUpload: data.id, }; case "file/loading": return { ...state, loading: true }; case "file/error": + console.log(error); return { ...state, loading: false, error: data.message }; default: return state; diff --git a/src/screens/Address/index.js b/src/screens/Address/index.js index 716a929..25f6141 100644 --- a/src/screens/Address/index.js +++ b/src/screens/Address/index.js @@ -23,6 +23,7 @@ import Navbar from "../../components/Navbar"; import CustomPressable from "../../components/Pressable"; import CustomTextInput from "../../components/CustomTextInput"; import Select from "../../components/Select"; +import MapSelector from "../../components/MapSelector"; //style import tw from "tailwind-rn"; @@ -551,38 +552,45 @@ const Address = ({ /> {!profilePage ? ( - + + setMapAddress(address)} + /> + + setMapAddress(text)} - placeholderTextColor={ - theme === "light" - ? Colors.theme1.gray2077 - : Colors.theme1.white + "aa" - } - /> + borderColor: + theme === "light" + ? Colors.theme1.grayE3 + : Colors.theme1.white + "55", + }, + ]} + value={mapAddress} + multiline={true} + textAlignVertical="top" + placeholder="آدرس مورد نظر ..." + onChangeText={(text) => setMapAddress(text)} + placeholderTextColor={ + theme === "light" + ? Colors.theme1.gray2077 + : Colors.theme1.white + "aa" + } + /> + ) : null} { const firstLoginFlag = await AsyncStorage.getItem("firstLogin"); if (!firstLoginFlag) { - AsyncStorage.setItem('firstLogin', JSON.stringify(true)); + AsyncStorage.setItem("firstLogin", JSON.stringify(true)); setTimeout(() => { props.start(); }, 800); @@ -145,5 +145,4 @@ const mapDispatchToProps = { setFirstLogin: publicApi.setFirstLogin, }; - export default connect(mapStateToProps, mapDispatchToProps)(Home); diff --git a/src/screens/Profile/components/User.js b/src/screens/Profile/components/User.js index a1138af..575ff98 100644 --- a/src/screens/Profile/components/User.js +++ b/src/screens/Profile/components/User.js @@ -2,6 +2,7 @@ import { View, Text, Platform, Pressable, Dimensions } from "react-native"; import * as ImagePicker from "expo-image-picker"; import React from "react"; import { connect } from "react-redux"; +import { file } from "../../../redux/actions"; import { useNavigation } from "@react-navigation/native"; //components @@ -16,7 +17,7 @@ import Colors from "../../../constants/Colors"; const ios = Platform.OS === "ios"; const { width } = Dimensions.get("window"); -const User = ({ user, mobile, theme }) => { +const User = ({ user, mobile, theme, upload }) => { const [dropdown, setDropdown] = React.useState(true); const [image, setImage] = React.useState(null); const navigation = useNavigation(); @@ -30,6 +31,10 @@ const User = ({ user, mobile, theme }) => { quality: 1, }); + console.log(result); + + upload(result); + if (!result.cancelled) { setImage(result.uri); } @@ -158,4 +163,8 @@ const mapStateToProps = (state) => ({ theme: state.publicApi.theme, }); -export default connect(mapStateToProps)(User); +const mapDispatchToProps = { + upload: file.upload, +}; + +export default connect(mapStateToProps, mapDispatchToProps)(User); diff --git a/yarn.lock b/yarn.lock index 67c7a49..ee87a9e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1051,11 +1051,6 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@expo-google-fonts/noto-sans@^0.2.0": - version "0.2.0" - resolved "https://registry.yarnpkg.com/@expo-google-fonts/noto-sans/-/noto-sans-0.2.0.tgz#e5bb0d73235e963d318d38b859c3470aa197ab58" - integrity sha512-Qk9goIvIQxAF0FRHSpw63smmp0uGBKmcRdhIqI4SvJNYEomQzH/Xzy5MA5MJanh/UhYx9KnyaidSH6FiJLLXeg== - "@expo/config-plugins@3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@expo/config-plugins/-/config-plugins-3.1.0.tgz#0752ff33c5eab21cf42034a44e79df97f0f867f8" @@ -1676,6 +1671,11 @@ dependencies: "@turf/helpers" "^6.5.0" +"@types/geojson@^7946.0.7": + version "7946.0.8" + resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.8.tgz#30744afdb385e2945e22f3b033f897f76b1f12ca" + integrity sha512-1rkryxURpr6aWP7R786/UQOkJ3PcpQiWkAXBmdWc7ryFWqN6a4xfK7BtjXvFBKO9LjQ+MWQSWxYeZX1OApnArA== + "@types/graceful-fs@^4.1.2": version "4.1.5" resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.5.tgz#21ffba0d98da4350db64891f92a9e5db3cdb4e15" @@ -5574,6 +5574,13 @@ react-native-iphone-x-helper@^1.3.0: resolved "https://registry.yarnpkg.com/react-native-iphone-x-helper/-/react-native-iphone-x-helper-1.3.1.tgz#20c603e9a0e765fd6f97396638bdeb0e5a60b010" integrity sha512-HOf0jzRnq2/aFUcdCJ9w9JGzN3gdEg0zFE4FyYlp4jtidqU03D5X7ZegGKfT1EWteR0gPBGp9ye5T5FvSWi9Yg== +react-native-maps@0.29.4: + version "0.29.4" + resolved "https://registry.yarnpkg.com/react-native-maps/-/react-native-maps-0.29.4.tgz#eb4a446104ed2aca5361422d06712f26d4c0d562" + integrity sha512-Td2KE8+KODcHOxfB1GBNnzFo4/89rlLiC7yTvqQZh0tGVrEzIcgSleUZRrjtq/WvSWSR4rql4AS+0VsBgDkYrw== + dependencies: + "@types/geojson" "^7946.0.7" + react-native-openanything@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/react-native-openanything/-/react-native-openanything-0.0.6.tgz#7b694a28ce6de0363d46474ab3c72f5c0d14e658"