Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
240
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
2022-240
240
Commits
7c5f12fd
Commit
7c5f12fd
authored
2 years ago
by
Malsha Rathnasiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add default questions
parent
c998912e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
7 deletions
+79
-7
MobileApp/screens/TabOneScreen.jsx
MobileApp/screens/TabOneScreen.jsx
+79
-7
No files found.
MobileApp/screens/TabOneScreen.jsx
View file @
7c5f12fd
...
...
@@ -9,6 +9,7 @@ import {
View
,
Text
,
SafeAreaView
,
TouchableOpacity
,
}
from
"
react-native
"
;
import
{
AudioRecorder
}
from
"
../components/AudioRecorder
"
;
import
_
from
"
lodash
"
;
...
...
@@ -23,13 +24,19 @@ import { CONVO_DEFAULT_ICON_COLOR, styles } from "../util/styles";
import
{
StatusBar
}
from
"
expo-status-bar
"
;
import
Slider
from
"
@react-native-community/slider
"
;
import
{
PlayMessage
}
from
"
../components/PlayMessage
"
;
import
{
Toast
,
Input
}
from
"
native-base
"
;
import
{
Toast
,
Input
,
ScrollView
,
Divider
}
from
"
native-base
"
;
import
{
ERROR_TOAST_PROPS
}
from
"
../util/util
"
;
import
AsyncStorage
from
"
@react-native-async-storage/async-storage
"
;
export
default
function
ChatScreen
({
navigation
})
{
const
currentTime
=
new
Date
();
const
QandAs
=
[
{
Q
:
"
Does the bus come today?
"
,
A
:
"
Yes
"
},
{
Q
:
"
What time the bus arrives?
"
,
A
:
"
10:30am
"
},
{
Q
:
"
Im not coming today
"
,
A
:
"
Okay
"
},
];
const
defaultChatData
=
[
{
id
:
1
,
...
...
@@ -155,6 +162,15 @@ export default function ChatScreen({ navigation }) {
// }
useEffect
(()
=>
{
const
interval
=
setInterval
(()
=>
{
loadChats
();
},
1000
);
return
()
=>
{
clearInterval
(
interval
);
};
},
[]);
const
loadChatDetails
=
async
()
=>
{
await
getOne
(
"
conversations
"
,
1
)
.
then
((
res
)
=>
{
...
...
@@ -180,6 +196,38 @@ export default function ChatScreen({ navigation }) {
});
};
const
onDefaultMessagePressed
=
(
item
)
=>
{
try
{
addChats
({
message
:
item
.
Q
,
from_user
:
chatDetails
.
from_user
,
to_user
:
chatDetails
.
to_user
,
conversation
:
chatDetails
.
id
,
}).
then
((
response
)
=>
{
// console.log(response)
});
setTimeout
(()
=>
{
addChats
({
message
:
item
.
A
,
from_user
:
chatDetails
.
to_user
,
to_user
:
chatDetails
.
from_user
,
conversation
:
chatDetails
.
id
,
}).
then
((
response
)
=>
{
// console.log(response)
});
},
500
);
setLoading
(
true
);
setInput
(
""
);
loadChats
();
}
catch
(
e
)
{
Toast
.
show
({
title
:
"
Error sending message. try again!
"
,
...
ERROR_TOAST_PROPS
,
});
}
};
const
loadChats
=
async
()
=>
{
await
getList
(
"
chats
"
)
.
then
((
res
)
=>
{
...
...
@@ -238,7 +286,7 @@ export default function ChatScreen({ navigation }) {
<
View
style=
{
{
display
:
"
flex
"
,
flex
:
0.
8
,
flex
:
0.
9
,
justifyContent
:
"
space-between
"
,
}
}
>
...
...
@@ -336,8 +384,7 @@ export default function ChatScreen({ navigation }) {
new
Date
().
toLocaleDateString
()
)
{
date
=
"
Today
"
;
}
else
{
}
else
{
date
=
new
Date
(
title
).
toLocaleDateString
();
}
return
<
Text
style=
{
styles
.
header
}
>
{
date
}
</
Text
>;
...
...
@@ -361,12 +408,37 @@ export default function ChatScreen({ navigation }) {
)
}} /> */
}
</
View
>
<
View
style=
{
{
flex
:
0.075
,
padding
:
0
,
backgroundColor
:
"
white
"
}
}
>
<
Divider
/>
<
View
style=
{
{
flex
:
0.05
,
padding
:
0
,
backgroundColor
:
"
white
"
}
}
>
<
View
style=
{
{
flexDirection
:
"
row
"
,
display
:
"
flex
"
,
height
:
"
100%
"
}
}
>
<
ScrollView
horizontal=
{
true
}
>
{
QandAs
.
map
((
item
)
=>
(
<
TouchableOpacity
onPress=
{
()
=>
onDefaultMessagePressed
(
item
)
}
style=
{
{
marginVertical
:
5
,
marginHorizontal
:
5
,
backgroundColor
:
"
gray
"
,
borderRadius
:
5
,
justifyContent
:
"
center
"
,
alignSelf
:
"
center
"
,
padding
:
5
,
}
}
>
<
Text
style=
{
{
justifyContent
:
"
center
"
,
alignSelf
:
"
center
"
}
}
>
{
item
.
Q
}
</
Text
>
</
TouchableOpacity
>
))
}
</
ScrollView
>
</
View
>
</
View
>
<
Divider
/>
<
View
style=
{
{
flex
:
0.05
,
padding
:
0
,
backgroundColor
:
"
white
"
}
}
>
<
View
style=
{
{
flexDirection
:
"
row
"
,
display
:
"
flex
"
,
height
:
"
100%
"
}
}
>
...
...
@@ -382,7 +454,7 @@ export default function ChatScreen({ navigation }) {
defaultValue={input}
onChange={(e) => setInput(e.target.value)}></TextInput> */
}
<
Input
style=
{
{}
}
style=
{
{
height
:
30
}
}
value=
{
input
}
w=
"100%"
onChangeText=
{
setInput
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment