Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
docimin committed Jun 10, 2024
1 parent da67a49 commit be34efa
Show file tree
Hide file tree
Showing 26 changed files with 3,382 additions and 8 deletions.
63 changes: 55 additions & 8 deletions app/friends/(tabs)/map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ import * as Sentry from '@sentry/react-native'
import { formatDate } from '~/components/calculateTimeLeft'
import { Avatar, AvatarFallback, AvatarImage } from '~/components/ui/avatar'
import { useUser } from '~/components/contexts/UserContext'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,

Check warning on line 43 in app/friends/(tabs)/map.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused import specifier AlertDialogTrigger

Check warning on line 43 in app/friends/(tabs)/map.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: 'AlertDialogTrigger' is defined but never used. (@typescript-eslint/no-unused-vars)
} from '~/components/ui/alert-dialog'
import { Button } from '~/components/ui/button'

Check warning on line 45 in app/friends/(tabs)/map.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused import { Button } from '\~/components/ui/button'

Check warning on line 45 in app/friends/(tabs)/map.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: 'Button' is defined but never used. (@typescript-eslint/no-unused-vars)

export default function FriendLocationsPage() {
const user = useUser()
Expand All @@ -42,6 +54,8 @@ export default function FriendLocationsPage() {
const [friendsLocations, setFriendsLocations] = useState(null)
const [refreshing, setRefreshing] = useState<boolean>(false)
const [currentEvent, setCurrentEvent] = useState(null)
const [modalOpen, setModalOpen] = useState<boolean>(false)
const [modalAccepted, setModalAccepted] = useState<boolean>(false)
const [filters, setFilters] = useState({

Check warning on line 59 in app/friends/(tabs)/map.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: 'filters' is assigned a value but never used. (@typescript-eslint/no-unused-vars)

Check warning on line 59 in app/friends/(tabs)/map.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: 'setFilters' is assigned a value but never used. (@typescript-eslint/no-unused-vars)

Check warning on line 59 in app/friends/(tabs)/map.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused local symbol

Unused constant setFilters

Check warning on line 59 in app/friends/(tabs)/map.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused local symbol

Unused constant filters
showEvents: true,
showFriends: true,
Expand Down Expand Up @@ -106,8 +120,10 @@ export default function FriendLocationsPage() {
useEffect(() => {
let watcher = null
const startWatching = async () => {
let { status } = await Location.requestForegroundPermissionsAsync()
if (status === 'granted') {
let { status } = await Location.getForegroundPermissionsAsync()
if (status !== 'granted') {
setModalOpen(true)
} else {
watcher = await Location.watchPositionAsync(
{
accuracy: Location.Accuracy.High,
Expand All @@ -120,13 +136,15 @@ export default function FriendLocationsPage() {
)
}
}
startWatching().then()
if (modalAccepted) {
startWatching().then()
}
return () => {
if (watcher) {
watcher.remove()
}
}
}, [])
}, [modalAccepted])

const handleLocationButtonPress = () => {
if (userLocation) {
Expand Down Expand Up @@ -163,7 +181,6 @@ export default function FriendLocationsPage() {
(response) => {
const eventType = response.events[0].split('.').pop()
const updatedDocument: any = response.payload
console.log(updatedDocument)

switch (eventType) {
case 'update':
Expand Down Expand Up @@ -203,6 +220,36 @@ export default function FriendLocationsPage() {
<Text>Loading...</Text>
</View>
)}
{modalOpen && (
<AlertDialog onOpenChange={setModalOpen} open={modalOpen}>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Headpat needs permission</AlertDialogTitle>
<AlertDialogDescription>
Headpat requires your location to show you on the map. You can
always change this later in your settings.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel onPress={() => setModalOpen(false)}>
<Text>Cancel</Text>
</AlertDialogCancel>
<AlertDialogAction
onPress={async () => {
let { status } =
await Location.requestForegroundPermissionsAsync()
if (status === 'granted') {
setModalAccepted(true)
}
setModalOpen(false)
}}
>
<Text>Continue</Text>
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)}
<Dialog>
<DialogContent>
<DialogTitle>{currentEvent?.title}</DialogTitle>
Expand Down Expand Up @@ -301,7 +348,7 @@ export default function FriendLocationsPage() {
<FilterIcon size={24} color={'black'} />
</TouchableOpacity>
</View>
{userLocation && (
{userLocation && Platform.OS === 'ios' && (
<View style={styles.locationButton}>
<TouchableOpacity
className={
Expand Down Expand Up @@ -360,14 +407,14 @@ const styles = StyleSheet.create({
},
locationButton: {
position: 'absolute',
bottom: 70,
bottom: 20,
right: 10,
borderRadius: 50,
overflow: 'hidden',
},
filterButton: {
position: 'absolute',
top: 10,
top: 60,
right: 10,
borderRadius: 50,
overflow: 'hidden',
Expand Down
30 changes: 30 additions & 0 deletions ios/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
.xcode.env.local

# Bundle artifacts
*.jsbundle

# CocoaPods
/Pods/
11 changes: 11 additions & 0 deletions ios/.xcode.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This `.xcode.env` file is versioned and is used to source the environment
# used when running script phases inside Xcode.
# To customize your local environment, you can create an `.xcode.env.local`
# file that is not versioned.

# NODE_BINARY variable contains the PATH to the node executable.
#
# Customize the NODE_BINARY variable here.
# For example, to use nvm with brew, add the following line
# . "$(brew --prefix nvm)/nvm.sh" --no-use
export NODE_BINARY=$(command -v node)
Loading

0 comments on commit be34efa

Please sign in to comment.