Skip to content

Commit

Permalink
[#5] refactor: make profile image index start from 0
Browse files Browse the repository at this point in the history
  • Loading branch information
hee-suh committed Jun 3, 2022
1 parent c70e440 commit 0cb1170
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions react-native/screens/JoinScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ export default function JoinScreen({ navigation }: Navigation) {
// 1 3 4 5 7 10
const [joinForm, setJoinForm] = useState<JoinData>({
uid: undefined,
uprofileImg: 1,
uprofileImg: 0,
username: '',
ulanguage: '',
uchildren: colors.map(color => ({ cname: '', cprofileImg: 1, color: color?.id }))
uchildren: colors.map(color => ({ cname: '', cprofileImg: 0, color: color?.id }))
})
const [open, setOpen] = useState(-1);

Expand Down Expand Up @@ -136,8 +136,8 @@ export default function JoinScreen({ navigation }: Navigation) {
<FormControl.Label>{i18n.t('profileImage')}</FormControl.Label>
<ScrollView horizontal={true}>
{Array.from(Array(Number(7)).keys()).map((num, index) =>
<Button key={'ub_'+index} variant="unstyled" onPress={handleProfileImg(index+1)}>
<Image style={[styles.uprofileImage, joinForm.uprofileImg!==index+1 && styles.disabled]} source={uProfileImgSource[index]} />
<Button key={'ub_'+index} variant="unstyled" onPress={handleProfileImg(index)}>
<Image style={[styles.uprofileImage, joinForm.uprofileImg!==index && styles.disabled]} source={uProfileImgSource[index]} />
</Button>
)}
</ScrollView>
Expand Down Expand Up @@ -228,7 +228,7 @@ export default function JoinScreen({ navigation }: Navigation) {
trigger={triggerProps => {
return <Button {...triggerProps} variant="unstyled" onPress={() => setOpen(child)}>
{joinForm && joinForm.uchildren &&
<Image style={[styles.cprofileImage]} source={cProfileImgSource[joinForm.uchildren[child]?.cprofileImg-1]} />
<Image style={[styles.cprofileImage]} source={cProfileImgSource[joinForm.uchildren[child]?.cprofileImg]} />
}
</Button>
}}
Expand All @@ -240,9 +240,9 @@ export default function JoinScreen({ navigation }: Navigation) {
<FormControl.Label>{i18n.t('profileImage')}</FormControl.Label>
<ScrollView horizontal={true}>
{Array.from(Array(Number(9)).keys()).map((num, i) =>
<Button key={'cb_'+num} variant="unstyled" onPress={handleChildrenProfileImg(child, num+1)}>
<Button key={'cb_'+num} variant="unstyled" onPress={handleChildrenProfileImg(child, num)}>
{joinForm && joinForm.uchildren &&
<Image style={[styles.uprofileImage, joinForm?.uchildren[child]?.cprofileImg!==num+1 && styles.disabled]} source={cProfileImgSource[num]} />
<Image style={[styles.uprofileImage, joinForm?.uchildren[child]?.cprofileImg!==num && styles.disabled]} source={cProfileImgSource[num]} />
}
</Button>
)}
Expand Down
2 changes: 1 addition & 1 deletion react-native/screens/SearchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export default function SearchScreen({ navigation }: Navigation) {
<TouchableOpacity key={'n_'+index} style={[styles.childButton, {
backgroundColor: nowSelectedChildId === child.cid ? theme.colors.primary : "#ffffff",
}]} onPress={() => handleNowSelectedChildId(child.cid)}>
<Image style={styles.cprofileImage} source={cProfileImgSource[child.cprofileImg-1]} />
<Image style={styles.cprofileImage} source={cProfileImgSource[child.cprofileImg]} />
<Text fontWeight={500} style={[{
color: nowSelectedChildId !== child.cid ? theme.colors.primary : "#ffffff",
}]}>{child.cname}</Text>
Expand Down

0 comments on commit 0cb1170

Please sign in to comment.