Skip to content

Commit

Permalink
Change profilePic attribute to use icon array index instead of file
Browse files Browse the repository at this point in the history
  • Loading branch information
Chuporceeta committed Sep 11, 2024
1 parent 2ed9255 commit f69348d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions client/app/screens/settings/SettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const SettingsScreen: React.FC = () => {
// settings values (will be changed later to reflect the actual settings)
const [data, setData] = useState({
displayName: "Display Name",
profilePic: require("../../../assets/icons/user/face_01.png"),
profilePicIndex: 0, // index for icons array
profileColor: "#1199ff",
notifyNewMessage: true,
darkMode: false,
Expand Down Expand Up @@ -82,7 +82,7 @@ const SettingsScreen: React.FC = () => {
<Pressable onPress={() => setProfileVisible(false)}>
<Image
style={iconStyle}
source={data.profilePic}
source={icons[data.profilePicIndex]}
/>
</Pressable>
</View>
Expand All @@ -97,7 +97,7 @@ const SettingsScreen: React.FC = () => {
<SafeAreaView style={styles.centeredView}>
<View style={styles.inputModal}>
<Text style={styles.sectionHeaderText}>{["Edit Display Name", "Edit Profile Color"][inputModal.type]}</Text>
<Text style={errorMessage==='' ? {display:"none"}: {color: "red"}}>{errorMessage}</Text>
<Text style={errorMessage==='' ? {display:"none"} : {color: "red"}}>{errorMessage}</Text>
<TextInput
defaultValue={[data.displayName, data.profileColor][inputModal.type]}
maxLength={[12, 7][inputModal.type]}
Expand All @@ -119,15 +119,15 @@ const SettingsScreen: React.FC = () => {
setData({...data, ["displayName"]: textInput});
setErrorMessage('');
} else
setErrorMessage("Please enter a display name.")
setErrorMessage("Please enter a display name.");
} else if (inputModal.type === 1){
const re = /^#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3}$/;
if (re.exec(textInput)) {
setInputModal({visible: false, type: -1});
setData({...data, ["profileColor"]: textInput});
setErrorMessage('');
} else
setErrorMessage("Please enter a valid hex code.")
setErrorMessage("Please enter a valid hex code.");
}}}
/>
</View>
Expand Down Expand Up @@ -163,8 +163,8 @@ const SettingsScreen: React.FC = () => {
<FlatList data={icons}
numColumns={6}
renderItem={icon => (
<Pressable onPress={() => setData({ ...data, ["profilePic"]: icon.item })}>
<Image style={[iconStyle, icon.item === data.profilePic ? styles.selected:{margin: 5}]}
<Pressable onPress={() => setData({ ...data, ["profilePicIndex"]: icon.index })}>
<Image style={[iconStyle, icon.index === data.profilePicIndex ? styles.selected:{margin: 5}]}
source={icon.item}/>
</Pressable>
)}>
Expand All @@ -181,7 +181,7 @@ const SettingsScreen: React.FC = () => {
<Pressable onPress={() => setProfileVisible(true)}>
<Image
style={iconStyle}
source={data.profilePic}
source={icons[data.profilePicIndex]}
/>
</Pressable>
</View>
Expand Down

0 comments on commit f69348d

Please sign in to comment.