Move location out of dialogs
This commit is contained in:
parent
f2df245878
commit
7c7f9de208
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import {View, Text } from "react-native";
|
import {View, Text } from "react-native";
|
||||||
import { useTheme } from "react-native-paper";
|
import { useTheme } from "react-native-paper";
|
||||||
import Profile from "@/components/Profile";
|
import Profile from "@/components/Profile";
|
||||||
|
import LocationScreen from "@/components/Location";
|
||||||
import Status from "@/components/Status";
|
import Status from "@/components/Status";
|
||||||
import TopNav from "@/components/TopNav";
|
import TopNav from "@/components/TopNav";
|
||||||
import DrawerMenu from "@/components/DrawerMenu";
|
import DrawerMenu from "@/components/DrawerMenu";
|
||||||
@ -63,11 +64,9 @@ const Index = () => {
|
|||||||
aboutVisible={isAboutActive}
|
aboutVisible={isAboutActive}
|
||||||
privacyVisible={isPrivacyActive}
|
privacyVisible={isPrivacyActive}
|
||||||
bugVisible={isBugActive}
|
bugVisible={isBugActive}
|
||||||
locationVisible={isLocationActive}
|
|
||||||
toggleAbout={() => setAboutActive(!isAboutActive)}
|
toggleAbout={() => setAboutActive(!isAboutActive)}
|
||||||
togglePrivacy={() => setPrivacyActive(!isPrivacyActive)}
|
togglePrivacy={() => setPrivacyActive(!isPrivacyActive)}
|
||||||
toggleBug={() => setBugActive(!isBugActive)}
|
toggleBug={() => setBugActive(!isBugActive)}
|
||||||
toggleLocation={() => setLocationActive(!isLocationActive)}
|
|
||||||
/>
|
/>
|
||||||
<TopNav
|
<TopNav
|
||||||
toggleMenu={() => setMenuActive(!isMenuActive)}
|
toggleMenu={() => setMenuActive(!isMenuActive)}
|
||||||
@ -94,6 +93,13 @@ const Index = () => {
|
|||||||
setChanged={setUserDataChanged}
|
setChanged={setUserDataChanged}
|
||||||
onClose={() => setProfileActive(false)}
|
onClose={() => setProfileActive(false)}
|
||||||
/>
|
/>
|
||||||
|
<LocationScreen
|
||||||
|
visible={isLocationActive}
|
||||||
|
setTheme={setTheme}
|
||||||
|
currentTheme={currentTheme}
|
||||||
|
setChanged={setUserDataChanged}
|
||||||
|
onClose={() => setLocationActive(false)}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -3,20 +3,18 @@ import { Portal, Button, Dialog, useTheme } from "react-native-paper";
|
|||||||
import About from "@/components/About";
|
import About from "@/components/About";
|
||||||
import Privacy from "@/components/Privacy";
|
import Privacy from "@/components/Privacy";
|
||||||
import Broken from "@/components/Broken";
|
import Broken from "@/components/Broken";
|
||||||
import Location from "@/components/Location";
|
|
||||||
|
|
||||||
interface DialogsProps {
|
interface DialogsProps {
|
||||||
aboutVisible: boolean;
|
aboutVisible: boolean;
|
||||||
privacyVisible: boolean;
|
privacyVisible: boolean;
|
||||||
bugVisible: boolean;
|
bugVisible: boolean;
|
||||||
locationVisible: boolean;
|
|
||||||
toggleAbout: () => void;
|
toggleAbout: () => void;
|
||||||
togglePrivacy: () => void;
|
togglePrivacy: () => void;
|
||||||
toggleBug: () => void;
|
toggleBug: () => void;
|
||||||
toggleLocation: () => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Dialogs: React.FC<DialogsProps> = ({ aboutVisible, privacyVisible, bugVisible, locationVisible, toggleAbout, togglePrivacy, toggleBug, toggleLocation }) => {
|
const Dialogs: React.FC<DialogsProps> = ({ aboutVisible, privacyVisible, bugVisible, toggleAbout, togglePrivacy, toggleBug }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
return (
|
return (
|
||||||
<Portal>
|
<Portal>
|
||||||
@ -56,18 +54,6 @@ const Dialogs: React.FC<DialogsProps> = ({ aboutVisible, privacyVisible, bugVisi
|
|||||||
</Button>
|
</Button>
|
||||||
</Dialog.Actions>
|
</Dialog.Actions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<Dialog visible={locationVisible} onDismiss={() => toggleLocation()}
|
|
||||||
style={{backgroundColor: theme.colors.primaryContainer}}>
|
|
||||||
<Dialog.Title style={{color: theme.colors.primary, textAlign: 'center'}}>Location</Dialog.Title>
|
|
||||||
<Location />
|
|
||||||
<Dialog.Actions style={{justifyContent: "center"}}>
|
|
||||||
<Button onPress={() => toggleLocation()} mode="contained"
|
|
||||||
style={{backgroundColor: theme.colors.inversePrimary}}
|
|
||||||
labelStyle={{color: theme.colors.primary}}>
|
|
||||||
Close
|
|
||||||
</Button>
|
|
||||||
</Dialog.Actions>
|
|
||||||
</Dialog>
|
|
||||||
</Portal>
|
</Portal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,19 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { Dialog, TextInput, useTheme, Button, Text, List } from "react-native-paper";
|
import {Dialog, TextInput, useTheme, Button, Text, List, Portal} from "react-native-paper";
|
||||||
import { View, FlatList } from "react-native";
|
import { View, FlatList } from "react-native";
|
||||||
import Slider from "@react-native-community/slider";
|
import Slider from "@react-native-community/slider";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import * as Location from "expo-location";
|
import * as Location from "expo-location";
|
||||||
import log from "@/util/log";
|
import log from "@/util/log";
|
||||||
|
|
||||||
|
interface LocationScreenProps {
|
||||||
|
visible: boolean;
|
||||||
|
setChanged: (dataChanged: boolean) => void;
|
||||||
|
setTheme: (theme: string) => void;
|
||||||
|
currentTheme: string;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
export const API_URL = process.env.EXPO_PUBLIC_API_URL;
|
export const API_URL = process.env.EXPO_PUBLIC_API_URL;
|
||||||
const BUTTON_WIDTH = 260;
|
const BUTTON_WIDTH = 260;
|
||||||
|
|
||||||
@ -20,7 +28,7 @@ type Park = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const LocationComponent = () => {
|
const LocationScreen: React.FC<LocationScreenProps> = ({ visible, setTheme, currentTheme, setChanged, onClose }) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [zip, setZip] = useState("");
|
const [zip, setZip] = useState("");
|
||||||
const [distance, setDistance] = useState(25);
|
const [distance, setDistance] = useState(25);
|
||||||
@ -99,20 +107,19 @@ const LocationComponent = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<Portal>
|
||||||
|
<Dialog visible={visible}
|
||||||
|
onDismiss={() => {
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
|
style={{ backgroundColor: theme.colors.background }}>
|
||||||
|
<Dialog.Title style={{color: theme.colors.primary, textAlign: 'center'}}>Location</Dialog.Title>
|
||||||
<Dialog.Content style={{ maxHeight: 500, justifyContent: "center", alignItems: "center" }}>
|
<Dialog.Content style={{ maxHeight: 500, justifyContent: "center", alignItems: "center" }}>
|
||||||
<View style={{ alignItems: "center", width: "100%" }}>
|
<View style={{ alignItems: "center", width: "100%" }}>
|
||||||
<Button
|
<Button mode="outlined" onPress={handleGetLocation} loading={locLoading} disabled={locLoading}
|
||||||
mode="outlined"
|
style={{ marginBottom: 12, width: BUTTON_WIDTH }}>Use My Location</Button>
|
||||||
onPress={handleGetLocation}
|
|
||||||
loading={locLoading}
|
|
||||||
disabled={locLoading}
|
|
||||||
style={{ marginBottom: 12, width: BUTTON_WIDTH }}
|
|
||||||
>
|
|
||||||
Use My Location
|
|
||||||
</Button>
|
|
||||||
<Text style={{ marginBottom: 12, color: theme.colors.primary, fontWeight: "bold" }}>OR</Text>
|
<Text style={{ marginBottom: 12, color: theme.colors.primary, fontWeight: "bold" }}>OR</Text>
|
||||||
<View
|
<View style={{
|
||||||
style={{
|
|
||||||
flexDirection: "row",
|
flexDirection: "row",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
width: BUTTON_WIDTH,
|
width: BUTTON_WIDTH,
|
||||||
@ -194,7 +201,9 @@ const LocationComponent = () => {
|
|||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
</Dialog.Content>
|
</Dialog.Content>
|
||||||
|
</Dialog>
|
||||||
|
</Portal>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default LocationComponent;
|
export default LocationScreen;
|
||||||
|
Loading…
Reference in New Issue
Block a user