Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
EmidWife-New
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
2023-24-005
EmidWife-New
Commits
00b60a06
Commit
00b60a06
authored
May 19, 2024
by
Malsha Jayakody
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create user profile
parent
828c667b
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
351 additions
and
130 deletions
+351
-130
src/assets/user_profile.png
src/assets/user_profile.png
+0
-0
src/constants/colors.js
src/constants/colors.js
+1
-0
src/constants/imgs.js
src/constants/imgs.js
+1
-1
src/constants/routes.js
src/constants/routes.js
+1
-1
src/navigations/AuthNavigator.js
src/navigations/AuthNavigator.js
+113
-98
src/navigations/GameNavigator.js
src/navigations/GameNavigator.js
+1
-1
src/navigations/ProfileNavigator.js
src/navigations/ProfileNavigator.js
+19
-0
src/screens/auth/ProfilePage.js
src/screens/auth/ProfilePage.js
+175
-0
src/screens/home/Home.js
src/screens/home/Home.js
+13
-28
src/screens/home/game/QuizScore.js
src/screens/home/game/QuizScore.js
+1
-1
src/services/auth/index.js
src/services/auth/index.js
+26
-0
No files found.
src/assets/user_profile.png
0 → 100644
View file @
00b60a06
28.7 KB
src/constants/colors.js
View file @
00b60a06
...
...
@@ -21,4 +21,5 @@ export default {
purple_new
:
'
#AC87C5
'
,
pink_new
:
'
#FF8080
'
,
pastal_blue
:
'
#7469B6
'
,
red
:
'
#DC143C
'
,
};
src/constants/imgs.js
View file @
00b60a06
...
...
@@ -16,7 +16,6 @@ export default {
sk_15
:
require
(
'
../assets/sk_15.png
'
),
sk_16
:
require
(
'
../assets/sk_16.png
'
),
//games
game_img_1
:
require
(
'
../assets/game_img_1.png
'
),
game_img_2
:
require
(
'
../assets/game_img_2.png
'
),
...
...
@@ -66,4 +65,5 @@ export default {
home_page
:
require
(
'
../assets/home_page.png
'
),
well_being
:
require
(
'
../assets/games/wellBeing.jpg
'
),
motherWithMidWife
:
require
(
'
../assets/games/motherAndMidWife.jpg
'
),
user_profile_image
:
require
(
'
../assets/user_profile.png
'
),
};
src/constants/routes.js
View file @
00b60a06
...
...
@@ -2,7 +2,7 @@ export default {
LOGIN
:
'
Login
'
,
REGISTER
:
'
Register
'
,
FORGOT_PASSWORD
:
'
Forgot_Password
'
,
PROFILE
:
'
UserProfile
'
,
HOME
:
'
Home
'
,
HOME_TAB
:
'
Home_Tab
'
,
...
...
src/navigations/AuthNavigator.js
View file @
00b60a06
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
createStackNavigator
}
from
'
@react-navigation/stack
'
;
import
Login
from
'
../screens/auth/Login
'
;
import
Register
from
'
../screens/auth/Register
'
;
import
ForgotPassword
from
'
../screens/auth/ForgotPassword
'
;
import
{
createStackNavigator
}
from
'
@react-navigation/stack
'
;
import
Login
from
'
../screens/auth/Login
'
;
import
Register
from
'
../screens/auth/Register
'
;
import
ForgotPassword
from
'
../screens/auth/ForgotPassword
'
;
// import { Login, Register, ForgotPassword} from '../screens';
import
{
ROUTES
}
from
"
../constants
"
import
BottomTabNavigator
from
'
./BottomTabNavigator
'
import
{
ROUTES
}
from
'
../constants
'
;
import
BottomTabNavigator
from
'
./BottomTabNavigator
'
;
const
Stack
=
createStackNavigator
();
import
AsyncStorage
from
'
@react-native-async-storage/async-storage
'
;
import
ProfileNavigator
from
'
./ProfileNavigator
'
;
function
AuthNavigator
()
{
const
[
isLoggedIn
,
setIsLoggedIn
]
=
useState
(
false
);
const
[
isLoggedIn
,
setIsLoggedIn
]
=
useState
(
false
);
useEffect
(()
=>
{
// Check if the user is already logged in
checkLoggedInStatus
();
},
[]);
useEffect
(()
=>
{
// Check if the user is already logged in
checkLoggedInStatus
();
},
[]);
const
checkLoggedInStatus
=
async
()
=>
{
try
{
// Example: Check if a token or user data exists in AsyncStorage
const
userData
=
await
AsyncStorage
.
getItem
(
'
userData
'
);
if
(
userData
)
{
setIsLoggedIn
(
true
);
}
}
catch
(
error
)
{
console
.
error
(
'
Error checking logged in status:
'
,
error
);
}
};
return
(
// <Stack.Navigator
// screenOptions={{
// headerBackTitleVisible: false
// }}
// initialRouteName={ROUTES.LOGIN}
// >
// <Stack.Screen
// options={{
// headerShown: false
// }}
// name={ROUTES.LOGIN} component={Login}
// />
// <Stack.Screen
// options={{
// headerShown: false,
// headerBackTitleVisible: false
// }}
// name={ROUTES.REGISTER} component={Register}
// />
// <Stack.Screen
// name={ROUTES.FORGOT_PASSWORD} component={ForgotPassword}
// />
// <Stack.Screen options={{
// headerShown: false,
// headerBackTitleVisible: false
// }}
// name={ROUTES.HOME} component={BottomTabNavigator} />
// </Stack.Navigator>
<
Stack
.
Navigator
screenOptions
=
{{
headerBackTitleVisible
:
false
const
checkLoggedInStatus
=
async
()
=>
{
try
{
// Example: Check if a token or user data exists in AsyncStorage
const
userData
=
await
AsyncStorage
.
getItem
(
'
userData
'
);
if
(
userData
)
{
setIsLoggedIn
(
true
);
}
}
catch
(
error
)
{
console
.
error
(
'
Error checking logged in status:
'
,
error
);
}
};
return
(
// <Stack.Navigator
// screenOptions={{
// headerBackTitleVisible: false
// }}
// initialRouteName={ROUTES.LOGIN}
// >
// <Stack.Screen
// options={{
// headerShown: false
// }}
// name={ROUTES.LOGIN} component={Login}
// />
// <Stack.Screen
// options={{
// headerShown: false,
// headerBackTitleVisible: false
// }}
// name={ROUTES.REGISTER} component={Register}
// />
// <Stack.Screen
// name={ROUTES.FORGOT_PASSWORD} component={ForgotPassword}
// />
// <Stack.Screen options={{
// headerShown: false,
// headerBackTitleVisible: false
// }}
// name={ROUTES.HOME} component={BottomTabNavigator} />
// </Stack.Navigator>
<
Stack
.
Navigator
screenOptions
=
{{
headerBackTitleVisible
:
false
,
}}
initialRouteName
=
{
ROUTES
.
LOGIN
}
>
{
isLoggedIn
?
(
<>
<
Stack
.
Screen
options
=
{{
headerShown
:
false
,
}}
name
=
{
ROUTES
.
HOME
}
component
=
{
BottomTabNavigator
}
/
>
<
Stack
.
Screen
options
=
{{
headerShown
:
false
,
}}
name
=
{
ROUTES
.
PROFILE
}
component
=
{
ProfileNavigator
}
/
>
<
/
>
)
:
(
<>
<
Stack
.
Screen
options
=
{{
headerShown
:
false
,
}}
name
=
{
ROUTES
.
LOGIN
}
component
=
{
Login
}
/
>
<
Stack
.
Screen
options
=
{{
headerShown
:
false
,
headerBackTitleVisible
:
false
,
}}
name
=
{
ROUTES
.
REGISTER
}
component
=
{
Register
}
/
>
<
Stack
.
Screen
name
=
{
ROUTES
.
FORGOT_PASSWORD
}
component
=
{
ForgotPassword
}
/
>
<
Stack
.
Screen
options
=
{{
headerShown
:
false
,
}}
name
=
{
ROUTES
.
HOME
}
component
=
{
BottomTabNavigator
}
/
>
<
Stack
.
Screen
options
=
{{
headerShown
:
false
,
}}
initialRouteName
=
{
ROUTES
.
LOGIN
}
>
{
isLoggedIn
?
(
<
Stack
.
Screen
options
=
{{
headerShown
:
false
}}
name
=
{
ROUTES
.
HOME
}
component
=
{
BottomTabNavigator
}
/
>
)
:
(
<>
<
Stack
.
Screen
options
=
{{
headerShown
:
false
}}
name
=
{
ROUTES
.
LOGIN
}
component
=
{
Login
}
/
>
<
Stack
.
Screen
options
=
{{
headerShown
:
false
,
headerBackTitleVisible
:
false
}}
name
=
{
ROUTES
.
REGISTER
}
component
=
{
Register
}
/
>
<
Stack
.
Screen
name
=
{
ROUTES
.
FORGOT_PASSWORD
}
component
=
{
ForgotPassword
}
/
>
<
Stack
.
Screen
options
=
{{
headerShown
:
false
}}
name
=
{
ROUTES
.
HOME
}
component
=
{
BottomTabNavigator
}
/
>
<
/
>
)}
<
/Stack.Navigator
>
);
name
=
{
ROUTES
.
PROFILE
}
component
=
{
ProfileNavigator
}
/
>
<
/
>
)}
<
/Stack.Navigator
>
);
}
export
default
AuthNavigator
;
\ No newline at end of file
export
default
AuthNavigator
;
src/navigations/GameNavigator.js
View file @
00b60a06
...
...
@@ -51,7 +51,7 @@ function GameNavigator() {
headerBackTitleVisible
:
false
,
headerShown
:
false
,
}}
initialRouteName
=
{
ROUTES
.
EXERCISE_MAIN_MENU
}
>
initialRouteName
=
{
ROUTES
.
GAME_HOME
}
>
<
Stack
.
Screen
name
=
{
ROUTES
.
GAME_WELCOME
}
component
=
{
WelcomePageGame
}
/
>
<
Stack
.
Screen
name
=
{
ROUTES
.
GAME_QUIZ_OPTIONS
}
...
...
src/navigations/ProfileNavigator.js
0 → 100644
View file @
00b60a06
import
React
from
'
react
'
;
import
{
createStackNavigator
}
from
'
@react-navigation/stack
'
;
import
{
ROUTES
}
from
'
../constants
'
;
import
UserProfile
from
'
../screens/auth/ProfilePage
'
;
const
Stack
=
createStackNavigator
();
function
ProfileNavigator
()
{
return
(
<
Stack
.
Navigator
screenOptions
=
{{
headerBackTitleVisible
:
false
,
headerShown
:
false
,
}}
initialRouteName
=
{
ROUTES
.
HOME
}
>
<
Stack
.
Screen
name
=
{
ROUTES
.
PROFILE
}
component
=
{
UserProfile
}
/
>
<
/Stack.Navigator
>
);
}
export
default
ProfileNavigator
;
src/screens/auth/ProfilePage.js
0 → 100644
View file @
00b60a06
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
StyleSheet
,
View
,
Text
,
Image
,
TouchableOpacity
}
from
'
react-native
'
;
import
Icon
from
'
react-native-vector-icons/Ionicons
'
;
import
{
COLORS
,
IMGS
,
ROUTES
}
from
'
../../constants
'
;
import
LinearGradient
from
'
react-native-linear-gradient
'
;
import
{
Formik
}
from
'
formik
'
;
// import {getUserDetails} from '../../services/auth/index';
const
UserProfile
=
({
navigation
})
=>
{
const
[
userDetails
,
setUserDetails
]
=
useState
(
null
);
const
[
error
,
setError
]
=
useState
(
null
);
// const handleFetchDetails = async () => {
// try {
// const email = 'user@example.com'; // This should be dynamically sourced, perhaps from user state or AsyncStorage
// const details = await getUserDetails(email);
// setUserDetails(details.data);
// } catch (err) {
// setError('Failed to fetch details');
// console.error(err);
// }
// };
console
.
log
(
userDetails
,
'
userDetails
'
);
// useEffect(() => {
// handleFetchDetails();
// }, []);
return
(
<
LinearGradient
style
=
{
styles
.
container
}
colors
=
{[
COLORS
.
dark_purple
,
COLORS
.
white
,
COLORS
.
pink
]}
>
<
View
style
=
{
styles
.
profileHeader
}
>
<
Image
source
=
{
IMGS
.
user_profile_image
}
style
=
{
styles
.
profileImage
}
/
>
<
Text
style
=
{
styles
.
name
}
>
{
userDetails
?.
name
?
userDetails
?.
name
:
'
Malsha Geethmi
'
}
<
/Text
>
<
/View
>
<
View
style
=
{
styles
.
infoContainer
}
>
<
View
style
=
{
styles
.
infoItem
}
>
<
Text
style
=
{
styles
.
infoLabel
}
>
Email
<
/Text
>
<
Text
style
=
{
styles
.
infoContent
}
>
{
userDetails
?.
email
?
userDetails
?.
email
:
'
malsha@gmail.com
'
}
<
/Text
>
<
/View
>
<
View
style
=
{
styles
.
infoItem
}
>
<
Text
style
=
{
styles
.
infoLabel
}
>
Age
<
/Text
>
<
Text
style
=
{
styles
.
infoContent
}
>
{
userDetails
?.
age
?
userDetails
?.
age
:
'
24
'
}
<
/Text
>
<
/View
>
<
View
style
=
{
styles
.
infoItem
}
>
<
Text
style
=
{
styles
.
infoLabel
}
>
Week
<
/Text
>
<
Text
style
=
{
styles
.
infoContent
}
>
{
userDetails
?.
week
?
userDetails
?.
week
:
'
14
'
}
<
/Text
>
<
/View
>
<
/View
>
<
TouchableOpacity
style
=
{
styles
.
button
}
onPress
=
{()
=>
navigation
.
navigate
(
ROUTES
.
FORGOT_PASSWORD
)}
>
<
View
style
=
{
styles
.
new
}
>
<
Icon
name
=
"
key
"
size
=
{
30
}
color
=
{
COLORS
.
white
}
style
=
{
styles
.
icon1
}
/
>
<
Text
style
=
{
styles
.
buttonText
}
>
Change
Password
<
/Text
>
<
/View
>
<
/TouchableOpacity
>
<
TouchableOpacity
style
=
{
styles
.
button2
}
>
<
Text
style
=
{
styles
.
buttonText2
}
>
LOGOUT
<
/Text
>
<
/TouchableOpacity
>
<
/LinearGradient
>
);
};
const
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
backgroundColor
:
COLORS
.
pastalBlue
,
alignItems
:
'
center
'
,
paddingTop
:
50
,
},
profileHeader
:
{
backgroundColor
:
'
white
'
,
width
:
'
90%
'
,
borderRadius
:
20
,
alignItems
:
'
center
'
,
marginBottom
:
20
,
paddingVertical
:
20
,
},
profileImage
:
{
width
:
80
,
height
:
80
,
borderRadius
:
40
,
marginBottom
:
10
,
},
name
:
{
fontSize
:
18
,
fontWeight
:
'
bold
'
,
color
:
COLORS
.
navyBlue
,
},
phoneNumber
:
{
fontSize
:
16
,
color
:
'
gray
'
,
},
infoContainer
:
{
width
:
'
90%
'
,
backgroundColor
:
'
white
'
,
borderRadius
:
20
,
paddingVertical
:
10
,
},
infoItem
:
{
flexDirection
:
'
row
'
,
justifyContent
:
'
space-between
'
,
paddingHorizontal
:
20
,
paddingVertical
:
10
,
},
infoLabel
:
{
fontWeight
:
'
bold
'
,
color
:
'
gray
'
,
},
infoContent
:
{
color
:
'
black
'
,
},
button
:
{
flexDirection
:
'
row
'
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
backgroundColor
:
COLORS
.
purple_new
,
borderRadius
:
20
,
width
:
'
90%
'
,
padding
:
15
,
marginVertical
:
5
,
marginTop
:
40
,
},
button2
:
{
flexDirection
:
'
row
'
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
backgroundColor
:
COLORS
.
red
,
borderRadius
:
20
,
width
:
'
90%
'
,
padding
:
15
,
marginVertical
:
5
,
marginTop
:
230
,
},
buttonText
:
{
textAlign
:
'
center
'
,
fontSize
:
18
,
color
:
COLORS
.
white
,
fontWeight
:
'
bold
'
,
},
buttonText2
:
{
textAlign
:
'
center
'
,
fontSize
:
20
,
color
:
COLORS
.
white
,
fontWeight
:
'
bold
'
,
},
icon1
:
{
justifyContent
:
'
flex-start
'
,
display
:
'
flex
'
,
},
new
:
{
marginRight
:
90
,
flexDirection
:
'
row
'
,
gap
:
20
,
},
});
export
default
UserProfile
;
src/screens/home/Home.js
View file @
00b60a06
import
React
from
'
react
'
;
import
{
Image
,
TouchableOpacity
,
Text
,
View
}
from
'
react-native
'
;
import
{
COLORS
,
IMGS
}
from
'
../../constants
'
;
import
{
COLORS
,
IMGS
,
ROUTES
}
from
'
../../constants
'
;
import
LinearGradient
from
'
react-native-linear-gradient
'
;
import
Icon
from
'
react-native-vector-icons/Ionicons
'
;
const
Home
=
()
=>
{
const
Home
=
(
{
navigation
}
)
=>
{
return
(
<
LinearGradient
style
=
{{
...
...
@@ -22,7 +23,16 @@ const Home = () => {
}}
/
>
<
/View
>
<
TouchableOpacity
style
=
{{
position
:
'
absolute
'
,
top
:
25
,
// Adjust top and right values as needed
right
:
20
,
zIndex
:
5
,
// Ensure the icon is on top of other elements
}}
onPress
=
{()
=>
navigation
.
navigate
(
ROUTES
.
PROFILE
)}
>
<
Icon
name
=
"
person-circle-sharp
"
size
=
{
35
}
color
=
{
COLORS
.
black
}
/
>
<
/TouchableOpacity
>
<
View
style
=
{{
paddingHorizontal
:
67
,
...
...
@@ -50,31 +60,6 @@ const Home = () => {
}}
>
e
-
MidWife
<
/Text
>
{
/* <View style={{marginTop: 1}}>
<TouchableOpacity
style={{
backgroundColor: COLORS.purple_new,
borderColor: COLORS.purple_new,
height: 50,
marginBottom: 50,
justifyContent: 'center',
alignItems: 'center',
borderRadius: 14,
width: '100%',
zIndex: 3,
elevation: 10,
}}
onPress={() => navigation.navigate(ROUTES.GAME_QUIZ_OPTIONS)}
>
<Text
medium
center
style={{color: 'white', fontSize: 24, fontWeight: 'bold'}}>
Start
</Text>
</TouchableOpacity>
</View> */
}
<
/View
>
<
/View
>
<
/LinearGradient
>
...
...
src/screens/home/game/QuizScore.js
View file @
00b60a06
...
...
@@ -98,7 +98,7 @@ const QuizScoreDisplayPage = ({route, navigation}) => {
style
=
{
styles
.
button
}
onPress
=
{
handleChooseGamePress
}
>
<
Text
bold
medium
center
style
=
{
styles
.
buttonText
}
>
Let
'
s
Improve Mental Well-Being
How
to
Improve
Mental
Well
-
Being
<
/Text
>
<
/TouchableOpacity
>
<
/View
>
...
...
src/services/auth/index.js
View file @
00b60a06
...
...
@@ -40,3 +40,29 @@ export let signup = async (name, password, email, age, week) => {
return
error
;
}
};
// getUserDetails API Call
// export const getUserDetails = async email => {
// try {
// const token = await AsyncStorage.getItem('userToken'); // Assuming you store token after login
// let response = await axios.get(
// `${BASE_PATH}/user-details?email=${encodeURIComponent(email)}`,
// {
// headers: {
// Authorization: `Bearer ${token}`, // Assuming you use Bearer token for authentication
// },
// },
// );
// console.log('userDetails', response.data);
// if (response.data.success === true) {
// await AsyncStorage.setItem(
// 'userDetails',
// JSON.stringify(response.data.data),
// );
// }
// return response.data;
// } catch (error) {
// console.error('Failed to fetch user details', error);
// throw error; // You might want to handle this differently depending on your error handling strategy
// }
// };
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