Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/tracking impl #257

Merged
merged 89 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
77245ee
wip nav changes to allow displaying modal without changing screen
CDFN Apr 11, 2024
2ba1cea
add custom tab bar icon and label
bohdanprog Apr 11, 2024
733746e
add modal with different options
bohdanprog Apr 11, 2024
6bd0461
tracks poc
CDFN Apr 12, 2024
1f597d7
add check if permission granted, add function to request about permis…
bohdanprog Apr 12, 2024
bef576b
add animation, add function for check permission disable strart track…
bohdanprog Apr 12, 2024
d9dfbde
wip nav changes to allow displaying modal without changing screen
CDFN Apr 11, 2024
9620c12
add custom tab bar icon and label
bohdanprog Apr 11, 2024
1d8da9e
add modal with different options
bohdanprog Apr 11, 2024
7245fe7
tracks poc
CDFN Apr 12, 2024
8773faf
add check if permission granted, add function to request about permis…
bohdanprog Apr 12, 2024
dfa1791
add animation, add function for check permission disable strart track…
bohdanprog Apr 12, 2024
dee33fd
fixed problem with custom modal
bohdanprog Apr 12, 2024
94db2fa
merged
bohdanprog Apr 12, 2024
5e338f7
fix hooks dependencies, user location flick
CDFN Apr 12, 2024
e145973
cleanup
CDFN Apr 12, 2024
5cfeb75
place observations exactly at track line
CDFN Apr 12, 2024
8d398c5
store observations found on track
CDFN Apr 12, 2024
82b5c5c
add check if foreground permission is granted, add gps indicator
bohdanprog Apr 15, 2024
d3c53ea
move gps indicator to map header
bohdanprog Apr 15, 2024
9d125b0
create custom bottom sheet component with clicalbe backdrop
bohdanprog Apr 15, 2024
f1b7ede
add icon to start tracking and stop tracking button
bohdanprog Apr 15, 2024
804f42b
fix hooks dependencies, user location flick
CDFN Apr 12, 2024
d56b2b5
cleanup
CDFN Apr 12, 2024
02bab4b
place observations exactly at track line
CDFN Apr 12, 2024
f8b2a3a
store observations found on track
CDFN Apr 12, 2024
b35b1ec
add check if foreground permission is granted, add gps indicator
bohdanprog Apr 15, 2024
577c6db
move gps indicator to map header
bohdanprog Apr 15, 2024
07f8662
fix bug where observations don't display when there's no tracking line
CDFN Apr 12, 2024
44aae30
cleanup track store naming
CDFN Apr 15, 2024
41c3dd5
extract track layer to separate component
CDFN Apr 15, 2024
ce07f72
correct imports, remove unused ones
CDFN Apr 15, 2024
07aab30
implement user location tooltip
CDFN Apr 15, 2024
b1effbe
Merge remote-tracking branch 'origin/feat/tracking-impl' into feat/tr…
CDFN Apr 15, 2024
39abc58
path drawing fixes
CDFN Apr 16, 2024
a2119fb
add timer indicator to stop tracking modal
bohdanprog Apr 16, 2024
1018be7
Merge branch 'main' of github.com:digidem/CoMapeo-mobile into feat/tr…
bohdanprog Apr 16, 2024
f806152
add show timer indicator in bottom tab bar
bohdanprog Apr 16, 2024
8505add
Merge branch 'feat/tracking-impl' of github.com:digidem/CoMapeo-mobil…
bohdanprog Apr 16, 2024
a5fa8b6
remove tab bar label, changed tabbar height
bohdanprog Apr 16, 2024
c2d4080
save only required data for track path drawing
CDFN Apr 16, 2024
e8172db
move TrackPathLayer to track folder
CDFN Apr 16, 2024
d8327d6
move task definition to different place
CDFN Apr 16, 2024
7d6b48d
fix layers order
CDFN Apr 16, 2024
86ceb3a
create context where we keep timer data
bohdanprog Apr 16, 2024
75728e5
Merge branch 'feat/tracking-impl' of github.com:digidem/CoMapeo-mobil…
bohdanprog Apr 16, 2024
7033d6e
extract types from store to common types
CDFN Apr 16, 2024
5593ed2
pre-review cleanups
CDFN Apr 16, 2024
915f28e
add comment explaining distance calc algo
CDFN Apr 16, 2024
56a0d18
correct import
CDFN Apr 16, 2024
465ea18
use luxon for duration formatting
CDFN Apr 16, 2024
eb40ca0
fix eslint rule
CDFN Apr 16, 2024
d15f719
add translations to gps modal
bohdanprog Apr 16, 2024
2c5eccd
Merge branch 'feat/tracking-impl' of github.com:digidem/CoMapeo-mobil…
bohdanprog Apr 16, 2024
815c42c
add changes to en.json
bohdanprog Apr 16, 2024
d36f508
changed GPS pill
bohdanprog Apr 16, 2024
ed9ce3a
add enum type with tab names,changes check in navigation listener
bohdanprog Apr 16, 2024
312bf28
set default route name to navigation store, use enum names in tabs name
bohdanprog Apr 17, 2024
03d0933
add test case for calculate distance function, rename varialbes
bohdanprog Apr 17, 2024
adba278
changed gps pill padding
bohdanprog Apr 17, 2024
9d28264
using in setCurrentTab function enum
bohdanprog Apr 17, 2024
6fa47da
update calculate distance function
bohdanprog Apr 17, 2024
2b1e4ee
remove comment
bohdanprog Apr 17, 2024
2c7da91
fix problem with timing calculation
bohdanprog Apr 17, 2024
9d5f7e4
improve typing a bit
CDFN Apr 16, 2024
19f4ab9
add shared location context
CDFN Apr 18, 2024
fe1d388
fix problem with gps modal and tab screen
bohdanprog Apr 18, 2024
ebec3c1
change place where we get locaiton, using react.memo to memorize trac…
bohdanprog Apr 18, 2024
213b61d
add back rounding of gps precision
CDFN Apr 18, 2024
328e4c6
code quality improvement
CDFN Apr 19, 2024
c73ebda
use cheap-ruler instead own distance calc
CDFN Apr 22, 2024
b4f92a4
Use ellipsis symbol instead triple dot
CDFN Apr 22, 2024
cfc9ab7
add header to tab navigator, fixed problem with navigator in homeHead…
bohdanprog Apr 22, 2024
998808a
rename gpsModal to GPSPermissionModal also renamed other connected co…
bohdanprog Apr 22, 2024
4dfc34d
Merge branch 'main' of github.com:digidem/CoMapeo-mobile into feat/tr…
bohdanprog Apr 23, 2024
255f590
fixed problem with dependency in useTracking hook
bohdanprog Apr 23, 2024
719a83f
Apply review suggestions
CDFN Apr 23, 2024
063f160
remove irrelevant changes to navigation
CDFN Apr 23, 2024
119bf56
rename store from useNvigatorStore to useTabNvigatorStore
bohdanprog Apr 23, 2024
44e0872
Merge branch 'feat/tracking-impl' of github.com:digidem/CoMapeo-mobil…
bohdanprog Apr 23, 2024
b9b5f28
restore changes with GPSPill
bohdanprog Apr 23, 2024
4aef7bc
rename gps components
bohdanprog Apr 23, 2024
22bbfdf
remove unnecessary props isFocused
bohdanprog Apr 24, 2024
ea50a90
remove navigation cast type to as never, add navigation types
bohdanprog Apr 24, 2024
09c3bc3
fixed timer nulable case
bohdanprog Apr 24, 2024
c0283c5
rebase to main
bohdanprog Apr 24, 2024
da725cb
add another solution to track timer
bohdanprog Apr 24, 2024
d440271
add feature flag for track
bohdanprog Apr 24, 2024
f3a63f4
fix order of babel plugins
CDFN Apr 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Required for react-native-zeroconf -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
12 changes: 11 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{
"name": "CoMapeo",
"plugins": ["expo-localization", "expo-secure-store"]
"plugins": [
"expo-localization",
"expo-secure-store",
[
"expo-location",
{
"isIosBackgroundLocationEnabled": true,
"isAndroidBackgroundLocationEnabled": true
}
]
]
}
21 changes: 21 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,27 @@
"description": "Title of dialog that shows when cancelling a new observation",
"message": "Discard observation?"
},
"Modal.GPSDisable.button": {
"message": "Enable"
},
"Modal.GPSDisable.description": {
"message": "To create a Track CoMapeo needs access to your location and GPS."
},
"Modal.GPSDisable.title": {
"message": "GPS Disabled"
},
"Modal.GPSEnable.button.default": {
"message": "Start Tracks"
},
"Modal.GPSEnable.button.loading": {
"message": "Loading…"
},
"Modal.GPSEnable.button.stop": {
"message": "Stop Tracks"
},
"Modal.GPSEnable.trackingDescription": {
"message": "You’ve been recording for"
},
"Screens.Settings.AppSettings.coordinateSystem": {
"message": "Coordinate System"
},
Expand Down
49 changes: 45 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@react-navigation/native-stack": "^6.9.13",
"@rnmapbox/maps": "^10.1.16",
"@tanstack/react-query": "^5.12.2",
"@types/luxon": "^3.4.2",
"assert": "^2.0.0",
"buffer": "^6.0.3",
"cheap-ruler": "^3.0.2",
Expand All @@ -47,10 +48,13 @@
"expo-camera": "~14.0.5",
"expo-crypto": "~12.8.1",
"expo-localization": "~14.8.3",
"expo-location": "~16.5.4",
"expo-location": "~16.5.5",
"expo-secure-store": "~12.8.1",
"expo-sensors": "~12.9.1",
"expo-task-manager": "~11.7.2",
"geojson": "^0.5.0",
"lodash.isequal": "^4.5.0",
"luxon": "^3.4.4",
"nanoid": "^5.0.1",
"nodejs-mobile-react-native": "^18.17.7",
"react": "18.2.0",
Expand Down
87 changes: 52 additions & 35 deletions src/frontend/Navigation/ScreenGroups/AppScreens.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {
BottomTabNavigationProp,
createBottomTabNavigator,
} from '@react-navigation/bottom-tabs';
import {NavigatorScreenParams} from '@react-navigation/native';
import * as React from 'react';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import {useForegroundPermissions} from 'expo-location';

import {HomeHeader} from '../../sharedComponents/HomeHeader';
import {RootStack} from '../AppStack';
import {MessageDescriptor} from 'react-intl';
Expand Down Expand Up @@ -50,15 +50,20 @@ import {
GpsModal,
createNavigationOptions as createGpsModalNavigationOptions,
} from '../../screens/GpsModal';
import {useLocation} from '../../hooks/useLocation';
import {useLocationProviderStatus} from '../../hooks/useLocationProviderStatus';
import {getLocationStatus} from '../../lib/utils';
import {useCurrentTab} from '../../hooks/useCurrentTab';
import {TrackingTabBarIcon} from './TabBar/TrackingTabBarIcon';
import {TabName} from '../types';
import {CameraTabBarIcon} from './TabBar/CameraTabBarIcon';
import {MapTabBarIcon} from './TabBar/MapTabBarIcon';
import {InviteDeclined} from '../../screens/Settings/ProjectSettings/YourTeam/InviteDeclined';
import {UnableToCancelInvite} from '../../screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/UnableToCancelInvite';

export const TAB_BAR_HEIGHT = 70;

export type HomeTabsList = {
Map: undefined;
Camera: undefined;
Tracking: undefined;
};

type InviteProps = {
Expand Down Expand Up @@ -136,42 +141,54 @@ export type AppList = {
const Tab = createBottomTabNavigator<HomeTabsList>();

const HomeTabs = () => {
const locationState = useLocation({maxDistanceInterval: 0});
const [permissions] = useForegroundPermissions();
const locationProviderStatus = useLocationProviderStatus();

const precision = locationState.location?.coords.accuracy;

const locationStatus =
!!locationState.error || !permissions?.granted
? 'error'
: getLocationStatus({
location: locationState.location,
providerStatus: locationProviderStatus,
});
const {handleTabPress} = useCurrentTab();

return (
<Tab.Navigator
screenListeners={{
tabPress: handleTabPress,
}}
screenOptions={({route}) => ({
tabBarIcon: ({color}) => {
const iconName = route.name === 'Map' ? 'map' : 'photo-camera';
return <MaterialIcons name={iconName} size={30} color={color} />;
},
header: () => (
<HomeHeader
locationStatus={locationStatus}
precision={
typeof precision === 'number' ? Math.round(precision) : undefined
}
/>
),
tabBarStyle: {height: TAB_BAR_HEIGHT},
tabBarShowLabel: false,
headerTransparent: true,
tabBarTestID: 'tabBarButton' + route.name,
header: HomeHeader,
})}
initialRouteName="Map"
initialRouteName={TabName.Map}
backBehavior="initialRoute">
<Tab.Screen name="Map" component={MapScreen} />
<Tab.Screen name="Camera" component={CameraScreen} />
<Tab.Screen
name={TabName.Map}
component={MapScreen}
options={{
tabBarIcon: MapTabBarIcon,
}}
/>
<Tab.Screen
name={TabName.Camera}
component={CameraScreen}
options={{
tabBarIcon: CameraTabBarIcon,
}}
/>
<Tab.Screen
name={TabName.Tracking}
options={{
tabBarIcon: TrackingTabBarIcon,
headerShown: false,
}}
listeners={({
navigation,
}: {
navigation: BottomTabNavigationProp<HomeTabsList>;
}) => ({
tabPress: e => {
e.preventDefault();
navigation.navigate(TabName.Map);
},
})}
children={() => <></>}
/>
</Tab.Navigator>
);
};
Expand Down
16 changes: 16 additions & 0 deletions src/frontend/Navigation/ScreenGroups/TabBar/CameraTabBarIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, {FC} from 'react';
import {TabBarIconProps, TabName} from '../../types';
import {TabBarIcon} from './TabBarIcon';
import {useTabNavigationStore} from '../../../hooks/useTabNavigationStore.ts';

export const CameraTabBarIcon: FC<TabBarIconProps> = props => {
const {currentTab} = useTabNavigationStore();

return (
<TabBarIcon
{...props}
isFocused={props.focused && currentTab !== TabName.Tracking}
bohdanprog marked this conversation as resolved.
Show resolved Hide resolved
iconName="photo-camera"
/>
);
};
16 changes: 16 additions & 0 deletions src/frontend/Navigation/ScreenGroups/TabBar/MapTabBarIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, {FC} from 'react';
import {TabBarIconProps, TabName} from '../../types';
import {TabBarIcon} from './TabBarIcon';
import {useTabNavigationStore} from '../../../hooks/useTabNavigationStore.ts';

export const MapTabBarIcon: FC<TabBarIconProps> = props => {
const {currentTab} = useTabNavigationStore();

return (
<TabBarIcon
{...props}
isFocused={props.focused && currentTab !== TabName.Tracking}
bohdanprog marked this conversation as resolved.
Show resolved Hide resolved
iconName="map"
/>
);
};
19 changes: 19 additions & 0 deletions src/frontend/Navigation/ScreenGroups/TabBar/TabBarIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, {FC} from 'react';
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
import {TabBarIconProps} from '../../types';
import {COMAPEO_BLUE, MEDIUM_GREY} from '../../../lib/styles';

export interface TabBarIcon extends TabBarIconProps {
isFocused: boolean;
iconName: string;
}

export const TabBarIcon: FC<TabBarIcon> = ({size, iconName, isFocused}) => {
return (
<MaterialIcons
name={iconName}
size={size}
color={isFocused ? COMAPEO_BLUE : MEDIUM_GREY}
/>
);
};
bohdanprog marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading