Skip to content

Commit e084880

Browse files
committed
feat(settings): display dynamic app version (with build number) using expo-constants
1 parent 876c5f5 commit e084880

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/settings.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { IconSymbol, IconSymbolName } from '@/components/ui/IconSymbol';
22
import { Colors, getThemeColors, Spacing, Typography } from '@/constants/DesignSystem';
33
import { useStorage } from '@/contexts/StorageContext';
44
import { useTheme } from '@/contexts/ThemeContext';
5+
import Constants from 'expo-constants';
56
import { router } from 'expo-router';
67
import React, { useState } from 'react';
78
import { Alert, ScrollView, StatusBar, StyleSheet, Switch, Text, TouchableOpacity, View } from 'react-native';
@@ -113,6 +114,12 @@ export default function SettingsScreen() {
113114
}
114115
};
115116

117+
const getAppVersion = () => {
118+
const version = Constants.expoConfig?.version || '1.0.0';
119+
const buildNumber = Constants.expoConfig?.ios?.buildNumber || Constants.expoConfig?.android?.versionCode;
120+
return buildNumber ? `${version} (${buildNumber})` : version;
121+
};
122+
116123
return (
117124
<SafeAreaView style={[styles.container, { backgroundColor: colors.background.primary }]} edges={['top']}>
118125
<StatusBar barStyle={isDark ? 'light-content' : 'dark-content'} backgroundColor="transparent" translucent />
@@ -189,7 +196,7 @@ export default function SettingsScreen() {
189196
<SettingItem
190197
icon={'info.circle' as any}
191198
title="App Version"
192-
subtitle="1.0.0"
199+
subtitle={getAppVersion()}
193200
colors={colors}
194201
showChevron={false}
195202
/>

0 commit comments

Comments
 (0)