Skip to content

Commit

Permalink
chore: replace placeholder buttons (#292)
Browse files Browse the repository at this point in the history
* chore: fixed placeholder buttons

* chore: translations

* chore:translations

* chore: reset nav state after project invite
  • Loading branch information
ErikSin authored Apr 25, 2024
1 parent ec280d4 commit e2f9d19
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
3 changes: 3 additions & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,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
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 e2f9d19

Please sign in to comment.