Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김서영
/
searchGuide
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
bluejoyq
2019-11-21 01:47:54 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7a51b2913c31a81bbe8cbe1f6b1903d35d9726be
7a51b291
1 parent
e2f7182b
complete connection
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
83 additions
and
48 deletions
searchGuide/.expo/packager-info.json
searchGuide/.expo/settings.json
searchGuide/components/RateBar/RateBar.js
searchGuide/components/RateLine/RateLine.js
searchGuide/components/RateSentence/RateSentence.js
searchGuide/lib/api.js
searchGuide/lib/sqlite.js
searchGuide/reducers/loading.js
searchGuide/reducers/search.js
searchGuide/.expo/packager-info.json
View file @
7a51b29
...
...
@@ -2,8 +2,8 @@
"devToolsPort"
:
19002
,
"expoServerPort"
:
19000
,
"packagerPort"
:
19001
,
"packagerPid"
:
31648
,
"expoServerNgrokUrl"
:
null
,
"packagerNgrokUrl"
:
null
,
"ngrokPid"
:
null
"packagerPid"
:
11640
,
"expoServerNgrokUrl"
:
"https://cx-ky7.anonymous.searchguide.exp.direct"
,
"packagerNgrokUrl"
:
"https://packager.cx-ky7.anonymous.searchguide.exp.direct"
,
"ngrokPid"
:
8960
}
...
...
searchGuide/.expo/settings.json
View file @
7a51b29
...
...
@@ -3,6 +3,6 @@
"lanType"
:
"ip"
,
"dev"
:
true
,
"minify"
:
false
,
"urlRandomness"
:
"
83-zd2
"
,
"urlRandomness"
:
"
cx-ky7
"
,
"https"
:
false
}
...
...
searchGuide/components/RateBar/RateBar.js
View file @
7a51b29
...
...
@@ -13,7 +13,7 @@ export default RateBar = (props) => {
{
props
.
score
.
msg
.
length
?
<>
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{
styles
.
Text
}
>
점수
<
/Text
>
<
Text
style
=
{
styles
.
Text
}
>
총
점수
:
{
props
.
score
.
full
}
<
/Text
>
<
View
style
=
{
styles
.
colorContainer
}
>
<
View
style
=
{
styles
.
textContainer
}
>
<
View
style
=
{
styles
.
colorA
}
><
/View><Text>키워드 점수</
Text
>
...
...
@@ -55,6 +55,7 @@ export default RateBar = (props) => {
<
HelperText
type
=
{
'info'
}
visible
=
{
click
==
1
}
style
=
{{
fontSize
:
20
}}
>
키워드
:
{
props
.
score
.
key
}
<
/HelperText
>
<
HelperText
type
=
{
'info'
}
visible
=
{
click
==
2
}
style
=
{{
fontSize
:
20
}}
>
맞춤법
:
{
props
.
score
.
fix
}
<
/HelperText
>
<
/View
>
<
Text
>
눌러서
각각의
점수를
알아보세요
!<
/Text
>
<
/
>
:
<
PromptSearchRate
/>
}
<
/Surface
>
...
...
searchGuide/components/RateLine/RateLine.js
View file @
7a51b29
import
React
from
'react'
;
import
React
,
{
useEffect
}
from
'react'
;
import
{
Surface
,
Text
}
from
'react-native-paper'
;
import
{
StyleSheet
}
from
'react-native'
;
import
{
connect
}
from
'react-redux'
;
import
{
load
}
from
'../../reducers/search'
;
import
PromptSearchRate
from
'../PromptSearch/PromptSearchRate'
;
export
default
RateLine
=
()
=>
(
const
RateLine
=
({
load
,
pastScore
})
=>
{
useEffect
(()
=>
{
const
get
=
async
()
=>
{
await
load
();
}
get
();
},
[
load
]);
return
(
<
Surface
style
=
{
styles
.
surface
}
>
<
Text
>
Surface
<
/Text
>
{
pastScore
.
length
?
pastScore
.
map
((
elem
,
index
)
=>
(
<
Text
key
=
{
index
}
>
{
elem
}
<
/Text
>
))
:
<
PromptSearchRate
/>
}
<
/Surface
>
);
);
}
const
styles
=
StyleSheet
.
create
({
surface
:
{
...
...
@@ -20,3 +39,16 @@ const styles = StyleSheet.create({
marginBottom
:
10
,
},
});
const
RateLineContainer
=
(
{
load
,
pastScore
}
)
=>
(
<
RateLine
load
=
{
load
}
pastScore
=
{
pastScore
}
/
>
);
export
default
connect
(
({
search
})
=>
({
pastScore
:
search
.
pastScore
}),
{
load
}
)(
RateLineContainer
);
\ No newline at end of file
...
...
searchGuide/components/RateSentence/RateSentence.js
View file @
7a51b29
...
...
@@ -22,11 +22,17 @@ const RateSentence = ({originalText, fixedText, keywordText }) => {
return
(
<
Surface
style
=
{
styles
.
surface
}
onTouchStart
=
{
calCount
}
>
{
keywordText
?
<>
<
View
>
{
count
==
0
&&
(
<
SentenceInfo
Text
=
{
originalText
}
info
=
{
'원래 검색 문장'
}
color
=
{
'#B71C1C'
}
/>
)
}
{
count
==
1
&&
(
<
SentenceInfo
Text
=
{
fixedText
}
info
=
{
'맞춤법 교정 문장'
}
color
=
{
'#2196F3'
}
/>
)
}
{
count
==
2
&&
(
<
SentenceInfo
Text
=
{
keywordText
}
info
=
{
'키워드 교정 문장'
}
color
=
{
'#00a676'
}
/>
)
}
<
/View>
<
View
style
=
{{
flexDirection
:
'column-reverse'
,
height
:
50
}}
>
<
Text
>
눌러서
변화
과정을
지켜보세요
!<
/Text
>
<
/View
>
<
/
>
:
<
PromptSearchRate
/>
}
...
...
searchGuide/lib/api.js
View file @
7a51b29
const
axios
=
require
(
'axios'
)
const
filter
=
require
(
'./filter'
)
import
filter
from
'./filter'
;
export
const
sendSearch
=
async
(
searchText
)
=>
{
console
.
log
(
searchText
)
return
new
Promise
((
resolve
,
reject
)
=>
{
let
isBlank_reg
=
"/\s\g"
if
(
searchText
===
""
||
searchText
.
length
>
30
){
resolve
(
JSON
.
stringify
({
"return_code"
:
-
1
,
"error_code"
:
"검색 단어를 확인해 주세요!"
})
);
resolve
(
{
"return_code"
:
-
1
,
"error_code"
:
"검색 단어를 확인해 주세요!"
}
);
}
else
{
axios
(
{
...
...
@@ -14,7 +13,7 @@ export const sendSearch = async(searchText) => {
"Accept"
:
"application/json"
,
"Content-Type"
:
"application/json"
,
},
url
:
'http://
1.201.142.118
:80/api/cliConnection'
,
url
:
'http://
34.84.91.190
:80/api/cliConnection'
,
data
:
{
data
:{
text
:
searchText
.
replace
(
/
\s{1,}
/g
,
' '
)
...
...
@@ -24,19 +23,14 @@ export const sendSearch = async(searchText) => {
}
)
.
then
((
response
)
=>
{
resolve
(
JSON
.
stringify
(
filter
(
response
.
data
)))
resolve
(
filter
(
response
.
data
))
return
true
;
})
.
catch
(
error
=>
{
console
.
error
(
error
);
throw
new
Error
(
err
)
});
}
setTimeout
(
()
=>
{
try
{
throw
new
Error
(
"ERROR"
);
}
catch
(
err
)
{
resolve
(
JSON
.
stringify
({
"return_code"
:
-
1
,
"error_code"
:
err
.
message
}));
return
false
;
}},
10000
)
throw
new
Error
(
"time out"
);}
,
10000
)
})
}
\ No newline at end of file
...
...
searchGuide/lib/sqlite.js
View file @
7a51b29
import
*
as
SQLite
from
'expo-sqlite'
;
import
{
Modal
}
from
'react-native'
;
import
{
openDatabase
,
transaction
,
executeSql
}
from
'expo-sqlite'
;
import
{
rejects
}
from
'assert'
;
let
sqlite
=
{};
...
...
searchGuide/reducers/loading.js
deleted
100644 → 0
View file @
e2f7182
const
TOGGLE
=
'loading/TOGGLE'
;
export
const
toggle
=
()
=>
({
type
:
TOGGLE
})
const
initialState
=
{
isLoading
:
false
,
};
export
default
loading
=
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
)
{
case
TOGGLE
:
return
{...
state
,
isLoading
:
!
state
.
isLoading
};
default
:
return
state
;
}
}
\ No newline at end of file
searchGuide/reducers/search.js
View file @
7a51b29
import
{
sendSearch
}
from
'../lib/api'
import
{
Alert
}
from
'react-native'
import
{
readTest
}
from
'../lib/readTest'
;
import
sqlite
from
'../lib/sqlite'
;
const
LOAD
=
'search/LOAD'
;
const
CHANGE
=
'search/CHANGE'
;
const
SUCCESS
=
'search/SUCCESS'
;
const
FAILURE
=
'search/FAILURE'
;
...
...
@@ -11,16 +14,32 @@ export const change = (text) => ({
text
,
})
export
const
load
=
()
=>
async
(
dispatch
)
=>
{
let
past
=
await
sqlite
.
select
();
past
=
await
past
.
map
(
elem
=>
elem
.
score
);
dispatch
({
type
:
LOAD
,
past
:
past
})
}
export
const
submit
=
(
text
)
=>
async
(
dispatch
)
=>
{
dispatch
(
{
type
:
START
});
try
{
/*const response = await sendSearch(text);*/
const
response
=
await
readTest
();
// 테스트용입니당~
const
response
=
await
sendSearch
(
text
.
nativeEvent
.
text
);
let
tempScore
=
scoring
(
response
.
return_data
).
full
;
await
sqlite
.
insert
(
tempScore
);
let
past
=
await
sqlite
.
select
();
past
=
past
.
map
(
elem
=>
elem
.
score
);
//dispatch( { type:SUCCESS, result:response }
setTimeout
(()
=>
dispatch
(
{
type
:
SUCCESS
,
result
:
response
}),
500
);
// 셋타임아웃도 테스트용
dispatch
(
{
type
:
SUCCESS
,
result
:
response
,
past
:
past
})
}
catch
(
err
){
dispatch
({
type
:
FAILURE
,
result
:
response
})
console
.
log
(
err
);
/* Alert.alert(
'error',
[
{text: '확인', onPress: () => {}},
],
) */
dispatch
({
type
:
FAILURE
})
}
}
...
...
@@ -33,6 +52,7 @@ const initialState = {
}
},
isLoading
:
false
,
pastScore
:
[
10
,
10
,
10
,
10
,
10
,
10
],
};
export
default
ToggleLoading
=
(
state
=
initialState
,
action
)
=>
{
...
...
@@ -40,11 +60,13 @@ export default ToggleLoading = (state = initialState, action) => {
case
CHANGE
:
return
{...
state
,
query
:
action
.
text
};
case
SUCCESS
:
return
{...
state
,
isLoading
:
false
,
result
:
action
.
result
};
return
{...
state
,
isLoading
:
false
,
result
:
action
.
result
,
pastScore
:
action
.
past
};
case
FAILURE
:
return
{...
state
,
isLoading
:
false
};
case
START
:
return
{...
state
,
query
:
''
,
isLoading
:
true
}
case
LOAD
:
return
{...
state
,
pastScore
:
action
.
past
}
default
:
return
state
;
}
...
...
Please
register
or
login
to post a comment