Untitled
unknown
plain_text
a year ago
4.0 kB
5
Indexable
// import React, { useState, useEffect } from "react";
// import {
// View,
// Text,
// StyleSheet,
// TextInput,
// Button,
// Alert,
// ActivityIndicator,
// } from "react-native";
// import MapView, { Marker } from "react-native-maps";
// import * as Location from "expo-location";
// const AddAddressScreen = ({ route, navigation }) => {
// const addAddress = route?.params?.addAddress;
// const [location, setLocation] = useState(null);
// const [region, setRegion] = useState(null);
// const [loading, setLoading] = useState(true);
// const [details, setDetails] = useState({
// house: "",
// street: "",
// landmark: "",
// label: "",
// });
// useEffect(() => {
// (async () => {
// let { status } = await Location.requestForegroundPermissionsAsync();
// if (status !== "granted") {
// Alert.alert("Permission Denied", "Location permission is required.");
// setLoading(false);
// return;
// }
// let userLocation = await Location.getCurrentPositionAsync({});
// setRegion({
// latitude: userLocation.coords.latitude,
// longitude: userLocation.coords.longitude,
// latitudeDelta: 0.01,
// longitudeDelta: 0.01,
// });
// setLocation({
// latitude: userLocation.coords.latitude,
// longitude: userLocation.coords.longitude,
// });
// setLoading(false);
// })();
// }, []);
// const handleSave = () => {
// if (!location || !details.house || !details.street) {
// Alert.alert("Error", "Please fill in all required fields.");
// return;
// }
// const newAddress = {
// latitude: location.latitude,
// longitude: location.longitude,
// details,
// };
// console.log(newAddress);
// // addAddress(newAddress);
// navigation.goBack();
// };
// if (loading) {
// return (
// <View style={styles.loadingContainer}>
// <ActivityIndicator size="large" color="#000" />
// <Text>Loading map...</Text>
// </View>
// );
// }
// return (
// <View style={styles.container}>
// <MapView
// style={styles.map}
// initialRegion={region}
// onRegionChangeComplete={(reg) => {
// setLocation({ latitude: reg.latitude, longitude: reg.longitude });
// setRegion(reg);
// }}
// >
// {location && <Marker coordinate={location} />}
// </MapView>
// <View style={styles.form}>
// <TextInput
// placeholder="House Number"
// style={styles.input}
// onChangeText={(text) => setDetails({ ...details, house: text })}
// />
// <TextInput
// placeholder="Street"
// style={styles.input}
// onChangeText={(text) => setDetails({ ...details, street: text })}
// />
// <TextInput
// placeholder="Landmark (Optional)"
// style={styles.input}
// onChangeText={(text) => setDetails({ ...details, landmark: text })}
// />
// <TextInput
// placeholder="Type (Optional)"
// style={styles.input}
// onChangeText={(text) => setDetails({ ...details, label: text })}
// />
// <Button title="Save Address" onPress={handleSave} />
// </View>
// </View>
// );
// };
// const styles = StyleSheet.create({
// container: {
// flex: 1,
// },
// map: {
// flex: 1,
// },
// form: {
// padding: 16,
// backgroundColor: "#fff",
// },
// input: {
// borderWidth: 1,
// borderColor: "#ccc",
// padding: 10,
// marginBottom: 10,
// borderRadius: 4,
// },
// loadingContainer: {
// flex: 1,
// justifyContent: "center",
// alignItems: "center",
// },
// });
// export default AddAddressScreen;
Editor is loading...
Leave a Comment