Skip to content

Commit

Permalink
[Deploy] Release 1.0.3v
Browse files Browse the repository at this point in the history
  • Loading branch information
SEEWON committed Jan 26, 2022
1 parent 7effdac commit 4cb87f7
Show file tree
Hide file tree
Showing 12 changed files with 516 additions and 70 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ android {
applicationId "com.chatminderclient"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 2
versionName "1.0.2"
versionCode 3
versionName "1.0.3"
resValue "string", "build_config_package", "com.chatminderclient"

}
Expand Down
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"expo": {
"name": "Chatminder",
"slug": "Chatminder",
"version": "1.0.2",
"version": "1.0.3",
"assetBundlePatterns": ["**/*"]
},
"android": {
"versionCode": 2,
"versionCode": 3,
"package": ""
},
"name": "Chatminder"
Expand Down
7 changes: 4 additions & 3 deletions navigation/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { setMemos } from '../shared/reducers/memo';
import { setTags } from '../shared/reducers/tag';
import Loader from '../shared/components/Loader';
import { Alert } from 'react-native';
import moment from 'moment';
import LogIn from '../screens/LogIn';
import SignUp from '../screens/SignUp';

const Nav = createNativeStackNavigator();

Expand All @@ -24,14 +24,14 @@ const Root = () => {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [loading, setLoading] = useState(true);

//이미 토큰이 리덕스에 저장된 경우(직접 카카오로그인)
//이미 토큰이 리덕스에 저장된 경우(직접 로그인)
useEffect(() => {
if (authData.isLoggedIn) {
setIsLoggedIn(true);
}
}, [authData]);

//직접 로그인하는 경우가 아니라면 AsyncStorage에 토큰이 있다면 로그인
//AsyncStorage에 토큰이 저장되어 있는 경우(자동 로그인)
useEffect(async () => {
const storedToken = await AsyncStorage.getItem('ChatMinderRefreshToken');
if (storedToken) {
Expand Down Expand Up @@ -124,6 +124,7 @@ const Root = () => {
<>
<Nav.Screen name="Starting" component={Starting} />
<Nav.Screen name="LogIn" component={LogIn} />
<Nav.Screen name="SignUp" component={SignUp} />
</>
)}
</Nav.Navigator>
Expand Down
6 changes: 5 additions & 1 deletion screens/DrawerNavScreens/detailText.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ const detailText = ({ route, navigation }) => {
<GoBack />
</TouchableOpacity>
<Buttons>
<TouchableOpacity onPress={() => onEdit()}>
<TouchableOpacity
hitSlop={{ top: 12, bottom: 12, left: 12, right: 0 }}
onPress={() => onEdit()}
>
<BookmarkItem
source={edit}
width="25"
Expand All @@ -196,6 +199,7 @@ const detailText = ({ route, navigation }) => {
/>
</TouchableOpacity>
<TouchableOpacity
hitSlop={{ top: 12, bottom: 12, left: 6, right: 12 }}
onPress={() => {
handleBookmark(route.params.id, route.params.is_marked);
}}
Expand Down
229 changes: 176 additions & 53 deletions screens/LogIn.js
Original file line number Diff line number Diff line change
@@ -1,62 +1,185 @@
import React, { useState } from 'react';
import axios from 'axios';
import { Text, View, Button } from 'react-native';
import {
KakaoOAuthToken,
KakaoProfile,
getProfile as getKakaoProfile,
login,
logout,
unlink,
getAccessToken,
} from '@react-native-seoul/kakao-login';

const LogIn = () => {
const [kakaoResponse, setKakaoResponse] =
useState('아직 응답 받지 못하였습니다.');
const [serverResponse, setServerResponse] =
useState('아직 응답 받지 못하였습니다.');
const [kakaoAccessToken, setKakaoAccessToken] =
useState('아직 응답 받지 못하였습니다.');
const [serverAccessToken, setServerAccessToken] =
useState('아직 응답 받지 못하였습니다.');

const signInWithKakao = async () => {
import React, { useEffect, useState } from 'react';
import { ActivityIndicator, Alert, Dimensions } from 'react-native';
import { useDispatch } from 'react-redux';
import { Controller, useForm } from 'react-hook-form';
import AsyncStorage from '@react-native-async-storage/async-storage';
import styled from 'styled-components/native';
import palette from '../shared/palette';
import { CMLogIn } from '../shared/API';
import { setLoginState } from '../shared/reducers/auth';

const LogIn = ({ navigation }) => {
useEffect(() => {
navigation.setOptions({
headerShadowVisible: false,
headerStyle: { backgroundColor: palette.logInGray },
title: '챗마인더 로그인',
});
}, []);

const dispatch = useDispatch();
const [loading, setLoading] = useState(false);

const { control, handleSubmit } = useForm({
defaultValues: {
ID: '',
PW: '',
},
});

const onSubmit = async (data) => {
setLoading(true);
try {
const token = await login();
setKakaoResponse(JSON.stringify(token));
setKakaoAccessToken(token.accessToken);
} catch (e) {
console.log('error' + e);
const sendingData = {
login_id: data.ID,
password: data.PW,
};
const logInRes = await CMLogIn(sendingData);
const ChatMinderTokens = logInRes.data;
await AsyncStorage.setItem(
'ChatMinderRefreshToken',
ChatMinderTokens.refresh_token
);
dispatch(setLoginState(ChatMinderTokens.access_token));
} catch (error) {
if (error.response) {
Alert.alert(
'알림',
`로그인에 실패했습니다.\n아이디와 비밀번호를 확인해 주세요.`,
[
{
text: '네!',
style: 'cancel',
},
]
);
}
if (error == 'Error: Network Error') {
Alert.alert(
'알림',
`인터넷 연결이 불안정합니다.\n확인 후 다시 시도해 주세요.`,
[
{
text: '네!',
style: 'cancel',
},
]
);
}
}
};

const sendAccesToken = () => {
// const url = "http://localhost:8000/auth/kakao";
const url = 'http://10.0.2.2:8000/auth/kakao';
console.log(kakaoAccessToken);
axios
.post(url, {
kakao_access_token: kakaoAccessToken,
})
.then((res) => {
console.log(res);
const resdata = JSON.stringify(res.data);
setServerResponse(resdata);
})
.catch((e) => console.log(e));
setLoading(false);
};

return (
<View>
<Button title="Kakao Login" onPress={signInWithKakao} />
<Button title="Send Access Token" onPress={sendAccesToken} />
<Text />
<Text>Kakao Server response : {kakaoResponse}</Text>
<Text />
<Text>ChatMinder Server response : {serverResponse}</Text>
</View>
<Wrapper>
{loading && (
<SpinnerWrapper>
<ActivityIndicator size="large" color="#ff7f6d" />
</SpinnerWrapper>
)}
<Controller
control={control}
render={({ field: { onChange, onBlur, value } }) => (
<Container>
<InputLabel>아이디</InputLabel>
<Input
onBlur={onBlur}
onChangeText={(value) => onChange(value)}
value={value}
/>
</Container>
)}
name="ID"
/>
<Controller
control={control}
render={({ field: { onChange, onBlur, value } }) => (
<Container>
<InputLabel>비밀번호</InputLabel>
<Input
onBlur={onBlur}
onChangeText={(value) => onChange(value)}
value={value}
secureTextEntry={true}
/>
</Container>
)}
name="PW"
/>
<SubmitBtnContainer onPress={handleSubmit(onSubmit)}>
<SubmitBtnText>로그인</SubmitBtnText>
</SubmitBtnContainer>
<SignUpBtn
hitSlop={{ top: 12, bottom: 12, left: 24, right: 24 }}
onPress={() => navigation.navigate('SignUp')}
>
<SignUpText>아직 아이디가 없다면? 회원가입하기</SignUpText>
</SignUpBtn>
</Wrapper>
);
};

const Wrapper = styled.View`
width: 100%;
height: 100%;
background: ${palette.logInGray};
`;

const SCREEN_WIDTH = Dimensions.get('window').width;
const SCREEN_HEIGHT = Dimensions.get('window').height;

const SpinnerWrapper = styled.View`
position: absolute;
left: ${SCREEN_WIDTH * 0.5 - 18}px;
bottom: ${SCREEN_HEIGHT * 0.5 - 18}px;
z-index: 10;
`;

const Container = styled.View`
margin: 8px 16px 8px 16px;
width: 90%;
`;
const InputLabel = styled.Text`
font-family: 'NanumSquareOTF_ac';
font-size: 16px;
`;
const Input = styled.TextInput`
margin: 4px 0 4px 0;
padding: 0 10px 0 10px;
background: ${palette.white};
border: 1px solid #d8d9df;
align-self: center;
width: 100%;
height: 50px;
`;

const SubmitBtnContainer = styled.TouchableOpacity`
width: 90%;
height: 55px;
border-radius: 27.5px;
background: ${palette.main};
justify-content: center;
align-self: center;
align-items: center;
margin-top: 10px;
`;
const SubmitBtnText = styled.Text`
font-family: 'NanumSquareOTF_ac';
font-size: 16px;
font-weight: bold;
line-height: 18px;
color: ${palette.white};
`;

const SignUpBtn = styled.TouchableOpacity`
margin-top: 24px;
align-self: center;
`;
const SignUpText = styled.Text`
font-family: 'NanumSquareOTF_ac';
font-size: 14px;
color: #565c6b;
text-decoration: underline;
`;

export default LogIn;
Loading

0 comments on commit 4cb87f7

Please sign in to comment.