Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
exam_9_native
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zarina
exam_9_native
Commits
72013c72
Commit
72013c72
authored
May 23, 2020
by
zarina
🌊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#2
, добавлен вывод полной информации по клику на контакт
parent
65024688
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
95 additions
and
28 deletions
+95
-28
Contact.js
components/Contact/Contact.js
+6
-3
FullContact.js
components/FullContact/FullContact.js
+50
-0
Main.js
containers/Main/Main.js
+28
-14
actions.js
store/actions.js
+4
-7
actionsType.js
store/actionsType.js
+3
-0
reducer.js
store/reducer.js
+4
-4
No files found.
components/Contact/Contact.js
View file @
72013c72
...
...
@@ -5,7 +5,7 @@ const Contact = props => {
return
(
<
TouchableOpacity
style
=
{
styles
.
placeItem
}
onPress
=
{
props
.
showContact
}
>
<
Image
source
=
{{
uri
:
props
.
photo
}}
style
=
{
styles
.
image
}
/
>
<
Text
style
=
{
{
textTransform
:
'uppercase'
}
}
>
{
props
.
name
}
<
/Text
>
<
Text
style
=
{
styles
.
text
}
>
{
props
.
name
}
<
/Text
>
<
/TouchableOpacity
>
);
};
...
...
@@ -18,14 +18,17 @@ const styles = StyleSheet.create({
justifyContent
:
'space-between'
,
alignItems
:
'center'
,
width
:
'100%'
,
backgroundColor
:
'
#eee
'
,
backgroundColor
:
'
rgba(1,1,1,0.7)
'
,
marginBottom
:
10
,
padding
:
10
,
borderRadius
:
5
},
image
:
{
width
:
60
,
height
:
60
,
marginRight
:
10
},
text
:
{
color
:
'#eee'
}
});
components/FullContact/FullContact.js
0 → 100644
View file @
72013c72
import
React
from
'react'
;
import
{
StyleSheet
,
Image
,
Text
,
TouchableHighlight
,
View
}
from
"react-native"
;
const
FullContact
=
props
=>
{
return
(
<
View
style
=
{{
marginTop
:
22
,
flex
:
1
}}
>
<
View
>
<
Image
source
=
{{
uri
:
props
.
contact
.
photo
}}
style
=
{
styles
.
image
}
/
>
<
Text
style
=
{
styles
.
contactProps
}
>
Name
:
{
props
.
contact
.
name
}
<
/Text
>
<
Text
style
=
{
styles
.
contactProps
}
>
Mail
:
{
props
.
contact
.
email
}
<
/Text
>
<
Text
style
=
{
styles
.
contactProps
}
>
Phone
:
{
props
.
contact
.
phone
}
<
/Text
>
<
/View
>
<
TouchableHighlight
onPress
=
{
props
.
closeModal
}
style
=
{
styles
.
btn
}
>
<
Text
style
=
{
styles
.
text
}
>
Hide
Modal
<
/Text
>
<
/TouchableHighlight
>
<
/View
>
);
};
export
default
FullContact
;
const
styles
=
StyleSheet
.
create
({
image
:
{
width
:
200
,
height
:
200
,
marginRight
:
10
},
btn
:
{
position
:
'absolute'
,
bottom
:
0
,
padding
:
20
,
borderRadius
:
5
,
backgroundColor
:
'rgba(0,0,0,0.7)'
,
width
:
'100%'
},
contactProps
:
{
fontWeight
:
'bold'
,
fontSize
:
18
,
marginTop
:
10
,
},
text
:
{
fontSize
:
24
,
textAlign
:
'center'
,
color
:
'white'
}
});
\ No newline at end of file
containers/Main/Main.js
View file @
72013c72
...
...
@@ -3,19 +3,24 @@ import {StyleSheet, Modal, View, Text, FlatList} from "react-native";
import
{
connect
}
from
"react-redux"
;
import
{
getContacts
}
from
"../../store/actions"
;
import
Contact
from
"../../components/Contact/Contact"
;
import
ContactInfo
from
"../../components/FullContact/FullContact"
;
class
Main
extends
Component
{
state
=
{
chosenContact
:
{}
modalShow
:
false
,
contact
:
{}
};
componentDidMount
()
{
this
.
props
.
getContacts
();
}
setModalShow
(
val
)
{
this
.
setState
({
modalShow
:
val
});
}
chooseContact
=
(
contact
)
=>
{
this
.
setState
({
c
hosenContact
:
contact
,
modalVisible
:
true
});
this
.
setState
({
c
ontact
,
modalShow
:
true
});
};
render
()
{
...
...
@@ -33,7 +38,19 @@ class Main extends Component {
}
return
(
<
View
style
=
{
styles
.
main
}
>
<
Text
style
=
{
styles
.
heading
}
>
<
Modal
animationType
=
"slide"
transparent
=
{
false
}
visible
=
{
this
.
state
.
modalShow
}
onRequestClose
=
{()
=>
{
this
.
setModalShow
(
!
this
.
state
.
modalShow
);
}}
>
<
ContactInfo
contact
=
{
this
.
state
.
contact
}
closeModal
=
{()
=>
this
.
setState
({
modalShow
:
false
})}
/
>
<
/Modal
>
<
Text
style
=
{
styles
.
title
}
>
Contacts
<
/Text
>
<
FlatList
...
...
@@ -64,19 +81,16 @@ const mapDispatchToProps = dispatch => {
};
export
default
connect
(
mapStateToProps
,
mapDispatchToProps
)(
Main
);
const
styles
=
StyleSheet
.
create
({
heading
:
{
fontSize
:
32
,
borderColor
:
'transparent'
,
borderStyle
:
'solid'
,
borderWidth
:
2
,
borderBottomColor
:
'black'
,
title
:
{
fontSize
:
30
,
textTransform
:
'uppercase'
,
marginBottom
:
20
},
main
:
{
height
:
'100%'
,
marginTop
:
150
,
backgroundColor
:
'#ccc'
,
flex
:
1
,
justifyContent
:
'flex-start'
,
padding
:
40
}
});
\ No newline at end of file
store/actions.js
View file @
72013c72
import
axios
from
'../axios-contacts'
;
export
const
FETCH_CONTACTS_REQUEST
=
'FETCH_CONTACTS_REQUEST'
;
export
const
FETCH_CONTACTS_SUCCESS
=
'FETCH_CONTACTS_SUCCESS'
;
export
const
FETCH_CONTACTS_ERROR
=
'FETCH_CONTACTS_ERROR'
;
import
{
FETCH_ERROR
,
FETCH_REQUEST
,
FETCH_SUCCESS
}
from
"./actionsType"
;
export
const
fetchContactsRequest
=
()
=>
{
return
{
type
:
FETCH_
CONTACTS_
REQUEST
};
return
{
type
:
FETCH_REQUEST
};
};
export
const
fetchContactsSuccess
=
contacts
=>
{
return
{
type
:
FETCH_
CONTACTS_
SUCCESS
,
contacts
};
return
{
type
:
FETCH_SUCCESS
,
contacts
};
};
export
const
fetchContactsError
=
error
=>
{
return
{
type
:
FETCH_
CONTACTS_
ERROR
,
error
};
return
{
type
:
FETCH_ERROR
,
error
};
};
...
...
store/actionsType.js
0 → 100644
View file @
72013c72
export
const
FETCH_REQUEST
=
'FETCH_REQUEST'
;
export
const
FETCH_SUCCESS
=
'FETCH_SUCCESS'
;
export
const
FETCH_ERROR
=
'FETCH_ERROR'
;
\ No newline at end of file
store/reducer.js
View file @
72013c72
import
{
FETCH_
CONTACTS_ERROR
,
FETCH_CONTACTS_REQUEST
,
FETCH_CONTACTS_SUCCESS
}
from
"./actions
"
;
import
{
FETCH_
ERROR
,
FETCH_REQUEST
,
FETCH_SUCCESS
}
from
"./actionsType
"
;
const
initialState
=
{
loading
:
false
,
...
...
@@ -8,11 +8,11 @@ const initialState = {
const
reducer
=
(
state
=
initialState
,
action
)
=>
{
switch
(
action
.
type
)
{
case
FETCH_
CONTACTS_
REQUEST
:
case
FETCH_REQUEST
:
return
{...
state
,
loading
:
true
};
case
FETCH_
CONTACTS_
SUCCESS
:
case
FETCH_SUCCESS
:
return
{...
state
,
loading
:
false
,
contacts
:
action
.
contacts
};
case
FETCH_
CONTACTS_
ERROR
:
case
FETCH_ERROR
:
return
{...
state
,
loading
:
false
,
error
:
action
.
error
};
default
:
return
state
;
...
...
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