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

fix: delete map shows confirmation twice #845

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions src/frontend/lib/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export const DARK_ORANGE = '#E86826';
export const SYNC_BACKGROUND = '#2348B2';
export const GPS_MODAL_TEXT = 'rgb(40,40,40)';
export const DARK_GREEN = '#59A553';
export const WARNING_RED = '#D92222';
36 changes: 19 additions & 17 deletions src/frontend/screens/Settings/MapManagement/BackgroundMaps.tsx
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you replace the < Text/> components in the file?

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import ErrorSvg from '../../../images/Error.svg';
import GreenCheckSvg from '../../../images/GreenCheck.svg';
import noop from '../../../lib/noop';
import {DARK_GREY, RED, WHITE} from '../../../lib/styles';
import {RED, WHITE} from '../../../lib/styles';
import {
BottomSheetModal,
BottomSheetModalContent,
Expand All @@ -23,7 +23,8 @@ import {
import {Button} from '../../../sharedComponents/Button';
import {ErrorBottomSheet} from '../../../sharedComponents/ErrorBottomSheet';
import {Loading} from '../../../sharedComponents/Loading';
import {Text} from '../../../sharedComponents/Text';
import {HeaderText} from '../../../sharedComponents/Text/HeaderText';
import {BodyText} from '../../../sharedComponents/Text/BodyText';
import {type NativeRootNavigationProps} from '../../../sharedTypes/navigation';
import {ChooseMapFile} from './ChooseMapFile';
import {CustomMapDetails} from './CustomMapDetails';
Expand Down Expand Up @@ -130,10 +131,12 @@ export function BackgroundMapsScreen() {
return (
<>
<ScrollView contentContainerStyle={styles.container}>
<Text style={styles.aboutText}>{t(m.about)}</Text>
<HeaderText variant="header2" style={styles.aboutText}>
{t(m.about)}
</HeaderText>
<View style={styles.descriptionContainer}>
<Text>{t(m.description1)}</Text>
<Text>{t(m.description2)}</Text>
<BodyText>{t(m.description1)}</BodyText>
<BodyText>{t(m.description2)}</BodyText>
</View>

<CustomMapInfoSection
Expand Down Expand Up @@ -172,18 +175,20 @@ export function BackgroundMapsScreen() {

{customMapInfoQuery.status === 'error' && (
<>
<Text style={styles.infoLoadErrorText}>
<BodyText variant="large" style={styles.infoLoadErrorText}>
{t(m.customMapInfoLoadError)}
</Text>
</BodyText>
<Button
fullWidth
variant="outlined"
onPress={() => {
removeCustomMapMutation.mutate();
}}>
<Text style={styles.removeMapFileButtonText}>
<HeaderText
variant="header5"
style={styles.removeMapFileButtonText}>
{t(m.removeMapFile)}
</Text>
</HeaderText>
</Button>
</>
)}
Expand All @@ -206,8 +211,11 @@ export function BackgroundMapsScreen() {
text: t(m.deleteMapButtonText),
icon: <MaterialIcon size={30} name="delete" color={WHITE} />,
onPress: () => {
removeCustomMapMutation.mutate();
removeMapBottomSheet.closeSheet();
removeCustomMapMutation.mutate(undefined, {
onSuccess: () => {
removeMapBottomSheet.closeSheet();
},
});
},
},
{
Expand Down Expand Up @@ -322,22 +330,16 @@ const styles = StyleSheet.create({
},
aboutText: {
textAlign: 'center',
fontWeight: 'bold',
fontSize: 36,
color: DARK_GREY,
},
infoLoadErrorText: {
textAlign: 'center',
color: RED,
fontSize: 20,
},
removeMapFileButton: {
backgroundColor: RED,
},
removeMapFileButtonText: {
fontWeight: '700',
letterSpacing: 0.5,
fontSize: 18,
color: RED,
},
});
24 changes: 13 additions & 11 deletions src/frontend/screens/Settings/MapManagement/ChooseMapFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React from 'react';
import {defineMessages, useIntl} from 'react-intl';
import {StyleSheet, View} from 'react-native';

import {MEDIUM_GREY, RED} from '../../../lib/styles';
import {NEW_DARK_GREY, RED} from '../../../lib/styles';
import {Button} from '../../../sharedComponents/Button';
import {Text} from '../../../sharedComponents/Text';
import {DownloadIcon} from '../../../sharedComponents/icons';
import {HeaderText} from '../../../sharedComponents/Text/HeaderText';
import {BodyText} from '../../../sharedComponents/Text/BodyText';

const m = defineMessages({
chooseFile: {
Expand All @@ -27,14 +28,19 @@ export function ChooseMapFile({onChooseFile}: {onChooseFile: () => void}) {
<View style={styles.buttonContentContainer}>
<DownloadIcon size={24} />
<View>
<Text style={styles.buttonTextBase}>
<HeaderText variant="header5" style={styles.buttonTextBase}>
{t(m.chooseFile)}
<Text style={styles.asteriskText}> *</Text>
</Text>
<HeaderText variant="header5" style={styles.asteriskText}>
{' '}
*
</HeaderText>
</HeaderText>
</View>
</View>
</Button>
<Text style={styles.fileTypeText}>{t(m.acceptedFileTypes)}</Text>
<BodyText variant="smallMeta" style={styles.fileTypeText}>
{t(m.acceptedFileTypes)}
</BodyText>
</View>
);
}
Expand All @@ -49,17 +55,13 @@ const styles = StyleSheet.create({
gap: 12,
},
buttonTextBase: {
fontWeight: '700',
letterSpacing: 0.5,
fontSize: 18,
},
asteriskText: {
fontSize: 18,
color: RED,
},
fileTypeText: {
color: MEDIUM_GREY,
fontSize: 14,
textAlign: 'center',
color: NEW_DARK_GREY,
},
});
44 changes: 26 additions & 18 deletions src/frontend/screens/Settings/MapManagement/CustomMapDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@ import {StyleSheet, View} from 'react-native';
import {TouchableOpacity} from 'react-native-gesture-handler';

import {bytesToMegabytes} from '../../../lib/bytesToMegabytes';
import {BLACK, MEDIUM_GREY, RED, VERY_LIGHT_GREY} from '../../../lib/styles';
import {
BLACK,
NEW_DARK_GREY,
WARNING_RED,
VERY_LIGHT_GREY,
} from '../../../lib/styles';
import {Loading} from '../../../sharedComponents/Loading';
import {Text} from '../../../sharedComponents/Text';
import {BodyText} from '../../../sharedComponents/Text/BodyText';
import {HeaderText} from '../../../sharedComponents/Text/HeaderText';

const m = defineMessages({
mapNameColumn: {
Expand Down Expand Up @@ -53,34 +59,40 @@ export function CustomMapDetails({
return (
<View style={styles.rootContainer}>
<View style={styles.columnHeadersContainer}>
<Text style={styles.columnTitleText}>{t(m.mapNameColumn)}</Text>
<Text style={styles.columnTitleText}>{t(m.dateAddedColumn)}</Text>
<BodyText variant="smallMeta" style={styles.columnTitleText}>
{t(m.mapNameColumn)}
</BodyText>
<BodyText variant="smallMeta" style={styles.columnTitleText}>
{t(m.dateAddedColumn)}
</BodyText>
</View>
<View style={styles.cardContainer}>
<View style={styles.cardRow}>
<View style={styles.columnLeft}>
<Text style={styles.nameText}>{name}</Text>
<Text style={styles.sizeText}>
<HeaderText variant="header5">{name}</HeaderText>
<BodyText variant="smallMeta" style={styles.sizeText}>
{displayedSize !== undefined &&
t(m.sizeInMegabytes, {
value: displayedSize,
})}
</Text>
</BodyText>
</View>
<View style={styles.columnRight}>
<Text style={styles.dateAddedText}>
<BodyText variant="smallMeta" style={styles.dateAddedText}>
<FormattedDate
year="numeric"
month="short"
day="2-digit"
value={dateAdded}
/>
</Text>
</BodyText>
</View>
</View>
<View style={styles.cardRow}>
<TouchableOpacity onPress={onRemove} hitSlop={20}>
<Text style={styles.removeMapText}>{t(m.removeMap)}</Text>
<BodyText variant="smallMeta" style={styles.removeMapText}>
{t(m.removeMap)}
</BodyText>
</TouchableOpacity>
</View>
{loading && <LoadingOverlay />}
Expand Down Expand Up @@ -119,21 +131,17 @@ const styles = StyleSheet.create({
justifyContent: 'space-between',
},
columnTitleText: {
color: MEDIUM_GREY,
color: NEW_DARK_GREY,
},
dateAddedText: {
color: MEDIUM_GREY,
color: NEW_DARK_GREY,
},
sizeText: {
color: MEDIUM_GREY,
color: NEW_DARK_GREY,
},
removeMapText: {
fontWeight: 'bold',
color: RED,
},
nameText: {
fontWeight: 'bold',
fontSize: 18,
color: WARNING_RED,
},
columnLeft: {
flex: 1,
Expand Down
Loading