Skip to content

Commit

Permalink
Merge branch 'main' of github.com:digidem/CoMapeo-mobile into feat/sa…
Browse files Browse the repository at this point in the history
…ve-track
  • Loading branch information
bohdanprog committed Apr 28, 2024
2 parents 358aa50 + 8fceead commit 1817157
Show file tree
Hide file tree
Showing 7 changed files with 724 additions and 10 deletions.
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,9 @@
"sharedComponents.ProjectInviteBottomSheet.goToMap": {
"message": "Go To Map"
},
"sharedComponents.ProjectInviteBottomSheet.goToSync": {
"message": "Go To Sync"
},
"sharedComponents.ProjectInviteBottomSheet.invitedToJoin": {
"message": "You've been invited to join {projName}"
},
Expand Down
5 changes: 4 additions & 1 deletion src/frontend/hooks/persistedState/usePersistedLocale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ type LocaleSlice = {
};

const localeSlice: StateCreator<LocaleSlice> = (set, get) => ({
locale: getSupportedLocale(getLocales()[0].languageTag) || 'en',
// We can use this non-null assertion with `getLocales()` because, according
// to [the docs][1], the result is "guaranteed to contain at least 1 element."
// [1]: https://github.com/expo/expo/blob/5585320eec9271038cd7c672b4cf9f0e945ca658/packages/expo-localization/src/Localization.ts#L123
locale: getSupportedLocale(getLocales()[0]!.languageTag) || 'en',
setLocale: newlocale => set({locale: newlocale}),
});

Expand Down
5 changes: 1 addition & 4 deletions src/frontend/screens/ObservationsList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ const m = defineMessages({

const OBSERVATION_CELL_HEIGHT = 80;

const getItemLayout = (
data: Observation[] | null | undefined,
index: number,
) => ({
const getItemLayout = (_data: unknown, index: number) => ({
length: OBSERVATION_CELL_HEIGHT,
offset: OBSERVATION_CELL_HEIGHT * index,
index,
Expand Down
4 changes: 1 addition & 3 deletions src/frontend/screens/PresetChooser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export const PresetChooser: NativeNavigationComponent<'PresetChooser'> = ({
const state = navigation.getState();
const currentIndex = state.index;
const routes = state.routes;
const prevRouteNameInStack = !routes[currentIndex - 1]
? undefined
: routes[currentIndex - 1].name;
const prevRouteNameInStack = routes[currentIndex - 1]?.name;

React.useLayoutEffect(() => {
navigation.setOptions({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ export const ProjectCreated = ({
);
}

//This resets the navigation so the user cannot press back and return to this screen
function handleGoToInviteScreen() {
navigation.dispatch(state => {
const index = state.routes.findIndex(r => r.name === 'Settings');
const routes = [
...state.routes.slice(0, index + 1),
{name: 'YourTeam'},
{name: 'SelectDevice'},
];

return CommonActions.reset({
...state,
routes,
index: routes.length - 1,
});
});
}

return (
<View style={styles.container}>
<View style={{alignItems: 'center'}}>
Expand All @@ -64,7 +82,7 @@ export const ProjectCreated = ({
</Text>
</View>
<View style={{width: '100%'}}>
<Button fullWidth variant="outlined" onPress={() => {}}>
<Button fullWidth variant="outlined" onPress={handleGoToInviteScreen}>
{t(m.inviteDevice)}
</Button>
<Button style={{marginTop: 20}} fullWidth onPress={handleGoToMap}>
Expand Down
23 changes: 22 additions & 1 deletion src/frontend/sharedComponents/ProjectInviteBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {LIGHT_GREY} from '../lib/styles';
import {View} from 'react-native';
import {useProjectInvite} from '../hooks/useProjectInvite';
import {useNavigationFromRoot} from '../hooks/useNavigationWithTypes';
import {useNavigationState} from '@react-navigation/native';
import {CommonActions, useNavigationState} from '@react-navigation/native';
import {isEditingScreen} from '../lib/utils';

const m = defineMessages({
Expand Down Expand Up @@ -43,6 +43,10 @@ const m = defineMessages({
id: 'sharedComponents.ProjectInviteBottomSheet.youHaveJoined',
defaultMessage: 'You have joined {projName}',
},
goToSync: {
id: 'sharedComponents.ProjectInviteBottomSheet.goToSync',
defaultMessage: 'Go To Sync',
},
});

export const ProjectInviteBottomSheet = () => {
Expand All @@ -62,6 +66,15 @@ export const ProjectInviteBottomSheet = () => {
openSheet();
}

function handleGoToSync() {
navigation.dispatch(
CommonActions.reset({
index: 1,
routes: [{name: 'Home'}, {name: 'Sync'}],
}),
);
}

return (
<BottomSheetModal ref={sheetRef} isOpen={isOpen} onDismiss={resetState}>
{accept.isSuccess ? (
Expand All @@ -76,6 +89,14 @@ export const ProjectInviteBottomSheet = () => {
},
text: formatMessage(m.goToMap),
},
{
onPress: () => {
handleGoToSync();
closeSheet();
},
text: formatMessage(m.goToSync),
variation: 'filled',
},
]}
title={formatMessage(m.success)}
description={formatMessage(m.youHaveJoined, {
Expand Down

0 comments on commit 1817157

Please sign in to comment.