Skip to content

Commit

Permalink
Merge pull request #12 from BOBpossible/feat/#10_LoginAPI
Browse files Browse the repository at this point in the history
Feat/#10 login api
  • Loading branch information
psh320 authored Jun 10, 2022
2 parents 53e14e8 + e6faf2c commit 15d3d16
Show file tree
Hide file tree
Showing 27 changed files with 479 additions and 95 deletions.
29 changes: 16 additions & 13 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, {useEffect, useState} from 'react';
import {RecoilRoot} from 'recoil';
import {StyleSheet, SafeAreaView, Text} from 'react-native';
import {SafeAreaProvider} from 'react-native-safe-area-context';
import {createStackNavigator} from '@react-navigation/stack';
Expand All @@ -25,19 +26,21 @@ export default function App() {
}, []);

return (
<SafeAreaProvider>
<NavigationContainer>
<Stack.Navigator screenOptions={{headerShown: false, gestureEnabled: false}}>
{loading ? (
<Stack.Screen name="Splash" component={Splash} />
) : isLogin ? (
<Stack.Screen name="MainNavigator" component={MainNavigator} />
) : (
<Stack.Screen name="AuthNavigation" component={AuthNavigator} />
)}
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
<RecoilRoot>
<SafeAreaProvider>
<NavigationContainer>
<Stack.Navigator screenOptions={{headerShown: false, gestureEnabled: false}}>
{loading ? (
<Stack.Screen name="Splash" component={Splash} />
) : isLogin ? (
<Stack.Screen name="MainNavigator" component={MainNavigator} />
) : (
<Stack.Screen name="AuthNavigation" component={AuthNavigator} />
)}
</Stack.Navigator>
</NavigationContainer>
</SafeAreaProvider>
</RecoilRoot>
);
}

Expand Down
16 changes: 9 additions & 7 deletions ios/BOB_FrontEnd.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
4F77B99D31ED4EDD94A6FFA6 /* PretendardSemiBold.woff in Resources */ = {isa = PBXBuildFile; fileRef = 683A1F4FE2FC402C8170EFFE /* PretendardSemiBold.woff */; };
529BA82781284EB3B91E5AA2 /* PretendardRegular.woff in Resources */ = {isa = PBXBuildFile; fileRef = EB6B8FCAEBCD44DA9A312D82 /* PretendardRegular.woff */; };
7699B88040F8A987B510C191 /* libPods-BOB_FrontEnd-BOB_FrontEndTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 19F6CBCC0A4E27FBF8BF4A61 /* libPods-BOB_FrontEnd-BOB_FrontEndTests.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
7B62CB6910144219AA715CC8 /* PretendardLight.woff in Resources */ = {isa = PBXBuildFile; fileRef = 709E966DA8644081BCC61B58 /* PretendardLight.woff */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
FDF04A86E4374DE48D65639E /* PretendardMedium.woff in Resources */ = {isa = PBXBuildFile; fileRef = 350FFDC1AA0E452B97F0CB21 /* PretendardMedium.woff */; };
529BA82781284EB3B91E5AA2 /* PretendardRegular.woff in Resources */ = {isa = PBXBuildFile; fileRef = EB6B8FCAEBCD44DA9A312D82 /* PretendardRegular.woff */; };
4F77B99D31ED4EDD94A6FFA6 /* PretendardSemiBold.woff in Resources */ = {isa = PBXBuildFile; fileRef = 683A1F4FE2FC402C8170EFFE /* PretendardSemiBold.woff */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -41,17 +41,17 @@
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = BOB_FrontEnd/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = BOB_FrontEnd/main.m; sourceTree = "<group>"; };
19F6CBCC0A4E27FBF8BF4A61 /* libPods-BOB_FrontEnd-BOB_FrontEndTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-BOB_FrontEnd-BOB_FrontEndTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
350FFDC1AA0E452B97F0CB21 /* PretendardMedium.woff */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = PretendardMedium.woff; path = ../src/assets/fonts/PretendardMedium.woff; sourceTree = "<group>"; };
3B4392A12AC88292D35C810B /* Pods-BOB_FrontEnd.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BOB_FrontEnd.debug.xcconfig"; path = "Target Support Files/Pods-BOB_FrontEnd/Pods-BOB_FrontEnd.debug.xcconfig"; sourceTree = "<group>"; };
5709B34CF0A7D63546082F79 /* Pods-BOB_FrontEnd.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BOB_FrontEnd.release.xcconfig"; path = "Target Support Files/Pods-BOB_FrontEnd/Pods-BOB_FrontEnd.release.xcconfig"; sourceTree = "<group>"; };
5B7EB9410499542E8C5724F5 /* Pods-BOB_FrontEnd-BOB_FrontEndTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BOB_FrontEnd-BOB_FrontEndTests.debug.xcconfig"; path = "Target Support Files/Pods-BOB_FrontEnd-BOB_FrontEndTests/Pods-BOB_FrontEnd-BOB_FrontEndTests.debug.xcconfig"; sourceTree = "<group>"; };
5DCACB8F33CDC322A6C60F78 /* libPods-BOB_FrontEnd.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-BOB_FrontEnd.a"; sourceTree = BUILT_PRODUCTS_DIR; };
683A1F4FE2FC402C8170EFFE /* PretendardSemiBold.woff */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = PretendardSemiBold.woff; path = ../src/assets/fonts/PretendardSemiBold.woff; sourceTree = "<group>"; };
709E966DA8644081BCC61B58 /* PretendardLight.woff */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = PretendardLight.woff; path = ../src/assets/fonts/PretendardLight.woff; sourceTree = "<group>"; };
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = BOB_FrontEnd/LaunchScreen.storyboard; sourceTree = "<group>"; };
89C6BE57DB24E9ADA2F236DE /* Pods-BOB_FrontEnd-BOB_FrontEndTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BOB_FrontEnd-BOB_FrontEndTests.release.xcconfig"; path = "Target Support Files/Pods-BOB_FrontEnd-BOB_FrontEndTests/Pods-BOB_FrontEnd-BOB_FrontEndTests.release.xcconfig"; sourceTree = "<group>"; };
EB6B8FCAEBCD44DA9A312D82 /* PretendardRegular.woff */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = PretendardRegular.woff; path = ../src/assets/fonts/PretendardRegular.woff; sourceTree = "<group>"; };
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
709E966DA8644081BCC61B58 /* PretendardLight.woff */ = {isa = PBXFileReference; name = "PretendardLight.woff"; path = "../src/assets/fonts/PretendardLight.woff"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
350FFDC1AA0E452B97F0CB21 /* PretendardMedium.woff */ = {isa = PBXFileReference; name = "PretendardMedium.woff"; path = "../src/assets/fonts/PretendardMedium.woff"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
EB6B8FCAEBCD44DA9A312D82 /* PretendardRegular.woff */ = {isa = PBXFileReference; name = "PretendardRegular.woff"; path = "../src/assets/fonts/PretendardRegular.woff"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
683A1F4FE2FC402C8170EFFE /* PretendardSemiBold.woff */ = {isa = PBXFileReference; name = "PretendardSemiBold.woff"; path = "../src/assets/fonts/PretendardSemiBold.woff"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -508,6 +508,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = Y6DURNJ6AC;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = BOB_FrontEnd/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand All @@ -534,6 +535,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = Y6DURNJ6AC;
INFOPLIST_FILE = BOB_FrontEnd/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down
14 changes: 8 additions & 6 deletions ios/BOB_FrontEnd/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,26 @@
<string>wa2ln3tnzy</string>
<key>NSAppTransportSecurity</key>
<dict>
<!-- <key>NSAllowsArbitraryLoads</key>
<true/> -->
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
<key>bobpossible.shop</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSLocationWhenInUseUsageDescription</key>
<string/>
<key>UIAppFonts</key>
<array>
<string>PretendardLight.woff</string>
<string>PretendardMedium.woff</string>
<string>PretendardRegular.woff</string>
<string>PretendardSemiBold.woff</string>
</array>
<array/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
Expand Down
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ PODS:
- React-jsi (= 0.68.2)
- React-logger (= 0.68.2)
- React-perflogger (= 0.68.2)
- RNAppleAuthentication (2.2.1):
- React-Core
- RNCAsyncStorage (1.17.6):
- React-Core
- RNCMaskedView (0.1.11):
Expand Down Expand Up @@ -467,6 +469,7 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
- "RNAppleAuthentication (from `../node_modules/@invertase/react-native-apple-authentication`)"
- "RNCAsyncStorage (from `../node_modules/@react-native-async-storage/async-storage`)"
- "RNCMaskedView (from `../node_modules/@react-native-community/masked-view`)"
- "RNDateTimePicker (from `../node_modules/@react-native-community/datetimepicker`)"
Expand Down Expand Up @@ -564,6 +567,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
ReactCommon:
:path: "../node_modules/react-native/ReactCommon"
RNAppleAuthentication:
:path: "../node_modules/@invertase/react-native-apple-authentication"
RNCAsyncStorage:
:path: "../node_modules/@react-native-async-storage/async-storage"
RNCMaskedView:
Expand Down Expand Up @@ -630,6 +635,7 @@ SPEC CHECKSUMS:
React-RCTVibration: 79040b92bfa9c3c2d2cb4f57e981164ec7ab9374
React-runtimeexecutor: b960b687d2dfef0d3761fbb187e01812ebab8b23
ReactCommon: 095366164a276d91ea704ce53cb03825c487a3f2
RNAppleAuthentication: dab41edef916715148ce94a7dd04041a01590ddc
RNCAsyncStorage: 466b9df1a14bccda91da86e0b7d9a345d78e1673
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
RNDateTimePicker: 04b805a3cb4d386e5e6aff54b47ace7bad706fda
Expand Down
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@invertase/react-native-apple-authentication": "^2.2.1",
"@react-native-async-storage/async-storage": "^1.17.6",
"@react-native-community/datetimepicker": "^6.1.3",
"@react-native-community/masked-view": "^0.1.11",
Expand Down
Binary file added src/assets/images/GoogleButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/assets/images/appleIcon.png
Binary file not shown.
Binary file added src/assets/images/kakaoButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/assets/images/kakaoIcon.png
Binary file not shown.
Binary file added src/assets/images/naverButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/assets/images/naverIcon.png
Binary file not shown.
8 changes: 1 addition & 7 deletions src/data/RegisterInterface.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
//Create Interface type for Registration Form
export enum gender {
'male' = 0,
'female',
'null',
'notSelected',
}

export type RegisterInterface = {
overAge14: boolean;
Expand All @@ -13,7 +7,7 @@ export type RegisterInterface = {
locationContract: boolean;
marketingContract: boolean;
name: string;
gender: gender;
gender: number;
birthDate: Date | null;
address: string;
category: {};
Expand Down
4 changes: 2 additions & 2 deletions src/data/createRegister.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {RegisterInterface, gender} from './RegisterInterface';
import {RegisterInterface} from './RegisterInterface';

export const createRegister = (): RegisterInterface => {
return {
Expand All @@ -8,7 +8,7 @@ export const createRegister = (): RegisterInterface => {
locationContract: false,
marketingContract: false,
name: '',
gender: gender.notSelected,
gender: 3,
birthDate: null,
address: '',
category: [],
Expand Down
2 changes: 2 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ declare namespace ReactNavigation {
OwnerLogin: undefined;
MainNavigator: undefined;
Register: undefined;
KakaoLogin: undefined;
NaverLogin: undefined;
}
}
74 changes: 74 additions & 0 deletions src/modal/SocialWebview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {useNavigation} from '@react-navigation/native';
import React, {FC, useRef} from 'react';
import {StyleSheet} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import {WebView} from 'react-native-webview';
import {useRecoilState} from 'recoil';
import {AuthStackParamList} from '../nav';
import {userToken} from '../state';

//let userAgent =
// 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1';
const INJECTED_JAVASCRIPT =
'(function() {if(window.document.getElementsByTagName("pre").length>0){window.ReactNativeWebView.postMessage((window.document.getElementsByTagName("pre")[0].innerHTML));}})();';

type SocialWebViewProps = {
source: string;
closeSocialModal: () => void;
};

const SocialWebview: FC<SocialWebViewProps> = ({source, closeSocialModal}) => {
const navigation = useNavigation();
const webviewRef = useRef<WebView | null>(null);
const [token, setToken] = useRecoilState(userToken);
const queryString = (rawURL: string) => {
var regex = /[?&]([^=#]+)=([^&#]*)/g,
params = {},
match;
while ((match = regex.exec(rawURL))) {
params[match[1]] = match[2];
}
return params;
};
const _handleMessage = async (data: any) => {
const jwt = data.accessToken;
try {
await setToken(jwt);
} catch (e) {
console.log(e);
}
closeSocialModal();
if (data.registerStatus === 'NEW') {
navigation.navigate('Register');
} else {
navigation.navigate('MainNavigator');
}
};
return (
<SafeAreaView style={styles.container}>
<WebView
ref={webviewRef}
source={{uri: source}}
// userAgent={userAgent}
javaScriptEnabled={true}
injectedJavaScript={INJECTED_JAVASCRIPT}
onMessage={_handleMessage}
onNavigationStateChange={async (e) => {
const result = queryString(e.url);
if (e.url.includes('bobpossible.shop/auth/success')) {
_handleMessage(result);
webviewRef.current?.stopLoading();
}
}}
originWhitelist={['*']}
/>
</SafeAreaView>
);
};
export default SocialWebview;

const styles = StyleSheet.create({
container: {
flex: 1,
},
});
43 changes: 43 additions & 0 deletions src/modal/SocialWebviewModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, {FC} from 'react';
import {Modal, StyleSheet, TouchableOpacity, View} from 'react-native';
import {SafeAreaView} from 'react-native-safe-area-context';
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
import SocialWebview from './SocialWebview';

type SocialWebViewModalProps = {
visible: boolean;
source: string;
closeSocialModal: () => void;
};

const SocialWebviewModal: FC<SocialWebViewModalProps> = ({visible, source, closeSocialModal}) => {
return (
<Modal
presentationStyle="pageSheet"
animationType="slide"
visible={visible}
style={styles.container}
>
<SafeAreaView style={styles.container}>
<TouchableOpacity onPress={closeSocialModal}>
<View style={[styles.backButton]}>
<Icon name="arrow-left" size={24} color="black" />
</View>
</TouchableOpacity>
<SocialWebview source={source} closeSocialModal={closeSocialModal} />
</SafeAreaView>
</Modal>
);
};
export default SocialWebviewModal;

const styles = StyleSheet.create({
container: {
flex: 1,
},
backButton: {
zIndex: 1,
justifyContent: 'center',
alignItems: 'center',
},
});
8 changes: 7 additions & 1 deletion src/nav/AuthNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@ import Register from '../screens/Register';
import RegisterForm from '../screens/RegisterForm';
import RegisterCategory from '../screens/RegisterCategory';
import {RegisterInterface} from '../data';
import KakaoLogin from '../screens/KakaoLogin';
import NaverLogin from '../screens/NaverLogin';

export type AuthStackParamList = {
Login: undefined;
Register: {registerData: RegisterInterface};
KakaoLogin: undefined;
Register: undefined;
RegisterForm: {registerData: RegisterInterface};
RegisterCategory: {registerData: RegisterInterface};
MainNavigator: undefined;
NaverLogin: undefined;
};

const Stack = createStackNavigator<AuthStackParamList>();
Expand All @@ -25,6 +29,8 @@ export const AuthNavigator = () => {
screenOptions={{headerShown: false, gestureEnabled: true}}
>
<Stack.Screen name="Login" component={Login} />
<Stack.Screen name="KakaoLogin" component={KakaoLogin} />
<Stack.Screen name="NaverLogin" component={NaverLogin} />
<Stack.Screen name="Register" component={Register} />
<Stack.Screen name="RegisterForm" component={RegisterForm} />
<Stack.Screen name="RegisterCategory" component={RegisterCategory} />
Expand Down
Loading

0 comments on commit 15d3d16

Please sign in to comment.