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 0000000..c4ac791 Binary files /dev/null and b/src/assets/icons/marker.png differ diff --git a/src/components/Avatar.js b/src/components/Avatar.js index 70a0a21..c60e093 100644 --- a/src/components/Avatar.js +++ b/src/components/Avatar.js @@ -80,7 +80,7 @@ function Avatar({ source, size, theme, action }) { style={tw("mr-2 absolute top-4 right-2")} size={24} color={ - theme === "light" ? Colors.theme1.green79 : Colors.theme1.white + theme === "light" ? Colors.theme1.white : Colors.theme1.white } onPress={() => 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"