-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[friends-native] 카카오톡 친구 추가 기능 반영 (#159)
Co-authored-by: woohm402 <[email protected]>
- Loading branch information
Showing
21 changed files
with
373 additions
and
106 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
apps/friends-react-native/src/app/assets/icons/user-hashtag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
apps/friends-react-native/src/app/components/Icons/Kakaotalk.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Icon from '../../assets/icons/kakaotalk.svg'; | ||
import { createIconComponent } from './_createIconComponent'; | ||
|
||
export const KakaotalkIcon = createIconComponent(Icon); |
4 changes: 4 additions & 0 deletions
4
apps/friends-react-native/src/app/components/Icons/UserHashtagIcon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import Icon from '../../assets/icons/user-hashtag.svg'; | ||
import { createIconComponent } from './_createIconComponent'; | ||
|
||
export const UserHashtagIcon = createIconComponent(Icon); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
apps/friends-react-native/src/app/queries/useRequestFriendToken.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { useServiceContext } from '../contexts/ServiceContext'; | ||
|
||
export const useRequestFriendToken = () => { | ||
const { friendService } = useServiceContext(); | ||
|
||
return useQuery({ | ||
queryKey: ['requestFriendToken'] as const, | ||
queryFn: () => friendService.generateToken(), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...pp/screens/MainScreen/RequestFriendsBottomSheetContent/RequestFriendsMethodList/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { StyleSheet, View } from 'react-native'; | ||
|
||
import { Typography } from '../../../../components/Typography'; | ||
import { TouchableOpacity } from 'react-native-gesture-handler'; | ||
import { UserHashtagIcon } from '../../../../components/Icons/UserHashtagIcon'; | ||
import { useThemeContext } from '../../../../contexts/ThemeContext'; | ||
import { KakaotalkIcon } from '../../../../components/Icons/Kakaotalk'; | ||
import { RequestFriendModalStep, useMainScreenContext } from '../..'; | ||
import { useRequestFriendToken } from '../../../../queries/useRequestFriendToken'; | ||
import { useServiceContext } from '../../../../contexts/ServiceContext'; | ||
|
||
export const RequestFriendsMethodList = () => { | ||
const { dispatch } = useMainScreenContext(); | ||
const { nativeEventService } = useServiceContext(); | ||
const { data } = useRequestFriendToken(); | ||
const iconColor = useThemeContext((theme) => theme.color.text.default); | ||
|
||
const setRequestFriendModalStep = (step: RequestFriendModalStep) => | ||
dispatch({ | ||
type: 'setRequestFriendModalStep', | ||
requestFriendModalStep: step, | ||
}); | ||
|
||
const requestFriendWithKakao = () => { | ||
const parameters = { | ||
requestToken: data!.requestToken, | ||
}; | ||
|
||
nativeEventService.sendEventToNative({ | ||
type: 'add-friend-kakao', | ||
parameters, | ||
}); | ||
|
||
dispatch({ | ||
type: 'setRequestFriendModalOpen', | ||
isOpen: false, | ||
}); | ||
}; | ||
|
||
return ( | ||
<> | ||
<View style={styles.sheetContent}> | ||
<TouchableOpacity style={styles.sheetItem} onPress={requestFriendWithKakao}> | ||
<KakaotalkIcon | ||
width={30} | ||
height={30} | ||
style={{ | ||
color: iconColor, | ||
}} | ||
/> | ||
<Typography>카카오톡으로 친구 초대</Typography> | ||
</TouchableOpacity> | ||
</View> | ||
<View style={styles.sheetContent}> | ||
<TouchableOpacity style={styles.sheetItem} onPress={() => setRequestFriendModalStep('REQUEST_WITH_NICKNAME')}> | ||
<UserHashtagIcon | ||
width={30} | ||
height={30} | ||
style={{ | ||
color: iconColor, | ||
}} | ||
/> | ||
<Typography>닉네임으로 친구 초대</Typography> | ||
</TouchableOpacity> | ||
</View> | ||
</> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
sheetContent: { paddingBottom: 20 }, | ||
sheetItem: { | ||
height: 50, | ||
paddingVertical: 10, | ||
display: 'flex', | ||
flexDirection: 'row', | ||
gap: 25, | ||
alignItems: 'center', | ||
}, | ||
}); |
90 changes: 90 additions & 0 deletions
90
.../screens/MainScreen/RequestFriendsBottomSheetContent/RequestFriendsWithNickname/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { Alert } from 'react-native'; | ||
import { StyleSheet, View } from 'react-native'; | ||
|
||
import { get } from '../../../../../utils/get'; | ||
import { BottomSheet } from '../../../../components/BottomSheet'; | ||
import { WarningIcon } from '../../../../components/Icons/WarningIcon'; | ||
import { Input } from '../../../../components/Input'; | ||
import { Typography } from '../../../../components/Typography'; | ||
import { COLORS } from '../../../../styles/colors'; | ||
import { useMainScreenContext, useRequestFriend } from '../..'; | ||
import { useServiceContext } from '../../../../contexts/ServiceContext'; | ||
import { useThemeContext } from '../../../../contexts/ThemeContext'; | ||
|
||
export const RequestFriendsWithNickname = () => { | ||
const { requestFriendModalNickname, dispatch } = useMainScreenContext(); | ||
const { friendService } = useServiceContext(); | ||
const guideEnabledColor = useThemeContext((data) => data.color.text.guide); | ||
const { mutate: request } = useRequestFriend(); | ||
|
||
const isValid = friendService.isValidNicknameTag(requestFriendModalNickname); | ||
const guideMessageState = requestFriendModalNickname === '' ? 'disabled' : isValid ? 'hidden' : 'enabled'; | ||
|
||
const closeAddFriendModal = () => dispatch({ type: 'setRequestFriendModalOpen', isOpen: false }); | ||
|
||
return ( | ||
<View style={styles.modalContent}> | ||
<BottomSheet.Header | ||
left={{ text: '취소', onPress: closeAddFriendModal }} | ||
right={{ | ||
text: '요청 보내기', | ||
onPress: () => | ||
request(requestFriendModalNickname, { | ||
onSuccess: () => { | ||
Alert.alert('친구에게 요청을 보냈습니다.'); | ||
closeAddFriendModal(); | ||
}, | ||
onError: (err) => { | ||
const displayMessage = get(err, ['displayMessage']); | ||
Alert.alert(displayMessage ? `${displayMessage}` : '오류가 발생했습니다.'); | ||
}, | ||
}), | ||
disabled: !isValid, | ||
}} | ||
/> | ||
<Typography variant="description" style={styles.inputDescription}> | ||
추가하고 싶은 친구의 닉네임 | ||
</Typography> | ||
<Input | ||
style={styles.input} | ||
autoFocus | ||
value={requestFriendModalNickname} | ||
onChange={(e) => dispatch({ type: 'setRequestFriendModalNickname', nickname: e })} | ||
placeholder="예) 홍길동#1234" | ||
/> | ||
<View style={styles.guide}> | ||
{guideMessageState !== 'hidden' && | ||
(() => { | ||
const color = { enabled: guideEnabledColor, disabled: COLORS.gray40 }[guideMessageState]; | ||
return ( | ||
<> | ||
<WarningIcon width={18} height={18} style={{ color }} /> | ||
<Typography variant="description" style={{ ...styles.guideText, color }}> | ||
닉네임 전체를 입력하세요 | ||
</Typography> | ||
</> | ||
); | ||
})()} | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
questionIconButton: { flexDirection: 'row', alignItems: 'center', gap: 6 }, | ||
questionIcon: { color: COLORS.gray30 }, | ||
modalContent: { paddingBottom: 30 }, | ||
inputDescription: { marginTop: 30, fontSize: 14 }, | ||
input: { marginTop: 15 }, | ||
guide: { | ||
marginTop: 7, | ||
display: 'flex', | ||
flexDirection: 'row', | ||
gap: 1, | ||
alignItems: 'center', | ||
height: 12, | ||
}, | ||
guideText: { fontSize: 12 }, | ||
hamburgerWrapper: { position: 'relative' }, | ||
hamburgerNotificationDot: { position: 'absolute', top: 5, right: -1 }, | ||
}); |
16 changes: 16 additions & 0 deletions
16
...riends-react-native/src/app/screens/MainScreen/RequestFriendsBottomSheetContent/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useMainScreenContext } from '..'; | ||
import { BottomSheet } from '../../../components/BottomSheet'; | ||
import { RequestFriendsMethodList } from './RequestFriendsMethodList'; | ||
import { RequestFriendsWithNickname } from './RequestFriendsWithNickname'; | ||
|
||
export const RequestFriendsBottomSheetContent = () => { | ||
const { isRequestFriendModalOpen, requestFriendModalStep, dispatch } = useMainScreenContext(); | ||
|
||
const closeAddFriendModal = () => dispatch({ type: 'setRequestFriendModalOpen', isOpen: false }); | ||
|
||
return ( | ||
<BottomSheet isOpen={isRequestFriendModalOpen} onClose={closeAddFriendModal}> | ||
{requestFriendModalStep === 'METHOD_LIST' ? <RequestFriendsMethodList /> : <RequestFriendsWithNickname />} | ||
</BottomSheet> | ||
); | ||
}; |
Oops, something went wrong.