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: update header with new UI #312

Merged
merged 7 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 11 additions & 5 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@
"description": "Button on dialog to keep editing (cancelling close action)",
"message": "Continue editing"
},
"AppContainer.EditHeader.discardChangesContent": {
"description": "Button on dialog to cancel observation edits",
"AppContainer.EditHeader.discardChangesButton": {
"description": "Title of dialog that shows when cancelling observation edits",
"message": "Discard changes"
},
"AppContainer.EditHeader.discardChangesDescription": {
"message": "Your changes will not be saved. This cannot be undone."
},
"AppContainer.EditHeader.discardChangesTitle": {
"description": "Title of dialog that shows when cancelling observation edits",
"message": "Discard changes?"
},
"AppContainer.EditHeader.discardContent": {
"description": "Button on dialog to cancel a new observation",
"message": "Discard without saving"
"AppContainer.EditHeader.discardObservationButton": {
"description": "Title of dialog that shows when cancelling observation edits",
"message": "Discard Observation"
},
"AppContainer.EditHeader.discardObservationDescription": {
"message": "Your Observation will not be saved. This cannot be undone."
},
"AppContainer.EditHeader.discardTitle": {
"description": "Title of dialog that shows when cancelling a new observation",
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/images/CheckMark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/frontend/screens/ObservationEdit/SaveButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import debug from 'debug';
import {defineMessages, useIntl} from 'react-intl';

import {IconButton} from '../../sharedComponents/IconButton';
import {SaveIcon} from '../../sharedComponents/icons/SaveIcon';
import {useNavigationFromRoot} from '../../hooks/useNavigationWithTypes';
import {usePersistedDraftObservation} from '../../hooks/persistedState/usePersistedDraftObservation';
import {useCreateObservation} from '../../hooks/server/observations';
Expand All @@ -14,6 +13,7 @@ import {useCreateBlobMutation} from '../../hooks/server/media';
import {DraftPhoto, Photo} from '../../contexts/PhotoPromiseContext/types';
import {useDraftObservation} from '../../hooks/useDraftObservation';
import {useCurrentTrackStore} from '../../hooks/tracks/useCurrentTrackStore';
import SaveCheck from '../../images/CheckMark.svg';

const m = defineMessages({
noGpsTitle: {
Expand Down Expand Up @@ -241,7 +241,7 @@ export const SaveButton = ({
</View>
) : (
<IconButton onPress={handleSavePress} testID="saveButton">
<SaveIcon inprogress={false} />
<SaveCheck />
</IconButton>
);
};
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/screens/ObservationEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export const ObservationEdit: NativeNavigationComponent<'ObservationEdit'> & {
navigation.navigate('AddPhoto');
}, [navigation]);

const handleDetailsPress = React.useCallback(() => {
navigation.navigate('ObservationDetails', {question: 1});
}, [navigation]);
// const handleDetailsPress = React.useCallback(() => {
// navigation.navigate('ObservationDetails', {question: 1});
// }, [navigation]);
Comment on lines -59 to +61
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be added really soon, so just commented out for linting purposes


const bottomSheetItems = [
{
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/screens/PresetChooser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const PresetChooser: NativeNavigationComponent<'PresetChooser'> = ({
<CustomHeaderLeftClose headerBackButtonProps={props} />
),
});
}, [prevRouteNameInStack, CustomHeaderLeft, CustomHeaderLeftClose]);
}, [prevRouteNameInStack, navigation]);

const presetsList = !presets
? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import {BLACK} from '../../../../lib/styles';
import {HookFormTextInput} from '../../../../sharedComponents/HookFormTextInput';
import {IconButton} from '../../../../sharedComponents/IconButton';
import {SaveIcon} from '../../../../sharedComponents/icons';
import SaveIcon from '../../../../images/CheckMark.svg';
import {useBottomSheetModal} from '../../../../sharedComponents/BottomSheetModal';
import {ErrorModal} from '../../../../sharedComponents/ErrorModal';
import {FieldRow} from './FieldRow';
Expand Down Expand Up @@ -72,14 +72,16 @@ export const EditScreen = ({
deviceName: string;
}>({defaultValues: {deviceName}});

const editDeviceInfoMutation = useEditDeviceInfo();
const {isPending, mutate} = useEditDeviceInfo();

const {isDirty: nameHasChanges} = control.getFieldState(
'deviceName',
formState,
);

const errorModal = useBottomSheetModal({openOnMount: false});
const {openSheet, sheetRef, closeSheet, isOpen} = useBottomSheetModal({
openOnMount: false,
});

React.useEffect(
function showDiscardChangesAlert() {
Expand Down Expand Up @@ -117,41 +119,30 @@ export const EditScreen = ({
return (
<IconButton
onPress={
editDeviceInfoMutation.isPending
isPending
? () => {}
: handleSubmit(async value => {
if (!nameHasChanges) {
navigation.navigate('DeviceNameDisplay');
return;
}

editDeviceInfoMutation.mutate(value.deviceName, {
mutate(value.deviceName, {
onSuccess: () =>
navigation.navigate('DeviceNameDisplay'),
onError: () => {
errorModal.openSheet();
openSheet();
},
});
})
}>
{editDeviceInfoMutation.isPending ? (
<UIActivityIndicator size={30} />
) : (
<SaveIcon />
)}
{isPending ? <UIActivityIndicator size={30} /> : <SaveIcon />}
</IconButton>
);
},
});
},
[
handleSubmit,
navigation,
editDeviceInfoMutation.mutate,
editDeviceInfoMutation.isPending,
nameHasChanges,
errorModal.openSheet,
],
[handleSubmit, navigation, isPending, mutate, nameHasChanges, openSheet],
);

return (
Expand All @@ -168,15 +159,11 @@ export const EditScreen = ({
style={{flex: 1, color: BLACK, fontSize: 16}}
showCharacterCount
autoFocus
editable={!editDeviceInfoMutation.isPending}
editable={isPending}
/>
</FieldRow>
</ScrollView>
<ErrorModal
sheetRef={errorModal.sheetRef}
closeSheet={errorModal.closeSheet}
isOpen={errorModal.isOpen}
/>
<ErrorModal sheetRef={sheetRef} closeSheet={closeSheet} isOpen={isOpen} />
</>
);
};
Expand Down
Loading
Loading