-
Notifications
You must be signed in to change notification settings - Fork 38
feat(settings): weight and temperature unit preferences #2595
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
Changes from all commits
c3a4061
7b941e9
f45c9f5
738a3b4
ee31156
09d1387
c44cfd5
9b60acc
5216be9
2ed9f6b
7c3162b
d147a99
677cd27
dc0406b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { ActivityIndicator, Text } from '@packrat/ui/nativewindui'; | ||
| import { ActivityIndicator, SegmentedControl, Text } from '@packrat/ui/nativewindui'; | ||
| import AsyncStorage from '@react-native-async-storage/async-storage'; | ||
| import * as Burnt from 'burnt'; | ||
| import { appAlert } from 'expo-app/app/_layout'; | ||
|
|
@@ -17,9 +17,13 @@ import { | |
| } from 'expo-app/features/ai/lib/localModelManager'; | ||
| import { DeleteAccountButton } from 'expo-app/features/auth/components/DeleteAccountButton'; | ||
| import { useAuth } from 'expo-app/features/auth/hooks/useAuth'; | ||
| import { useSpeedUnit } from 'expo-app/features/auth/hooks/useSpeedUnit'; | ||
| import { useTemperatureUnit } from 'expo-app/features/auth/hooks/useTemperatureUnit'; | ||
| import { useWeightUnit } from 'expo-app/features/auth/hooks/useWeightUnit'; | ||
| import { useSeasonSuggestionsPrefs } from 'expo-app/features/packs/atoms/seasonSuggestionsAtoms'; | ||
| import { useColorScheme } from 'expo-app/lib/hooks/useColorScheme'; | ||
| import { useTranslation } from 'expo-app/lib/hooks/useTranslation'; | ||
| import { testIds } from 'expo-app/lib/testIds'; | ||
| import ImageCacheManager from 'expo-app/lib/utils/ImageCacheManager'; | ||
| import Constants from 'expo-constants'; | ||
| import { useRouter } from 'expo-router'; | ||
|
|
@@ -37,6 +41,9 @@ export default function SettingsScreen() { | |
|
|
||
| const router = useRouter(); | ||
| const { announcementSeen, setAnnouncementSeen, opened, setOpened } = useSeasonSuggestionsPrefs(); | ||
| const { unit: weightUnit, setWeightUnit } = useWeightUnit(); | ||
| const { unit: temperatureUnit, setTemperatureUnit } = useTemperatureUnit(); | ||
| const { unit: speedUnit, setSpeedUnit } = useSpeedUnit(); | ||
|
|
||
| const isApple = isAppleIntelligenceAvailable(); | ||
| const isDownloading = modelStatus === 'downloading'; | ||
|
|
@@ -100,6 +107,64 @@ export default function SettingsScreen() { | |
| style={Platform.OS === 'ios' ? 'light' : colorScheme === 'dark' ? 'light' : 'dark'} | ||
| /> | ||
|
|
||
| <View> | ||
| <Text variant="subhead" className="mb-3"> | ||
| {t('settings.displayUnits')} | ||
| </Text> | ||
| <View className="rounded-xl border border-border bg-card"> | ||
| <View className="flex-row items-center justify-between p-4"> | ||
| <View className="flex-1"> | ||
| <Text className="font-medium">Weight</Text> | ||
| <Text variant="footnote" className="mt-0.5 text-muted-foreground"> | ||
| {t('settings.weightSubtitle')} | ||
| </Text> | ||
| </View> | ||
| <View className="w-28"> | ||
| <SegmentedControl | ||
| testID={testIds.settings.weightUnitControl} | ||
| values={['kg', 'lb']} | ||
| selectedIndex={weightUnit === 'kg' ? 0 : 1} | ||
| onIndexChange={(index) => setWeightUnit(index === 0 ? 'kg' : 'lb')} | ||
| /> | ||
| </View> | ||
| </View> | ||
| <View className="h-px bg-border mx-4" /> | ||
| <View className="flex-row items-center justify-between p-4"> | ||
| <View className="flex-1"> | ||
| <Text className="font-medium">Temperature</Text> | ||
| <Text variant="footnote" className="mt-0.5 text-muted-foreground"> | ||
| {t('settings.temperatureSubtitle')} | ||
| </Text> | ||
| </View> | ||
| <View className="w-28"> | ||
| <SegmentedControl | ||
| testID={testIds.settings.temperatureUnitControl} | ||
| values={['°C', '°F']} | ||
| selectedIndex={temperatureUnit === 'C' ? 0 : 1} | ||
| onIndexChange={(index) => setTemperatureUnit(index === 0 ? 'C' : 'F')} | ||
| /> | ||
| </View> | ||
| </View> | ||
| <View className="h-px bg-border mx-4" /> | ||
| <View className="flex-row items-center justify-between p-4"> | ||
| <View className="flex-1"> | ||
| <Text className="font-medium">Wind & Distance</Text> | ||
| <Text variant="footnote" className="mt-0.5 text-muted-foreground"> | ||
| {t('settings.windDistanceSubtitle')} | ||
| </Text> | ||
| </View> | ||
| <View className="w-36"> | ||
| <SegmentedControl | ||
| testID={testIds.settings.speedUnitControl} | ||
| values={['km/h', 'mph']} | ||
| selectedIndex={speedUnit === 'kmh' ? 0 : 1} | ||
| onIndexChange={(index) => setSpeedUnit(index === 0 ? 'kmh' : 'mph')} | ||
| /> | ||
| </View> | ||
| </View> | ||
| </View> | ||
| </View> | ||
|
Comment on lines
+110
to
+166
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win Add internationalization for new UI strings to maintain consistency. The new "Display Units" section hardcodes English strings ( Add translation keys and use 🌐 Suggested i18n integration <View>
- <Text variant="subhead" className="mb-3">
- Display Units
- </Text>
+ <Text variant="subhead" className="mb-3">
+ {t('settings.displayUnits')}
+ </Text>
<View className="rounded-xl border border-border bg-card">
<View className="flex-row items-center justify-between p-4">
<View className="flex-1">
- <Text className="font-medium">Weight</Text>
+ <Text className="font-medium">{t('settings.weight')}</Text>
- <Text variant="footnote" className="mt-0.5 text-muted-foreground">
- Shown on pack totals and items
- </Text>
+ <Text variant="footnote" className="mt-0.5 text-muted-foreground">
+ {t('settings.weightDescription')}
+ </Text>
</View>
{/* ... */}
</View>
{/* ... */}
<View className="flex-row items-center justify-between p-4">
<View className="flex-1">
- <Text className="font-medium">Temperature</Text>
+ <Text className="font-medium">{t('settings.temperature')}</Text>
- <Text variant="footnote" className="mt-0.5 text-muted-foreground">
- Shown in weather forecasts
- </Text>
+ <Text variant="footnote" className="mt-0.5 text-muted-foreground">
+ {t('settings.temperatureDescription')}
+ </Text>
</View>
{/* ... */}
</View>
</View>
</View>Add corresponding keys to your translation files (e.g., {
"settings": {
"displayUnits": "Display Units",
"weight": "Weight",
"weightDescription": "Shown on pack totals and items",
"temperature": "Temperature",
"temperatureDescription": "Shown in weather forecasts"
}
}🤖 Prompt for AI Agents |
||
|
|
||
| <View> | ||
| <Text variant="subhead" className="mb-3"> | ||
| {t('ai.modelManagement')} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internationalize the main unit labels for consistency.
The subtitles now use
t()for i18n, but the main labels ("Weight","Temperature","Wind & Distance") are still hardcoded English. This creates an inconsistency within the Display Units section.🌐 Complete the i18n integration
Add corresponding keys to your translation file (e.g.,
apps/expo/lib/i18n/locales/en.json):{ "settings": { "weight": "Weight", "temperature": "Temperature", "windDistance": "Wind & Distance" } }Also applies to: 134-134, 151-151
🤖 Prompt for AI Agents