Added hasIpAddress display. Fixed Unknown User name for non-gmail users

This commit is contained in:
2024-08-16 15:31:16 +08:00
parent b9c382eaa8
commit 6a00ec453d
2 changed files with 12 additions and 1 deletions

View File

@@ -81,6 +81,9 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
const isShorteningService = details.shorteningService === 'Yes'; const isShorteningService = details.shorteningService === 'Yes';
const classification = details.classifications || 'Unknown'; const classification = details.classifications || 'Unknown';
// New state to check if the URL contains an IP address
const hasIpAddress = details.hasIpAddress || '';
// Function to get security text and icon based on the URL description // Function to get security text and icon based on the URL description
const getSecurityStatus = () => { const getSecurityStatus = () => {
if (data.info?.description === "Secure Uniform Resource Locator") { if (data.info?.description === "Secure Uniform Resource Locator") {
@@ -250,6 +253,10 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
{isShorteningService && ( {isShorteningService && (
<Text style={styles.shorteningServiceText}>This is a shortening service</Text> <Text style={styles.shorteningServiceText}>This is a shortening service</Text>
)} )}
{/* Conditionally display the IP address message */}
{hasIpAddress && (
<Text style={styles.shorteningServiceText}>{hasIpAddress}</Text>
)}
</View> </View>
</View> </View>
@@ -554,6 +561,7 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
); );
}; };
const styles = StyleSheet.create({ const styles = StyleSheet.create({
// Row styles // Row styles
row: { row: {

View File

@@ -148,6 +148,9 @@ const SettingsScreen: React.FC = () => {
]); ]);
}; };
const userName = userAttributes?.name || (userEmail ? userEmail.split('@')[0] : 'Unknown User');
return ( return (
<View style={styles.container}> <View style={styles.container}>
<Text style={styles.header}>Settings</Text> <Text style={styles.header}>Settings</Text>
@@ -156,7 +159,7 @@ const SettingsScreen: React.FC = () => {
<View style={styles.section}> <View style={styles.section}>
<View style={styles.profileContainer}> <View style={styles.profileContainer}>
<Ionicons name="person-circle" size={60} color="#f41c87" style={styles.profileIcon} /> <Ionicons name="person-circle" size={60} color="#f41c87" style={styles.profileIcon} />
<Text style={styles.userName}>Hello, {userAttributes?.name || 'Unknown User'}</Text> <Text style={styles.userName}>Hello, {userName}</Text>
</View> </View>
{userAttributes ? ( {userAttributes ? (
<TouchableOpacity style={styles.logoutButton} onPress={handleSignOut}> <TouchableOpacity style={styles.logoutButton} onPress={handleSignOut}>